From f73b655466092169abac34833fb628fce1fcdebe Mon Sep 17 00:00:00 2001
From: jcduff <jcduff@localhost>
Date: Thu, 23 Oct 2008 14:04:24 +0000
Subject: [PATCH] The commit will bring the following features :     - An updated version of the underlying database. BDB JE 3.3 is now used.     - Attribute API refactoring providing a better abstraction and offering improved performances.     - A new GUI called the Control-Panel to replace the Status-Panel: the specifications for this       GUI are available on OpenDS Wiki and contains a link to a mockup.        See <https://www.opends.org/wiki/page/ControlPanelUISpecification>.     - Some changes in the replication protocol to implement "Assured Replication Mode". The        specifications are on OpenDS Wiki at <https://www.opends.org/wiki/page/AssuredMode> and section 7       described some of the replication changes required to support this. Assured Replication is not finished,       but the main replication protocol changes to support it are done. As explained by Gilles on an email on       the Dev mailing list (http://markmail.org/message/46rgo3meq3vriy4a), with these changes the newer versions       of OpenDS may not be able to replicate with OpenDS 1.0 instances.     - Support for Service Tags on the platforms where the functionality is available and enabled. Specifications       are published at <https://www.opends.org/wiki/page/OpenDSServiceTagEnabled>. For more information on       Service Tags see <http://wikis.sun.com/display/ServiceTag/Sun+Service+Tag+FAQ>.     - The Admin Connector service. In order to provide agentry of the OpenDS server at any time, a new service       has been added, dedicated to the administration, configuration and monitoring of the server.       An overview of the Admin Connector service and it's use is available on the       OpenDS wiki <https://www.opends.org/wiki/page/ManagingAdministrationTrafficToTheServer>     - Updates to the various command line tools to support the Admin Connector service.     - Some internal re-architecting of the server to put the foundation of future developments such as virtual       directory services. The new NetworkGroups and WorkFlow internal services which have been specified in       <https://www.opends.org/wiki/page/BasicOperationRoutingThroughNetworkGroup> are now implemented.     - Many bug fixes...

---
 opends/tests/unit-tests-testng/src/server/org/opends/server/replication/ReSyncTest.java |   98 ++++++++++++++++++++++++++++++++++++------------
 1 files changed, 73 insertions(+), 25 deletions(-)

diff --git a/opends/tests/unit-tests-testng/src/server/org/opends/server/replication/ReSyncTest.java b/opends/tests/unit-tests-testng/src/server/org/opends/server/replication/ReSyncTest.java
index 3e2e4e8..eb65fe1 100644
--- a/opends/tests/unit-tests-testng/src/server/org/opends/server/replication/ReSyncTest.java
+++ b/opends/tests/unit-tests-testng/src/server/org/opends/server/replication/ReSyncTest.java
@@ -32,20 +32,44 @@
 import java.net.ServerSocket;
 import java.util.UUID;
 
+import org.opends.messages.Category;
+import org.opends.messages.Message;
+import org.opends.messages.Severity;
 import org.opends.server.TestCaseUtils;
 import org.opends.server.core.AddOperationBasis;
+import org.opends.server.loggers.debug.DebugTracer;
 import org.opends.server.protocols.internal.InternalClientConnection;
+import org.opends.server.replication.plugin.ReplicationDomain;
 import org.opends.server.types.DN;
 import org.opends.server.types.Entry;
 import org.opends.server.types.ResultCode;
+import org.testng.annotations.AfterClass;
 import org.testng.annotations.BeforeClass;
 import org.testng.annotations.Test;
+import static org.opends.server.TestCaseUtils.*;
+import static org.opends.server.loggers.debug.DebugLogger.debugEnabled;
+import static org.opends.server.loggers.ErrorLogger.logError;
+import static org.opends.server.loggers.debug.DebugLogger.getTracer;
 
 /**
  * Test re-synchronization after after backup/restore and LDIF import.
  */
 public class ReSyncTest extends ReplicationTestCase
 {
+  // The tracer object for the debug logger
+  private static final DebugTracer TRACER = getTracer();
+
+  private void debugInfo(String s)
+  {
+    logError(Message.raw(Category.SYNC, Severity.NOTICE, s));
+    if (debugEnabled())
+    {
+      TRACER.debugInfo(s);
+    }
+  }
+
+  protected static final String EXAMPLE_DN = "dc=example,dc=com";
+
  /**
   * Set up the environment for performing the tests in this Class.
   *
@@ -55,48 +79,47 @@
  @BeforeClass
   public void setup() throws Exception
   {
+   super.setUp();
+
    /*
-    * - Start a server and a replicationServer, configure replication
+    * - Configure replication
     * - Do some changes.
     */
-    TestCaseUtils.startServer();
 
     // find  a free port for the replicationServer
     ServerSocket socket = TestCaseUtils.bindFreePort();
     int replServerPort = socket.getLocalPort();
     socket.close();
 
-    // Create an internal connection
-    connection = InternalClientConnection.getRootConnection();
+    // This test uses restore task which does not work with memory backend
+    // (like the test backend we use in every tests): backend is disabled then
+    // re-enabled and this clears the backend reference and thus the underlying
+    // data. So for this particular test, we use a classical backend. Let's
+    // clear it and create the root entry
 
-    //  Create backend top level entries
+    ReplicationDomain.clearJEBackend(false, "userRoot", EXAMPLE_DN);
     addEntry("dn: dc=example,dc=com\n" + "objectClass: top\n"
         + "objectClass: domain\n");
 
-    // top level synchro provider
-    String synchroStringDN = "cn=Synchronization Providers,cn=config";
-
-    // Multimaster Synchro plugin
-    synchroPluginStringDN = "cn=Multimaster Synchronization, "
-        + synchroStringDN;
-
     // Change log
     String replServerLdif =
-      "dn: " + "cn=Replication Server, " + synchroPluginStringDN + "\n"
+      "dn: " + "cn=Replication Server, " + SYNCHRO_PLUGIN_DN + "\n"
         + "objectClass: top\n"
         + "objectClass: ds-cfg-replication-server\n"
         + "cn: Replication Server\n"
         + "ds-cfg-replication-port:" + replServerPort + "\n"
-        + "ds-cfg-replication-server-id: 1\n";
+        + "ds-cfg-replication-db-directory: ReSyncTest\n"    
+        + "ds-cfg-replication-server-id: 104\n";
     replServerEntry = TestCaseUtils.entryFromLdifString(replServerLdif);
 
     // suffix synchronized
+    String reSyncTest = "reSyncTest";
     String domainLdif =
-      "dn: cn=example, cn=domains, " + synchroPluginStringDN + "\n"
+      "dn: cn=" + reSyncTest + ", cn=domains, " + SYNCHRO_PLUGIN_DN + "\n"
         + "objectClass: top\n"
         + "objectClass: ds-cfg-replication-domain\n"
-        + "cn: example\n"
-        + "ds-cfg-base-dn: dc=example,dc=com\n"
+        + "cn: " + reSyncTest + "\n"
+        + "ds-cfg-base-dn: " + EXAMPLE_DN + "\n"
         + "ds-cfg-replication-server: localhost:"+ replServerPort + "\n"
         + "ds-cfg-server-id: 123\n";
     synchroServerEntry = TestCaseUtils.entryFromLdifString(domainLdif);
@@ -107,7 +130,7 @@
     Thread.sleep(1000);
 
     // Create a dummy entry
-    addEntry("dn: dc=dummy, dc=example,dc=com\n"
+    addEntry("dn: dc=dummy," + EXAMPLE_DN + "\n"
         + "objectClass: top\n" + "objectClass: domain\n");
   }
 
@@ -150,7 +173,8 @@
 
     // Delete the entry we are going to use to make sure that
     // we do test something.
-    connection.processDelete(DN.decode("dc=foo, dc=example,dc=com"));
+
+    connection.processDelete(DN.decode("dc=fooUniqueName1," + EXAMPLE_DN));
 
     task("dn: ds-task-id=" + UUID.randomUUID()
         +  ",cn=Scheduled Tasks,cn=Tasks\n"
@@ -161,8 +185,10 @@
         + "ds-backup-directory-path: bak\n"
         + "ds-task-backup-all: TRUE\n");
 
-    addEntry("dn: dc=foo, dc=example,dc=com\n"
+    debugInfo("testResyncAfterRestore: backup done");
+    addEntry("dn: dc=fooUniqueName1," + EXAMPLE_DN + "\n"
         + "objectClass: top\n" + "objectClass: domain\n");
+    debugInfo("testResyncAfterRestore: entry added");
 
     task("dn: ds-task-id=" + UUID.randomUUID()
         + ",cn=Scheduled Tasks,cn=Tasks\n"
@@ -173,10 +199,12 @@
         + "ds-backup-directory-path: bak" + File.separator
         + "userRoot\n");
 
-   if (getEntry(DN.decode("dc=foo, dc=example,dc=com"), 30000, true) == null)
+    debugInfo("testResyncAfterRestore: restore done");
+
+   if (getEntry(DN.decode("dc=fooUniqueName1," + EXAMPLE_DN), 30000, true) == null)
      fail("The Directory has not been resynchronized after the restore.");
 
-   connection.processDelete(DN.decode("dc=foo, dc=example,dc=com"));
+   connection.processDelete(DN.decode("dc=fooUniqueName1," + EXAMPLE_DN));
   }
 
   /**
@@ -194,7 +222,7 @@
 
     // delete the entry we are going to use to make sure that
     // we do test something.
-    connection.processDelete(DN.decode("dc=foo, dc=example,dc=com"));
+    connection.processDelete(DN.decode("dc=fooUniqueName2," + EXAMPLE_DN));
 
     String buildRoot = System.getProperty(TestCaseUtils.PROPERTY_BUILD_ROOT);
     String path = buildRoot + File.separator + "build" +
@@ -210,8 +238,10 @@
         + "ds-task-export-backend-id: userRoot\n"
         + "ds-task-export-ldif-file: " + path + "\n");
 
-    addEntry("dn: dc=foo, dc=example,dc=com\n"
+    debugInfo("testResyncAfterImport: export done");
+    addEntry("dn: dc=fooUniqueName2," + EXAMPLE_DN + "\n"
         + "objectClass: top\n" + "objectClass: domain\n");
+    debugInfo("testResyncAfterImport: entry added");
 
     task("dn: ds-task-id=" + UUID.randomUUID()
         + ",cn=Scheduled Tasks,cn=Tasks\n"
@@ -223,9 +253,27 @@
         + "ds-task-import-ldif-file: " + path + "\n"
         + "ds-task-import-reject-file: " + path + "reject\n");
 
-   if (getEntry(DN.decode("dc=foo, dc=example,dc=com"), 30000, true) == null)
+    debugInfo("testResyncAfterImport: import done");
+
+   if (getEntry(DN.decode("dc=fooUniqueName2," + EXAMPLE_DN), 30000, true) == null)
      fail("The Directory has not been resynchronized after the restore.");
   }
+  
+  /**
+   * Clean up the environment.
+   *
+   * @throws Exception If the environment could not be set up.
+   */
+  @AfterClass
+  @Override
+  public void classCleanUp() throws Exception
+  {
+    callParanoiaCheck = false;
+    super.classCleanUp();
 
+    // Clear the backend
+    ReplicationDomain.clearJEBackend(false, "userRoot", EXAMPLE_DN);
 
+    paranoiaCheck();
+  }
 }

--
Gitblit v1.10.0