From 79a8669d6be5ac1fe2f1b62e3a48568200bd3148 Mon Sep 17 00:00:00 2001
From: gbellato <gbellato@localhost>
Date: Wed, 22 Aug 2007 07:36:24 +0000
Subject: [PATCH] issue 1804 : Ensure that conflicts are visible to administrators

---
 opends/tests/unit-tests-testng/src/server/org/opends/server/replication/UpdateOperationTest.java |   81 ++++++++++++++++++++++++++++++++++++++++
 1 files changed, 81 insertions(+), 0 deletions(-)

diff --git a/opends/tests/unit-tests-testng/src/server/org/opends/server/replication/UpdateOperationTest.java b/opends/tests/unit-tests-testng/src/server/org/opends/server/replication/UpdateOperationTest.java
index 4d1d947..394dc9e 100644
--- a/opends/tests/unit-tests-testng/src/server/org/opends/server/replication/UpdateOperationTest.java
+++ b/opends/tests/unit-tests-testng/src/server/org/opends/server/replication/UpdateOperationTest.java
@@ -51,6 +51,7 @@
 import org.opends.server.core.ModifyDNOperationBasis;
 import org.opends.server.core.ModifyOperation;
 import org.opends.server.core.ModifyOperationBasis;
+import org.opends.server.extensions.DummyAlertHandler;
 import org.opends.server.plugins.ShortCircuitPlugin;
 import org.opends.server.protocols.asn1.ASN1OctetString;
 import org.opends.server.protocols.internal.InternalClientConnection;
@@ -80,6 +81,7 @@
 import org.opends.server.types.RDN;
 import org.opends.server.types.RawModification;
 import org.opends.server.types.ResultCode;
+import org.opends.server.util.TimeThread;
 import org.testng.annotations.BeforeClass;
 import org.testng.annotations.DataProvider;
 import org.testng.annotations.Test;
@@ -653,6 +655,7 @@
         DN.decode("cn=something,ou=People,dc=example,dc=com"), mods,
         user1entryUUID);
     updateMonitorCount(baseDn, resolvedMonitorAttr);
+    int AlertCount = DummyAlertHandler.getAlertCount();
     broker.publish(modMsg);
 
     // check that the modify has been applied as if the entry had been renamed.
@@ -661,6 +664,11 @@
     if (found == false)
      fail("The modification has not been correctly replayed.");
     assertEquals(getMonitorDelta(), 1);
+    
+    // check that there was no administrative alert generated
+    // because the conflict has been automatically resolved.
+    assertEquals(DummyAlertHandler.getAlertCount(), AlertCount,
+        "An alert was incorrectly generated when resolving conflicts");
 
     /*
      * Test that the conflict resolution code is able to detect
@@ -691,14 +699,22 @@
     modMsg = new ModifyMsg(gen.newChangeNumber(),
         DN.decode(user1dn), mods, "10000000-9abc-def0-1234-1234567890ab");
     updateMonitorCount(baseDn, resolvedMonitorAttr);
+    AlertCount = DummyAlertHandler.getAlertCount();
     broker.publish(modMsg);
 
     // check that the modify has not been applied
+    TimeThread.sleep(2000);
     found = checkEntryHasAttribute(personWithUUIDEntry.getDN(),
                            "telephonenumber", "02 01 03 05", 10000, false);
     if (found == true)
      fail("The modification has been replayed while it should not.");
     assertEquals(getMonitorDelta(), 1);
+    
+    // Check that there was no administrative alert generated
+    // because the conflict has been automatically resolved.
+    assertEquals(DummyAlertHandler.getAlertCount(), AlertCount,
+        "An alert was incorrectly generated when resolving conflicts");
+
 
 
     /*
@@ -714,6 +730,7 @@
       new DeleteMsg("cn=anotherdn,ou=People,dc=example,dc=com",
           gen.newChangeNumber(), user1entryUUID);
     updateMonitorCount(baseDn, resolvedMonitorAttr);
+    AlertCount = DummyAlertHandler.getAlertCount();
     broker.publish(delMsg);
 
     // check that the delete operation has been applied
@@ -722,6 +739,10 @@
     assertNull(resultEntry,
         "The DELETE replication message was not replayed");
     assertEquals(getMonitorDelta(), 1);
+    // Check that there was no administrative alert generated
+    // because the conflict has been automatically resolved.
+    assertEquals(DummyAlertHandler.getAlertCount(), AlertCount,
+        "An alert was incorrectly generated when resolving conflicts");
 
     /*
      * Test that two adds with the same DN but a different unique ID result
@@ -749,6 +770,7 @@
         personWithSecondUniqueID.getObjectClassAttribute(),
         personWithSecondUniqueID.getAttributes(), new ArrayList<Attribute>());
     updateMonitorCount(baseDn, unresolvedMonitorAttr);
+    AlertCount = DummyAlertHandler.getAlertCount();
     broker.publish(addMsg);
 
     //  Check that the entry has been renamed and created in the local DS.
@@ -759,6 +781,11 @@
         "The ADD replication message was not applied");
     assertEquals(getMonitorDelta(), 1);
     assertConflictAttribute(resultEntry);
+    // Check that there was an administrative alert generated
+    // because the conflict has not been automatically resolved.
+    assertEquals(DummyAlertHandler.getAlertCount(), AlertCount+1,
+        "An alert was not generated when resolving conflicts");
+
 
     //  delete the entries to clean the database.
     delMsg =
@@ -788,6 +815,7 @@
         personWithUUIDEntry.getObjectClassAttribute(),
         personWithUUIDEntry.getAttributes(), new ArrayList<Attribute>());
     updateMonitorCount(baseDn, resolvedMonitorAttr);
+    AlertCount = DummyAlertHandler.getAlertCount();
     broker.publish(addMsg);
 
     //  Check that the entry has been renamed and created in the local DS.
@@ -796,6 +824,11 @@
     assertNotNull(resultEntry,
         "The ADD replication message was not applied");
     assertEquals(getMonitorDelta(), 1);
+    // Check that there was no administrative alert generated
+    // because the conflict has been automatically resolved.
+    assertEquals(DummyAlertHandler.getAlertCount(), AlertCount,
+        "An alert was incorrectly generated when resolving conflicts");
+
 
     /*
      * Check that when replaying delete the naming conflict code
@@ -810,6 +843,7 @@
       new DeleteMsg("uid=new person,ou=People,dc=example,dc=com",
           gen.newChangeNumber(), "11111111-9abc-def0-1234-1234567890ab");
     updateMonitorCount(baseDn, resolvedMonitorAttr);
+    AlertCount = DummyAlertHandler.getAlertCount();
     broker.publish(delMsg);
     resultEntry = getEntry(
           DN.decode("uid=new person,ou=People,dc=example,dc=com"), 10000, true);
@@ -818,6 +852,11 @@
     assertNotNull(resultEntry,
         "The DELETE replication message was replayed when it should not");
     assertEquals(getMonitorDelta(), 1);
+    
+    // Check that there was no administrative alert generated
+    // because the conflict has been automatically resolved.
+    assertEquals(DummyAlertHandler.getAlertCount(), AlertCount,
+        "An alert was incorrectly generated when resolving conflicts");
 
 
     /*
@@ -835,6 +874,7 @@
         "uid=wrong, ou=people,dc=example,dc=com",
         "uid=newrdn");
     updateMonitorCount(baseDn, resolvedMonitorAttr);
+    AlertCount = DummyAlertHandler.getAlertCount();
     broker.publish(modDnMsg);
 
     resultEntry = getEntry(
@@ -844,6 +884,12 @@
     assertNotNull(resultEntry,
       "The modify dn was not or badly replayed");
     assertEquals(getMonitorDelta(), 1);
+    
+    // Check that there was no administrative alert generated
+    // because the conflict has been automatically resolved.
+    assertEquals(DummyAlertHandler.getAlertCount(), AlertCount,
+        "An alert was incorrectly generated when resolving conflicts");
+
 
     /*
      * same test but by giving a bad entry DN
@@ -853,6 +899,7 @@
         "uid=wrong,ou=People,dc=example,dc=com", gen.newChangeNumber(),
         user1entryUUID, baseUUID, false, null, "uid=reallynewrdn");
     updateMonitorCount(baseDn, resolvedMonitorAttr);
+    AlertCount = DummyAlertHandler.getAlertCount();
     broker.publish(modDnMsg);
 
     resultEntry = getEntry(
@@ -862,6 +909,12 @@
     assertNotNull(resultEntry,
       "The modify dn was not or badly replayed");
     assertEquals(getMonitorDelta(), 1);
+    
+    // Check that there was no administrative alert generated
+    // because the conflict has been automatically resolved.
+    assertEquals(DummyAlertHandler.getAlertCount(), AlertCount,
+        "An alert was incorrectly generated when resolving conflicts");
+
 
     /*
      * Check that conflicting entries are renamed when a
@@ -888,6 +941,7 @@
                                user1entrysecondUUID, baseUUID, false,
                                baseDn.toString(), "uid=reallynewrdn");
     updateMonitorCount(baseDn, unresolvedMonitorAttr);
+    AlertCount = DummyAlertHandler.getAlertCount();
     broker.publish(modDnMsg);
 
    // check that the second entry has been renamed
@@ -897,6 +951,12 @@
     assertNotNull(resultEntry, "The modifyDN was not or incorrectly replayed");
     assertEquals(getMonitorDelta(), 1);
     assertConflictAttribute(resultEntry);
+    
+    // Check that there was no administrative alert generated
+    // because the conflict has been automatically resolved.
+    assertEquals(DummyAlertHandler.getAlertCount(), AlertCount+1,
+        "An alert was not generated when resolving conflicts");
+
 
     // delete the entries to clean the database
     delMsg =
@@ -1003,6 +1063,7 @@
 
     // - publish msg
     updateMonitorCount(baseDn, resolvedMonitorAttr);
+    AlertCount = DummyAlertHandler.getAlertCount();
     broker.publish(addMsg);
 
     // - check that the Dn has been changed to baseDn2
@@ -1018,6 +1079,12 @@
     entryList.add(resultEntry.getDN());
     assertEquals(getMonitorDelta(), 1);
     
+    // Check that there was no administrative alert generated
+    // because the conflict has been automatically resolved.
+    assertEquals(DummyAlertHandler.getAlertCount(), AlertCount,
+        "An alert was incorrectly generated when resolving conflicts");
+
+    
     //
     // Check that when a delete is conflicting with Add of some entries
     // below the deleted entries, the child entry that have been added
@@ -1037,6 +1104,7 @@
         "entryUUID = " + domain3uid + "+dc=domain3,ou=people,dc=example,dc=com");
  
     updateMonitorCount(baseDn, unresolvedMonitorAttr);
+    AlertCount = DummyAlertHandler.getAlertCount();
     
     // delete domain1
     delMsg = new DeleteMsg(domain1dn, gen.newChangeNumber(), domain1uid);
@@ -1061,6 +1129,12 @@
     // check that unresolved conflict count has been incremented
     assertEquals(getMonitorDelta(), 1);
     
+    // Check that an administrative alert was generated
+    // because the conflict has not been automatically resolved.
+    assertEquals(DummyAlertHandler.getAlertCount(), AlertCount+2,
+        "An alert was incorrectly generated when resolving conflicts");
+
+    
     // delete the resulting entries for the next test
     delEntry(conflictDomain2dn);
     delEntry(conflictDomain3dn);
@@ -1097,6 +1171,7 @@
         "uid=wrong, ou=people,dc=example,dc=com",
         "uid=newrdn");
     updateMonitorCount(baseDn, resolvedMonitorAttr);
+    AlertCount = DummyAlertHandler.getAlertCount();
     broker.publish(modDnMsg);
     // unfortunately it is difficult to check that the operation
     // did not do anything.
@@ -1104,6 +1179,12 @@
     // has correctly been incremented.
     assertEquals(getMonitorDelta(), 1);
     
+    // Check that there was no administrative alert generated
+    // because the conflict has been automatically resolved.
+    assertEquals(DummyAlertHandler.getAlertCount(), AlertCount,
+        "An alert was incorrectly generated when resolving conflicts");
+
+    
     broker.stop();
   }
 

--
Gitblit v1.10.0