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

Jean-Noel Rouvignac
06.32.2015 74313fb840dff7a76d49f00930ddcfef6b412393
Fix ChangelogBackendTestCase randomness. Should be the last one!!

ChangelogBackendTestCase.java:
Fixed the failing searchInCookieModeOnTwoSuffixes() test by adding retry functionality to isOldestCSNForReplica().
In publishUpdateMessages(), added additional checks.
1 files modified
36 ■■■■ changed files
opendj-sdk/opendj-server-legacy/src/test/java/org/opends/server/backends/ChangelogBackendTestCase.java 36 ●●●● patch | view | raw | blame | history
opendj-sdk/opendj-server-legacy/src/test/java/org/opends/server/backends/ChangelogBackendTestCase.java
@@ -446,9 +446,8 @@
      isOldestCSNForReplica(DN_OTEST2, csn6);
      // test last cookie on root DSE
      MultiDomainServerState expectedLastCookie =
          new MultiDomainServerState("o=test:" + csn5 + " " + csn9 + ";o=test2:" + csn3 + " " + csn8 + ";");
      final String lastCookie = assertLastCookieIsEqualTo(expectedLastCookie.toString());
      String expectedLastCookie = "o=test:" + csn5 + " " + csn9 + ";o=test2:" + csn3 + " " + csn8 + ";";
      final String lastCookie = assertLastCookieIsEqualTo(expectedLastCookie);
      // test unknown domain in provided cookie
      // This case seems to be very hard to obtain in the real life
@@ -476,13 +475,28 @@
  private void isOldestCSNForReplica(DN baseDN, CSN csn) throws Exception
  {
    final ReplicationDomainDB domainDB = replicationServer.getChangelogDB().getReplicationDomainDB();
    CursorOptions options = new CursorOptions(GREATER_THAN_OR_EQUAL_TO_KEY, ON_MATCHING_KEY);
    try (DBCursor<UpdateMsg> cursor = domainDB.getCursorFrom(baseDN, csn.getServerId(), csn, options))
    AssertionError ex = null;
    int cnt = 0;
    while (cnt < 30)
    {
      assertTrue(cursor.next(),
          "Expected to find at least one change in replicaDB(" + baseDN + " " + csn.getServerId() + ")");
      assertEquals(cursor.getRecord().getCSN(), csn);
      cnt++;
      final ReplicationDomainDB domainDB = replicationServer.getChangelogDB().getReplicationDomainDB();
      CursorOptions options = new CursorOptions(GREATER_THAN_OR_EQUAL_TO_KEY, ON_MATCHING_KEY);
      try (DBCursor<UpdateMsg> cursor = domainDB.getCursorFrom(baseDN, csn.getServerId(), csn, options))
      {
        assertTrue(cursor.next(),
            "Expected to find at least one change in replicaDB(" + baseDN + " " + csn.getServerId() + ")");
        assertEquals(cursor.getRecord().getCSN(), csn);
        return;
      }
      catch (AssertionError e)
      {
        ex = e;
      }
    }
    if (ex != null)
    {
      throw ex;
    }
  }
@@ -1009,7 +1023,9 @@
    {
      if (msg instanceof UpdateMsg)
      {
        debugInfo(testName, " publishes " + ((UpdateMsg) msg).getCSN());
        final UpdateMsg updateMsg = (UpdateMsg) msg;
        assertThat(updateMsg.getCSN().getServerId()).isEqualTo(serverId);
        debugInfo(testName, " publishes " + updateMsg.getCSN());
      }
      broker.publish(msg);