From b2ec3b8614b48c1c52cce553b2e4c7d3db0d60e7 Mon Sep 17 00:00:00 2001
From: Ludovic Poitou <ludovic.poitou@forgerock.com>
Date: Tue, 28 Jun 2011 21:21:01 +0000
Subject: [PATCH] Small incremental improvements of ReplicationServerTest to narrow and reduce scope of failure. Tests are passing 100% of the time on my machine. Not passing almost 100% of the time on builds.forgerock.org (Jenkins-CI). Bare metal vs VMs ?

---
 opends/tests/unit-tests-testng/src/server/org/opends/server/replication/server/ReplicationServerTest.java |   31 ++++++++++++-------------------
 1 files changed, 12 insertions(+), 19 deletions(-)

diff --git a/opends/tests/unit-tests-testng/src/server/org/opends/server/replication/server/ReplicationServerTest.java b/opends/tests/unit-tests-testng/src/server/org/opends/server/replication/server/ReplicationServerTest.java
index 0226b58..ce82b3e 100644
--- a/opends/tests/unit-tests-testng/src/server/org/opends/server/replication/server/ReplicationServerTest.java
+++ b/opends/tests/unit-tests-testng/src/server/org/opends/server/replication/server/ReplicationServerTest.java
@@ -198,8 +198,7 @@
     newClientWithFirstChanges();
     newClientWithChangefromServer1();
     newClientWithChangefromServer2();
-    newClientWithUnknownChanges();
-    changelogChaining();
+    newClientWithUnknownChanges();    
     stopChangelog();
     exportBackend();
     backupRestore();
@@ -565,8 +564,8 @@
 
     ReplicationBroker server = null;
     BrokerReader reader = null;
-    int TOTAL_MSG = 500;     // number of messages to send during the test
-    int CLIENT_THREADS = 4;   // number of threads that will try to read
+    int TOTAL_MSG = 1000;     // number of messages to send during the test
+    int CLIENT_THREADS = 2;   // number of threads that will try to read
                               // the messages
     ChangeNumberGenerator gen =
       new ChangeNumberGenerator(5 , (long) 0);
@@ -645,9 +644,6 @@
 
       assertTrue(reader.errDetails==null,
           reader.exc + " " + reader.errDetails);
-
-      replicationServer.clearDb();
-      TestCaseUtils.initializeTestBackend(true);
     }
   }
 
@@ -707,7 +703,6 @@
         reader[i].start();
       }
       debugInfo("multipleWriterMultipleReader produces and readers started");
-      //Thread.sleep(2000);
     }
     finally
     {
@@ -737,9 +732,6 @@
       }
       debugInfo("multipleWriterMultipleReader brokers stopped");
 
-      replicationServer.clearDb();
-      TestCaseUtils.initializeTestBackend(true);
-
       for (int i = 0; i< THREADS; i++)
       {
         if (reader[i] != null)
@@ -772,9 +764,13 @@
    * - Check that client 2 receives the changes published by client 1
    *
    */
-  private void changelogChaining() throws Exception
+  @Test(enabled=true, dependsOnMethods = { "searchBackend"})
+  public void changelogChaining() throws Exception
   {
     debugInfo("Starting changelogChaining");
+    replicationServer.clearDb();
+    TestCaseUtils.initializeTestBackend(true);
+    
     for (int itest = 0; itest <2; itest++)
     {
       ReplicationBroker broker2 = null;
@@ -889,7 +885,7 @@
           servers.add("localhost:"+changelogPorts[0]);
           ReplServerFakeConfiguration conf =
             new ReplServerFakeConfiguration(changelogPorts[1], null, 0,
-                                           changelogIds[1], 0, 0, null);
+                                           changelogIds[1], 0, 100, null);
           changelogs[1] = new ReplicationServer(conf);
 
           // Connect broker 2 to changelog2
@@ -1899,13 +1895,10 @@
            new ReplServerFakeConfiguration(changelogPorts[0], "changelogDb0", 0,
                                           changelogIds[0], 0, 100, servers);
          changelogs[0].applyConfigurationChange(conf) ;
-         // Sleep a while to be sure disconnection occurs
-         sleep(1000);
 
-         // We expect the receive to end because of a timeout : the link between RS1 & RS2
-         // should be distroyed by the new configuration
-
-         // Send 1 update and check that RS[1] does not receive the message after the timeout
+         // The link between RS[0] & RS[1] should be destroyed by the new configuration.
+         // So we expect a timeout exception when calling receive on RS[1].
+         // Send an update and check that RS[1] does not receive the message after the timeout
          try
          {
            // - Del

--
Gitblit v1.10.0