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

Nicolas Capponi
02.31.2014 c0c061c7aa37545e306a84e588685ce61e81d49f
OPENDJ-1611 Fix failing test in ReplicationServerTest

Modify ReplicationServerTest.replicationServerTest() method to
stop brokers only at end of the test.
1 files modified
66 ■■■■■ changed files
opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/replication/server/ReplicationServerTest.java 66 ●●●●● patch | view | raw | blame | history
opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/replication/server/ReplicationServerTest.java
@@ -152,13 +152,20 @@
  @Test(enabled = true)
  public void replicationServerTest() throws Exception
  {
    changelogBasic();
    ReplicationBroker[] brokers1And2 = null;
    try {
      brokers1And2 = changelogBasic();
    newClientLateServer1();
    newClient();
    newClientWithFirstChanges();
    newClientWithChangefromServer1();
    newClientWithChangefromServer2();
    newClientWithUnknownChanges();
    }
    finally
    {
      stop(brokers1And2);
    }
    stopChangelog();
  }
@@ -173,12 +180,28 @@
  @Test(enabled=false)
  public void replicationServerTestLoop() throws Exception
  {
    changelogBasic();
    ReplicationBroker[] brokers1And2 = null;
    try
    {
      brokers1And2 = changelogBasic();
    while (true)
    {
      newClient();
    }
  }
    finally
    {
      stop(brokers1And2);
    }
  }
  /** Create two brokers: open for each a sender session and a receiver session to the replicationServer. */
  private ReplicationBroker[] createReplicationBrokers1And2() throws Exception {
    return new ReplicationBroker[] {
       openReplicationSession(TEST_ROOT_DN, 1, 100, replicationServerPort, 1000),
       openReplicationSession(TEST_ROOT_DN, 2, 100, replicationServerPort, 1000)
    };
  }
  @Override
  protected ReplicationBroker openReplicationSession(final DN baseDN,
@@ -190,26 +213,22 @@
  }
  /**
   * Basic test of the replicationServer code :
   *  Connect 2 clients to the replicationServer and exchange messages
   *  between the clients.
   * Basic test of the replicationServer code : Connect 2 clients to the
   * replicationServer and exchange messages between the clients. Note : Other
   * tests in this file depends on this test and may need to change if this test
   * is modified.
   *
   * Note : Other tests in this file depends on this test and may need to
   *        change if this test is modified.
   * @return the two brokers created to simulate 2 DS sending and receiving
   *         messages. They are returned to allow other tests to close the
   *         brokers themselves.
   */
  private void changelogBasic() throws Exception
  private ReplicationBroker[] changelogBasic() throws Exception
  {
    clearChangelogDB(replicationServer);
    debugInfo("Starting changelogBasic");
    ReplicationBroker server1 = null;
    ReplicationBroker server2 = null;
    try {
      /*
       * Open a sender session and a receiver session to the replicationServer
       */
      server1 = openReplicationSession(TEST_ROOT_DN, 1, 100, replicationServerPort, 1000);
      server2 = openReplicationSession(TEST_ROOT_DN, 2, 100, replicationServerPort, 1000);
    ReplicationBroker[] brokers1And2 = createReplicationBrokers1And2();
    ReplicationBroker server1 = brokers1And2[0];
    ReplicationBroker server2 = brokers1And2[1];
      /*
       * Create CSNs for the messages sent from server 1 with current time
@@ -243,11 +262,7 @@
      sendAndReceiveDeleteMsg(server2, server1, TEST_ROOT_DN, secondCSNServer2, "uid");
      debugInfo("Ending changelogBasic");
    }
    finally
    {
      stop(server1, server2);
    }
    return new ReplicationBroker[] { server1, server2 };
  }
  private void sendAndReceiveDeleteMsg(ReplicationBroker sender, ReplicationBroker receiver,
@@ -436,15 +451,22 @@
   */
  private void stopChangelog() throws Exception
  {
    ReplicationBroker[] brokers1And2 = null;
    try {
    debugInfo("Starting stopChangelog");
    shutdown();
    configure();
      brokers1And2 = createReplicationBrokers1And2();
    newClient();
    newClientWithFirstChanges();
    newClientWithChangefromServer1();
    newClientWithChangefromServer2();
    debugInfo("Ending stopChangelog");
  }
    finally {
      stop(brokers1And2);
    }
  }
  /**
   * Stress test from client using the ReplicationBroker API