From 6c7fa214b88ce9ad2d0ab03029ee38a8ab0e22f8 Mon Sep 17 00:00:00 2001
From: gbellato <gbellato@localhost>
Date: Tue, 27 Oct 2009 11:31:26 +0000
Subject: [PATCH] Fix some random failure in ReplicationServerTest where the tests are opening  repetitively broker sessions to the Replication Server which can cause some normal failure.

---
 opends/tests/unit-tests-testng/src/server/org/opends/server/replication/ReplicationTestCase.java          |    5 ++++-
 opends/tests/unit-tests-testng/src/server/org/opends/server/replication/plugin/StateMachineTest.java      |    1 +
 opends/tests/unit-tests-testng/src/server/org/opends/server/replication/server/ReplicationServerTest.java |    6 ++----
 3 files changed, 7 insertions(+), 5 deletions(-)

diff --git a/opends/tests/unit-tests-testng/src/server/org/opends/server/replication/ReplicationTestCase.java b/opends/tests/unit-tests-testng/src/server/org/opends/server/replication/ReplicationTestCase.java
index 64eabd1..9e1aae1 100644
--- a/opends/tests/unit-tests-testng/src/server/org/opends/server/replication/ReplicationTestCase.java
+++ b/opends/tests/unit-tests-testng/src/server/org/opends/server/replication/ReplicationTestCase.java
@@ -372,6 +372,7 @@
       try
       {
         Thread.sleep(1000);
+        rb.start();
       } catch (InterruptedException ex)
       {
         fail("Error sleeping " + stackTraceToSingleLineString(ex));
@@ -382,7 +383,7 @@
       {
         // Timeout reached, end with error
         fail("checkConnection: DS " + rb.getServerId() + " is not connected to "
-          + "the RS port " + rsPort + " after " + secTimeout + " seconds.");
+           + "the RS port " + rsPort + " after " + secTimeout + " seconds.");
       }
     }
   }
@@ -416,6 +417,7 @@
     ArrayList<String> servers = new ArrayList<String>(1);
     servers.add("localhost:" + port);
     broker.start(servers);
+    checkConnection(30, broker, port);
     if (timeout != 0)
       broker.setSoTimeout(timeout);
 
@@ -455,6 +457,7 @@
     ArrayList<String> servers = new ArrayList<String>(1);
     servers.add("localhost:" + port);
     broker.start(servers);
+    checkConnection(30, broker, port);
     if (timeout != 0)
       broker.setSoTimeout(timeout);
     if (emptyOldChanges)
diff --git a/opends/tests/unit-tests-testng/src/server/org/opends/server/replication/plugin/StateMachineTest.java b/opends/tests/unit-tests-testng/src/server/org/opends/server/replication/plugin/StateMachineTest.java
index 9a6681d..183d786 100644
--- a/opends/tests/unit-tests-testng/src/server/org/opends/server/replication/plugin/StateMachineTest.java
+++ b/opends/tests/unit-tests-testng/src/server/org/opends/server/replication/plugin/StateMachineTest.java
@@ -328,6 +328,7 @@
     ArrayList<String> servers = new ArrayList<String>(1);
     servers.add("localhost:" + rs1Port);
     broker.start(servers);
+    checkConnection(30, broker, rs1Port);
 
     return broker;
   }
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 0620f0a..a24799f 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
@@ -248,10 +248,10 @@
        */
       server1 = openReplicationSession(
           DN.decode(TEST_ROOT_DN_STRING),  1, 100, replicationServerPort,
-          1000, true);
+          1000, false);
       server2 = openReplicationSession(
           DN.decode(TEST_ROOT_DN_STRING),  2, 100, replicationServerPort,
-          1000, true);
+          1000, false);
 
       assertTrue(server1.isConnected());
       assertTrue(server2.isConnected());
@@ -419,8 +419,6 @@
         openReplicationSession(DN.decode(TEST_ROOT_DN_STRING),  3,
                              100, replicationServerPort, 5000, state);
 
-      assertTrue(broker.isConnected(), "Broker could not connect to RS");
-
       ReplicationMsg msg2 = broker.receive();
       broker.updateWindowAfterReplay();
       if (!(msg2 instanceof DeleteMsg))

--
Gitblit v1.10.0