mirror of https://github.com/OpenIdentityPlatform/OpenDJ.git

gbellato
22.59.2007 b182ea128bb2c9e70bdfb41ac056efef4ea70430
Fix for issue 1370 : tests for resynchronization after import or restore are failing
This was happening because in some cases the Changelog server was failing to re-send
the changes to the LDAP servers.

A new test have been added to test the Changelog server in this case.

It was also necessary to add some timeout in the test setup to let some time to
the synchornization to setup before starting the actual test. The tests have
therefore been marked as slow.

This commit also enables a Schema Synchronization test that was left disabled by error
in a previous commit

4 files modified
55 ■■■■■ changed files
opends/src/server/org/opends/server/synchronization/changelog/ChangelogDB.java 14 ●●●●● patch | view | raw | blame | history
opends/tests/unit-tests-testng/src/server/org/opends/server/synchronization/ReSyncTest.java 10 ●●●●● patch | view | raw | blame | history
opends/tests/unit-tests-testng/src/server/org/opends/server/synchronization/SchemaSynchronizationTest.java 2 ●●● patch | view | raw | blame | history
opends/tests/unit-tests-testng/src/server/org/opends/server/synchronization/changelog/ChangelogTest.java 29 ●●●●● patch | view | raw | blame | history
opends/src/server/org/opends/server/synchronization/changelog/ChangelogDB.java
@@ -323,8 +323,22 @@
        if (cursor.getSearchKey(key, data, LockMode.DEFAULT) !=
          OperationStatus.SUCCESS)
        {
          if (cursor.getSearchKeyRange(key, data, LockMode.DEFAULT) !=
            OperationStatus.SUCCESS)
          {
          throw new Exception("ChangeNumber not available");
        }
          else
          {
            DatabaseEntry key = new DatabaseEntry();
            DatabaseEntry data = new DatabaseEntry();
            if (cursor.getPrev(key, data, LockMode.DEFAULT) !=
             OperationStatus.SUCCESS)
           {
             cursor = db.openCursor(txn, null);
           }
          }
        }
      }
    }
opends/tests/unit-tests-testng/src/server/org/opends/server/synchronization/ReSyncTest.java
@@ -116,15 +116,17 @@
        + "cn: example\n"
        + "ds-cfg-synchronization-dn: dc=example,dc=com\n"
        + "ds-cfg-changelog-server: localhost:"+ changelogPort + "\n"
        + "ds-cfg-directory-server-id: 1\n";
        + "ds-cfg-directory-server-id: 123\n";
    synchroServerEntry = TestCaseUtils.entryFromLdifString(synchroServerLdif);
    configureSynchronization();
    // Give some time to the synchronization to setup
    Thread.sleep(1000);
    // Create a dummy entry
    addEntry("dn: dc=dummy, dc=example,dc=com\n"
        + "objectClass: top\n" + "objectClass: domain\n");
  }
  /**
@@ -153,7 +155,7 @@
  /**
   * Test re-synchronization after after backup/restore
   */
  @Test(enabled=false)
  @Test(enabled=true, groups="slow")
  public void testResyncAfterRestore() throws Exception
  {
    /*
@@ -208,7 +210,7 @@
  /**
   * Test re-synchronization after after backup/restore
   */
  @Test(enabled=false)
  @Test(enabled=true, groups="slow")
  public void testResyncAfterImport() throws Exception
  {
    /*
opends/tests/unit-tests-testng/src/server/org/opends/server/synchronization/SchemaSynchronizationTest.java
@@ -255,7 +255,7 @@
   * It causes schema tests in org.opends.server.core.AddOperationTestCase
   * to fail when running the build test target.
   */
  @Test(enabled=false, dependsOnMethods = { "replaySchemaChange" })
  @Test(enabled=true, dependsOnMethods = { "replaySchemaChange" })
  public void pushSchemaFilesChange() throws Exception
  {
    logError(ErrorLogCategory.SYNCHRONIZATION,
opends/tests/unit-tests-testng/src/server/org/opends/server/synchronization/changelog/ChangelogTest.java
@@ -81,6 +81,8 @@
  private ChangeNumber firstChangeNumberServer2 = null;
  private ChangeNumber secondChangeNumberServer2 = null;
  private ChangeNumber unknownChangeNumberServer1;
  /**
   * Before starting the tests, start the server and configure a
@@ -150,6 +152,16 @@
      secondChangeNumberServer2 = new ChangeNumber(time + 3, 2, (short) 2);
      /*
       * Create a ChangeNumber between firstChangeNumberServer1 and
       * secondChangeNumberServer1 that will not be used to create a
       * change sent to the changelog server but that will be used
       * in the Server State when opening a connection to the
       * Changelog Server to make sure that the Changelog server is
       * able to accept such clients.
       */
      unknownChangeNumberServer1 = new ChangeNumber(time+1, 1, (short) 1);
      /*
       * Send and receive a Delete Msg from server 1 to server 2
       */
      DeleteMsg msg =
@@ -310,6 +322,23 @@
  }
  /**
   * Test with a client that has already seen a Change that the
   * Changelog server has not seen.
   */
  @Test(enabled=true, dependsOnMethods = { "changelogBasic" })
  public void newClientWithUnknownChanges() throws Exception
  {
    /*
     * Create a ServerState with wrongChangeNumberServer1
     */
    ServerState state = new ServerState();
    state.update(unknownChangeNumberServer1);
    state.update(secondChangeNumberServer2);
    newClientWithChanges(state, secondChangeNumberServer1);
  }
  /**
   * Test that a client that has already seen the first change from server 1
   * now see the first change from server 2
   */