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

Ludovic Poitou
12.52.2011 a400ee2b6f6e9a76323e73a8e4e5e8681d6dc126
Fix to OPENDJ-274, resolve remaining nightly unit test failure with modifications of single valued attributes.
Tidy up some of the unit-tests around that area, adding more controls, making sure tests stop services on failure and reducing time to run.
4 files modified
97 ■■■■■ changed files
opendj-sdk/opends/src/server/org/opends/server/replication/plugin/AttrHistoricalSingle.java 3 ●●●● patch | view | raw | blame | history
opendj-sdk/opends/tests/unit-tests-testng/src/server/org/opends/server/replication/UpdateOperationTest.java 47 ●●●● patch | view | raw | blame | history
opendj-sdk/opends/tests/unit-tests-testng/src/server/org/opends/server/replication/plugin/HistoricalTest.java 31 ●●●● patch | view | raw | blame | history
opendj-sdk/opends/tests/unit-tests-testng/src/server/org/opends/server/replication/plugin/ModifyConflictTest.java 16 ●●●●● patch | view | raw | blame | history
opendj-sdk/opends/src/server/org/opends/server/replication/plugin/AttrHistoricalSingle.java
@@ -251,8 +251,7 @@
      break;
    case REPLACE:
      if ((changeNumber.older(deleteTime))
          && ((addTime == null) || (changeNumber.older(addTime))))
      if (changeNumber.older(deleteTime))
      {
        conflict = true;
        modsIterator.remove();
opendj-sdk/opends/tests/unit-tests-testng/src/server/org/opends/server/replication/UpdateOperationTest.java
@@ -23,6 +23,7 @@
 *
 *
 *      Copyright 2006-2010 Sun Microsystems, Inc.
 *      Portions Copyright 2011 ForgeRock AS
 */
package org.opends.server.replication;
@@ -316,6 +317,8 @@
      openReplicationSession(baseDn, 2, 100, replServerPort, 1000, true);
    try
    {
    /*
     * Create a Change number generator to generate new changenumbers
     * when we need to send operation messages to the replicationServer.
@@ -341,8 +344,8 @@
    // Check that the entry has not been created in the directory server.
    resultEntry = getEntry(personWithUUIDEntry.getDN(), 1000, true);
    assertNull(resultEntry,
        "The replication message was replayed while the server " +
             "receive status was disabled");
          "The replication message was replayed while the server "
          + "receive status was disabled");
    // Enable the directory server receive status.
    setReceiveStatus(synchroServerEntry.getDN().toString(), true);
@@ -359,8 +362,8 @@
    // Check that the entry has been created in the directory server.
    resultEntry = getEntry(personWithUUIDEntry.getDN(), 10000, true);
    assertNotNull(resultEntry,
        "The replication message was not replayed after the server " +
             "receive status was enabled");
          "The replication message was not replayed after the server "
          + "receive status was enabled");
    // Delete the entries to clean the database.
    DeleteMsg delMsg =
@@ -372,8 +375,12 @@
    // Check that the delete operation has been applied.
    assertNull(resultEntry,
        "The DELETE replication message was not replayed");
    }
    finally
    {
    broker.stop();
  }
  }
  /**
   * Tests whether the synchronization provider fails over when it loses
@@ -397,7 +404,8 @@
    ReplicationBroker broker =
      openReplicationSession(baseDn, 2, 100, replServerPort, 1000, true);
    try
    {
    /*
     * Create a Change number generator to generate new changenumbers
     * when we need to send operation messages to the replicationServer.
@@ -467,8 +475,12 @@
    // Check that the delete operation has been applied.
    assertNull(resultEntry,
        "The DELETE replication message was not replayed");
    }
    finally
    {
    broker.stop();
  }
  }
  /**
   * Tests the modify conflict resolution code.
@@ -502,6 +514,8 @@
    ReplicationBroker broker =
      openReplicationSession(baseDn, 2, 100, replServerPort, 1000, true);
    try
    {
    // Add the first test entry.
    TestCaseUtils.addEntry(
         "dn: cn=test1," + baseDn.toString(),
@@ -511,8 +525,7 @@
         "objectClass: organizationalPerson",
         "objectClass: inetOrgPerson",
         "cn: test1",
         "sn: test"
       );
          "sn: test");
    // Read the entry back to get its UUID.
    Entry entry = DirectoryServer.getEntry(dn1);
@@ -598,12 +611,15 @@
    entry = DirectoryServer.getEntry(dn1);
    attrs = entry.getAttribute(attrType);
    // there should not be a value (delete at time t1)
      // there should not be a value (delete at time t2)
    assertNull(attrs);
    assertEquals(getMonitorDelta(), 1);
    }
    finally
    {
    broker.stop();
  }
  }
  /**
@@ -636,6 +652,8 @@
    ReplicationBroker broker =
      openReplicationSession(baseDn, 2, 100, replServerPort, 1000, true);
    try
    {
    /*
     * Create a Change number generator to generate new changenumbers
     * when we need to send operations messages to the replicationServer.
@@ -1299,9 +1317,12 @@
        DN.decode("uid=new person,ou=baseDn2,"+baseDn),
        LDAPReplicationDomain.DS_SYNC_CONFLICT,
        "uid=newrdn,ou=baseDn2,ou=People," + TEST_ROOT_DN_STRING, 1000, true));
    }
    finally
    {
    broker.stop();
  }
  }
  /**
   * Check that the given entry does contain the attribute that mark the
@@ -1731,6 +1752,8 @@
    ReplicationBroker broker =
      openReplicationSession(baseDn, serverId, 100, replServerPort, 1000, true);
    try
    {
    /*
     * Create a Change number generator to generate new changenumbers
     * when we need to send operation messages to the replicationServer.
@@ -1788,6 +1811,10 @@
    resultEntry = getEntry(user3Entry.getDN(), 10000, false);
    assertNull(resultEntry,
        "The DELETE replication message was not replayed");
    }
    finally
    {
    broker.stop();
  }
}
}
opendj-sdk/opends/tests/unit-tests-testng/src/server/org/opends/server/replication/plugin/HistoricalTest.java
@@ -23,6 +23,7 @@
 *
 *
 *      Copyright 2008-2010 Sun Microsystems, Inc.
 *      Portions Copyright 2011 ForgeRock AS
 */
package org.opends.server.replication.plugin;
@@ -346,8 +347,6 @@
    mod = new Modification(ModificationType.ADD, attr);
    publishModify(broker, t2, dn1, entryuuid, mod);
    Thread.sleep(2000);
    // Simulate the reverse ordering t2:add:B followed by t1:add:A that
    // would happen on the other server.
@@ -554,36 +553,14 @@
    addEntriesWithHistorical(1, entryCnt);
    /*
    // every entry should have its hist
    try
    {
      // Search for matching entries in config backend
      InternalSearchOperation op = connection.processSearch(
          ByteString.valueOf(TEST_ROOT_DN_STRING),
          SearchScope.WHOLE_SUBTREE,
          LDAPFilter.decode("(ds-sync-hist=*)"));
      assertEquals(op.getResultCode(), ResultCode.SUCCESS,
          op.getErrorMessage().toString());
      // Check that no entries have been found
      LinkedList<SearchResultEntry> entries = op.getSearchEntries();
      assertTrue(entries != null);
      assertEquals(entries.size(), entryCnt);
    } catch (Exception e)
    {
      fail("assertNoConfigEntriesWithFilter: could not search config backend" + e.getMessage());
    }
    */
    // set the purge delay to 1 sec
    TestCaseUtils.dsconfig(
        "set-replication-domain-prop",
        "--provider-name","Multimaster Synchronization",
        "--domain-name",testName,
        "--set","conflicts-historical-purge-delay:1m");
        "--set","conflicts-historical-purge-delay:1s");
    Thread.sleep(60*1000);
    Thread.sleep(2*1000);
    // launch the purge
    Entry taskInit = TestCaseUtils.makeEntry(
@@ -594,7 +571,7 @@
        "objectclass: ds-task-purge-conflicts-historical",
        "ds-task-class-name: org.opends.server.tasks.PurgeConflictsHistoricalTask",
        "ds-task-purge-conflicts-historical-domain-dn: "+TEST_ROOT_DN_STRING,
    "ds-task-purge-conflicts-historical-maximum-duration: 1000"); // 1000 sec
    "ds-task-purge-conflicts-historical-maximum-duration: 120"); // 120 sec
    addTask(taskInit, ResultCode.SUCCESS, null);
opendj-sdk/opends/tests/unit-tests-testng/src/server/org/opends/server/replication/plugin/ModifyConflictTest.java
@@ -156,6 +156,10 @@
    testModify(entry, hist, DISPLAYNAME, ModificationType.ADD, "new value",
               11, false);
    List<Attribute> attrs = entry.getAttribute(DISPLAYNAME);
    Attribute attr = attrs.get(0);
    assertEquals(1, attr.size());
    attr.contains(AttributeValues.create(attr.getAttributeType(), "init value"));
  }
  /**
@@ -267,12 +271,22 @@
    testModify(entry, hist, DISPLAYNAME, ModificationType.REPLACE,
        "older value", 1, true);
    List<Attribute> attrs = entry.getAttribute(DISPLAYNAME);
    Attribute attr = attrs.get(0);
    assertEquals(1, attr.size());
    attr.contains(AttributeValues.create(attr.getAttributeType(), "older value"));
    /*
     * Now simulate a replace at a later date.
     * Conflict resolution should keept it.
     */
    testModify(entry, hist, DISPLAYNAME, ModificationType.REPLACE,
        "older value", 3, true);
        "newer value", 3, true);
    attrs = entry.getAttribute(DISPLAYNAME);
    attr = attrs.get(0);
    assertEquals(1, attr.size());
    attr.contains(AttributeValues.create(attr.getAttributeType(), "newer value"));
  }