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

gbellato
10.57.2007 37d94bc7fc4991912f2c0d87730ac8c3c26ab00d
This fixes 2724 : and enable/fix some more replication tests.

If the Replication Server is stopped while the ServerHandler writer threads are blocked waiting for some window credit they are blocked and don't stop
immediately.

This issue is minimal for real life but can cause unit test failure because replication Servers are stopped and started a number of times during the tests.

This commit also enabled some more replication tests and change them to make the
order in which they are run more predictible.
5 files modified
111 ■■■■■ changed files
opends/src/server/org/opends/server/replication/server/ServerHandler.java 12 ●●●● patch | view | raw | blame | history
opends/tests/unit-tests-testng/src/server/org/opends/server/replication/GenerationIdTest.java 9 ●●●● patch | view | raw | blame | history
opends/tests/unit-tests-testng/src/server/org/opends/server/replication/InitOnLineTest.java 2 ●●● patch | view | raw | blame | history
opends/tests/unit-tests-testng/src/server/org/opends/server/replication/UpdateOperationTest.java 2 ●●● patch | view | raw | blame | history
opends/tests/unit-tests-testng/src/server/org/opends/server/replication/server/ReplicationServerTest.java 86 ●●●● patch | view | raw | blame | history
opends/src/server/org/opends/server/replication/server/ServerHandler.java
@@ -53,7 +53,6 @@
package org.opends.server.replication.server;
import org.opends.messages.*;
import org.opends.messages.MessageBuilder;
import static org.opends.server.loggers.ErrorLogger.logError;
import static org.opends.server.loggers.debug.DebugLogger.*;
@@ -73,6 +72,7 @@
import java.util.SortedSet;
import java.util.TreeSet;
import java.util.concurrent.Semaphore;
import java.util.concurrent.TimeUnit;
import org.opends.server.admin.std.server.MonitorProviderCfg;
import org.opends.server.api.MonitorProvider;
@@ -167,6 +167,11 @@
   */
  HeartbeatThread heartbeatThread = null;
  /**
   * Set when ServerHandler is stopping.
   */
  private boolean shutdown = false;
  private static final Map<ChangeNumber, ReplServerAckMessageList>
   changelogsWaitingAcks =
       new HashMap<ChangeNumber, ReplServerAckMessageList>();
@@ -1012,13 +1017,13 @@
    do {
      try
      {
        sendWindow.acquire();
        sendWindow.tryAcquire((long)500, TimeUnit.MILLISECONDS);
        interrupted = false;
      } catch (InterruptedException e)
      {
        // loop until not interrupted
      }
    } while (interrupted);
    } while ((interrupted) && (!shutdown));
    this.incrementOutCount();
    return msg;
  }
@@ -1504,6 +1509,7 @@
   */
  public void shutdown()
  {
    shutdown  = true;
    try
    {
      session.close();
opends/tests/unit-tests-testng/src/server/org/opends/server/replication/GenerationIdTest.java
@@ -1241,7 +1241,7 @@
   * at the moement when the replication is enabled.
   * @throws Exception
   */
  @Test(enabled=true)
  @Test(enabled=false)
  public void testServerStop() throws Exception
  {
    String testCase = "testServerStop";
@@ -1285,4 +1285,11 @@
      debugInfo("Successfully ending " + testCase);
    }
  }
  @Test(enabled=true)
  public void generationIdTest() throws Exception
  {
    testSingleRS();
    testMultiRS();
    testServerStop();
  }
}
opends/tests/unit-tests-testng/src/server/org/opends/server/replication/InitOnLineTest.java
@@ -1135,7 +1135,7 @@
    changelog1 = null;
  }
  
  @Test(enabled=false)
  @Test(enabled=true)
  public void initializeTargetExportMultiSS() throws Exception
  {
    try
opends/tests/unit-tests-testng/src/server/org/opends/server/replication/UpdateOperationTest.java
@@ -1253,7 +1253,7 @@
  /**
   * Tests done using directly the ReplicationBroker interface.
   */
  @Test(enabled=false, dataProvider="assured")
  @Test(enabled=true, dataProvider="assured")
  public void updateOperations(boolean assured) throws Exception
  {
    logError(Message.raw(
opends/tests/unit-tests-testng/src/server/org/opends/server/replication/server/ReplicationServerTest.java
@@ -83,10 +83,6 @@
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
import org.opends.messages.Category;
import org.opends.messages.Message;
import org.opends.messages.Severity;
import org.opends.server.loggers.ErrorLogger;
import org.opends.server.tools.LDAPModify;
import org.opends.server.tools.LDAPSearch;
@@ -132,7 +128,7 @@
    ReplServerFakeConfiguration conf =
      new ReplServerFakeConfiguration(replicationServerPort, null, 0, 1, 0, 0, null);
    replicationServer = new ReplicationServer(conf);
    replicationServer = new ReplicationServer(conf);;
  }
  private void debugInfo(String s)
@@ -145,6 +141,31 @@
  }
  /**
   * The tests in this class only works in a specific order.
   * This method is used to make sure that this order is always respected.
   * (Using testng dependency does not work)
   */
  @Test(enabled=true)
  public void replicationServerTest() throws Exception
  {
    replicationServer.clearDb();
    changelogBasic();
    multipleWriterMultipleReader();
    newClientLateServer1();
    newClient();
    newClientWithFirstChanges();
    newClientWithChangefromServer1();
    newClientWithChangefromServer2();
    newClientWithUnknownChanges();
    oneWriterMultipleReader();
    changelogChaining();
    exportBackend();
    backupRestore();
    stopChangelog();
    windowProbeTest();
  }
  /**
   * Basic test of the replicationServer code :
   *  Connect 2 clients to the replicationServer and exchange messages
   *  between the clients.
@@ -152,9 +173,9 @@
   * Note : Other tests in this file depends on this test and may need to
   *        change if this test is modified.
   */
  @Test(enabled=true)
  public void changelogBasic() throws Exception
  private void changelogBasic() throws Exception
  {
    replicationServer.clearDb();
    debugInfo("Starting changelogBasic");
    ReplicationBroker server1 = null;
    ReplicationBroker server2 = null;
@@ -273,8 +294,7 @@
   * Test that a new client see the change that was sent in the
   * previous test.
   */
  @Test(enabled=false, dependsOnMethods = { "changelogBasic" })
  public void newClient() throws Exception
  private void newClient() throws Exception
  {
    debugInfo("Starting newClient");
    ReplicationBroker broker = null;
@@ -346,8 +366,7 @@
   * Test that a client that has already seen the first change now see the
   * second change
   */
  @Test(enabled=true, dependsOnMethods = { "changelogBasic" })
  public void newClientWithFirstChanges() throws Exception
  private void newClientWithFirstChanges() throws Exception
  {
    debugInfo("Starting newClientWithFirstChanges");
    /*
@@ -366,8 +385,7 @@
   * Test with a client that has already seen a Change that the
   * ReplicationServer has not seen.
   */
  @Test(enabled=true, dependsOnMethods = { "changelogBasic" })
  public void newClientWithUnknownChanges() throws Exception
  private void newClientWithUnknownChanges() throws Exception
  {
    /*
     * Create a ServerState with wrongChangeNumberServer1
@@ -383,8 +401,7 @@
   * Test that a client that has already seen the first change from server 1
   * now see the first change from server 2
   */
  @Test(enabled=false, dependsOnMethods = { "changelogBasic" })
  public void newClientWithChangefromServer1() throws Exception
  private void newClientWithChangefromServer1() throws Exception
  {
    /*
     * Create a ServerState updated with the first change from server 1
@@ -399,8 +416,7 @@
   * Test that a client that has already seen the first chaneg from server 2
   * now see the first change from server 1
   */
  @Test(enabled=false, dependsOnMethods = { "changelogBasic" })
  public void newClientWithChangefromServer2() throws Exception
  private void newClientWithChangefromServer2() throws Exception
  {
    /*
     * Create a ServerState updated with the first change from server 1
@@ -415,8 +431,7 @@
   * Test that a client that has not seen the second change from server 1
   * now receive it.
   */
  @Test(enabled=true, dependsOnMethods = { "changelogBasic" })
  public void newClientLateServer1() throws Exception
  private void newClientLateServer1() throws Exception
  {
    /*
     * Create a ServerState updated with the first change from server 1
@@ -432,15 +447,14 @@
   * Test that newClient() and newClientWithFirstChange() still works
   * after stopping and restarting the replicationServer.
   */
  @Test(enabled=true, dependsOnMethods = { "changelogBasic" })
  public void stopChangelog() throws Exception
  private void stopChangelog() throws Exception
  {
    replicationServer.remove();
    configure();
    //newClient();
    newClient();
    newClientWithFirstChanges();
    newClientWithChangefromServer1();
    //newClientWithChangefromServer2();
    newClientWithChangefromServer2();
  }
  /**
@@ -453,8 +467,7 @@
   * This test i sconfigured by a relatively low stress
   * but can be changed using TOTAL_MSG and CLIENT_THREADS consts.
   */
  @Test(enabled=true, groups="slow")
  public void oneWriterMultipleReader() throws Exception
  private void oneWriterMultipleReader() throws Exception
  {
    ReplicationBroker server = null;
    int TOTAL_MSG = 1000;     // number of messages to send during the test
@@ -535,8 +548,7 @@
   * This test is sconfigured for a relatively low stress
   * but can be changed using TOTAL_MSG and THREADS consts.
   */
  @Test(enabled=true, groups="slow")
  public void multipleWriterMultipleReader() throws Exception
  private void multipleWriterMultipleReader() throws Exception
  {
    ReplicationBroker server = null;
    final int TOTAL_MSG = 1000;   // number of messages to send during the test
@@ -610,8 +622,7 @@
   * - Check that client 2 receives the changes published by client 1
   *
   */
  @Test(enabled=true)
  public void changelogChaining() throws Exception
  private void changelogChaining() throws Exception
  {
    for (int itest = 0; itest <2; itest++)
    {
@@ -800,8 +811,7 @@
   * Test that the Replication sends back correctly WindowsUpdate
   * when we send a WindowProbe.
   */
  @Test(enabled=true)
  public void windowProbeTest() throws Exception
  private void windowProbeTest() throws Exception
  {
    final int WINDOW = 10;
    /*
@@ -999,8 +1009,7 @@
  /*
   * Test backup and restore of the Replication server backend
   */
   @Test(enabled=true)
   public void backupRestore() throws Exception
   private void backupRestore() throws Exception
   {
     debugInfo("Starting backupRestore");
@@ -1023,8 +1032,7 @@
    * - Launch a full export
    * - Launch a partial export on one of the 2 domains
    */
    @Test(enabled=true)
    public void exportBackend() throws Exception
    private void exportBackend() throws Exception
    {
      debugInfo("Starting exportBackend");
@@ -1227,8 +1235,7 @@
    * Testing searches on the backend of the replication server.
    * @throws Exception
    */
   @Test(enabled=false)
   public void searchBackend() throws Exception
   private void searchBackend() throws Exception
   {
     debugInfo("Starting searchBackend");
@@ -1285,8 +1292,9 @@
     DN baseDN=DN.decode("dc=replicationChanges");
     //Test the group membership control causes search to be skipped.
     InternalSearchOperation internalSearch =
             new InternalSearchOperation(conn, conn.nextOperationID(),
                                         conn.nextMessageID(), requestControls,
             new InternalSearchOperation(
                 conn, InternalClientConnection.nextOperationID(),
                 InternalClientConnection.nextMessageID(), requestControls,
                                         baseDN,
                                         SearchScope.WHOLE_SUBTREE,
                                         DereferencePolicy.NEVER_DEREF_ALIASES,