| | |
| | | import static org.opends.server.util.CollectionUtils.*; |
| | | import static org.testng.Assert.*; |
| | | |
| | | /** |
| | | * An abstract class that all Replication unit test should extend. |
| | | */ |
| | | /** An abstract class that all Replication unit test should extend. */ |
| | | @SuppressWarnings("javadoc") |
| | | @Test(groups = { "precommit", "replication" }, sequential = true) |
| | | public abstract class ReplicationTestCase extends DirectoryServerTestCase |
| | |
| | | */ |
| | | protected static final long TEST_DN_WITH_ROOT_ENTRY_GENID = 5055L; |
| | | |
| | | /** |
| | | * Generation id for a fully empty domain. |
| | | */ |
| | | /** Generation id for a fully empty domain. */ |
| | | public static final long EMPTY_DN_GENID = GenerationIdChecksum.EMPTY_BACKEND_GENERATION_ID; |
| | | |
| | | /** |
| | | * The internal connection used for operation. |
| | | */ |
| | | /** The internal connection used for operation. */ |
| | | protected InternalClientConnection connection; |
| | | |
| | | /** Created entries that will be deleted on class cleanup. */ |
| | |
| | | public static ReplicationDBImplementation replicationDbImplementation = ReplicationDBImplementation.valueOf( |
| | | System.getProperty(REPLICATION_DB_IMPL_PROPERTY, ReplicationDBImplementation.LOG.name())); |
| | | |
| | | /** |
| | | * Replication monitor stats. |
| | | */ |
| | | /** Replication monitor stats. */ |
| | | private DN monitorDN; |
| | | private String monitorAttr; |
| | | private long lastCount; |
| | |
| | | */ |
| | | protected boolean callParanoiaCheck = true; |
| | | |
| | | /** |
| | | * The replication plugin entry. |
| | | */ |
| | | /** The replication plugin entry. */ |
| | | protected static final String SYNCHRO_PLUGIN_DN = |
| | | "cn=Multimaster Synchronization, cn=Synchronization Providers,cn=config"; |
| | | |
| | | /** |
| | | * Set up the environment for performing the tests in this suite. |
| | | */ |
| | | /** Set up the environment for performing the tests in this suite. */ |
| | | @BeforeClass |
| | | public void setUp() throws Exception |
| | | { |
| | |
| | | } |
| | | catch(Exception e) { |
| | | logger.traceException(e); |
| | | |
| | | // This is the value of the generationId computed by the server when the |
| | | // test suffix (o=test) has only the root entry created. |
| | | return TEST_DN_WITH_ROOT_ENTRY_GENID; |
| | | } |
| | | // This is the value of the generationId computed by the server when the |
| | | // test suffix (o=test) has only the root entry created. |
| | | return TEST_DN_WITH_ROOT_ENTRY_GENID; |
| | | } |
| | | |
| | | /** |
| | |
| | | port, timeout, getGenerationId(baseDN)); |
| | | } |
| | | |
| | | /** |
| | | * Open a replicationServer session to the local ReplicationServer |
| | | * providing the generationId. |
| | | */ |
| | | /** Open a replicationServer session to the local ReplicationServer providing the generationId. */ |
| | | protected ReplicationBroker openReplicationSession(final DN baseDN, |
| | | int serverId, int windowSize, int port, int timeout, |
| | | long generationId) throws Exception |
| | |
| | | |
| | | protected void deleteEntry(DN dn) throws Exception |
| | | { |
| | | if (dn.parent().rdn().toString().equalsIgnoreCase("cn=domains")) |
| | | if ("cn=domains".equalsIgnoreCase(dn.parent().rdn().toString())) |
| | | { |
| | | deleteEntry(DN.valueOf("cn=external changelog," + dn)); |
| | | } |
| | |
| | | "Delete entry " + dn + " failed: " + op.getResultCode()); |
| | | } |
| | | |
| | | /** |
| | | * Suppress all the config entries created by the tests in this class. |
| | | */ |
| | | /** Suppress all the config entries created by the tests in this class. */ |
| | | protected void cleanConfigEntries() throws Exception |
| | | { |
| | | logger.error(LocalizableMessage.raw("ReplicationTestCase/Cleaning config entries")); |
| | |
| | | replServerEntry = null; |
| | | } |
| | | |
| | | /** |
| | | * Suppress all the real entries created by the tests in this class. |
| | | */ |
| | | /** Suppress all the real entries created by the tests in this class. */ |
| | | protected void cleanRealEntries() throws Exception |
| | | { |
| | | logger.error(LocalizableMessage.raw("ReplicationTestCase/Cleaning entries")); |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * Cleanup databases of the currently instantiated replication servers in the |
| | | * VM. |
| | | */ |
| | | /** Cleanup databases of the currently instantiated replication servers in the VM. */ |
| | | protected void cleanUpReplicationServersDB() throws Exception |
| | | { |
| | | for (ReplicationServer rs : ReplicationServer.getAllInstances()) |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * Remove trailing directories and databases of the currently instantiated |
| | | * replication servers. |
| | | */ |
| | | /** Remove trailing directories and databases of the currently instantiated replication servers. */ |
| | | protected void removeReplicationServerDB() throws Exception |
| | | { |
| | | // avoid ConcurrentModificationException |
| | |
| | | assertEquals(entries.size(), 0, errorMsg + ":\n" + sb); |
| | | } |
| | | |
| | | /** |
| | | * Configure the replication for this test. |
| | | */ |
| | | /** Configure the replication for this test. */ |
| | | protected void configureReplication(String replServerEntryLdif, |
| | | String synchroServerEntryLdif) throws Exception |
| | | { |
| | |
| | | return null; |
| | | } |
| | | |
| | | /** |
| | | * Update the monitor count for the specified monitor attribute. |
| | | */ |
| | | /** Update the monitor count for the specified monitor attribute. */ |
| | | protected void updateMonitorCount(DN baseDN, String attr) throws Exception |
| | | { |
| | | monitorDN = baseDN; |
| | |
| | | return mods; |
| | | } |
| | | |
| | | /** |
| | | * Utility method to create, run a task and check its result. |
| | | */ |
| | | /** Utility method to create, run a task and check its result. */ |
| | | protected void task(String task) throws Exception |
| | | { |
| | | Entry taskEntry = TestCaseUtils.addEntry(task); |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * Add to the current DB the entries necessary to the test. |
| | | */ |
| | | /** Add to the current DB the entries necessary to the test. */ |
| | | protected void addTestEntriesToDB(String... ldifEntries) throws Exception |
| | | { |
| | | for (String ldifEntry : ldifEntries) |
| | |
| | | return found; |
| | | } |
| | | |
| | | /** |
| | | * Utility method : removes a domain deleting the passed config entry |
| | | */ |
| | | /** Utility method : removes a domain deleting the passed config entry */ |
| | | protected void removeDomain(Entry... domainCfgEntries) throws Exception |
| | | { |
| | | for (Entry entry : domainCfgEntries) |