From c6b6a243346d668724252649f39cae3419294cb9 Mon Sep 17 00:00:00 2001
From: neil_a_wilson <neil_a_wilson@localhost>
Date: Tue, 07 Nov 2006 22:00:50 +0000
Subject: [PATCH] Update a set of test cases that reference the post-response invocation counter to wait until any previous operations have completed all processing (including post-response processing) before submitting a new operation.  This fixes a problem in which post-response processing from an earlier operation could interfere with the post-response invocation count check made in other test cases.

---
 opends/tests/unit-tests-testng/src/server/org/opends/server/core/SearchOperationTestCase.java  |   14 ++++++++++++++
 opends/tests/unit-tests-testng/src/server/org/opends/server/core/TestModifyDNOperation.java    |   14 ++++++++++++++
 opends/tests/unit-tests-testng/src/server/org/opends/server/core/CompareOperationTestCase.java |    7 +++++++
 3 files changed, 35 insertions(+), 0 deletions(-)

diff --git a/opends/tests/unit-tests-testng/src/server/org/opends/server/core/CompareOperationTestCase.java b/opends/tests/unit-tests-testng/src/server/org/opends/server/core/CompareOperationTestCase.java
index 5dd6315..a6f1979 100644
--- a/opends/tests/unit-tests-testng/src/server/org/opends/server/core/CompareOperationTestCase.java
+++ b/opends/tests/unit-tests-testng/src/server/org/opends/server/core/CompareOperationTestCase.java
@@ -598,6 +598,13 @@
   @Test(groups = "slow")
   public void testCompareWriteLock() throws Exception
   {
+    // Since we are going to be watching the post-response count, we need to
+    // wait for the server to become idle before kicking off the next request to
+    // ensure that any remaining post-response processing from the previous
+    // operation has completed.
+    assertTrue(DirectoryServer.getWorkQueue().waitUntilIdle(10000));
+
+
     // We need the operation to be run in a separate thread because we are going
     // to write lock the entry in the test case thread and check that the
     // compare operation does not proceed.
diff --git a/opends/tests/unit-tests-testng/src/server/org/opends/server/core/SearchOperationTestCase.java b/opends/tests/unit-tests-testng/src/server/org/opends/server/core/SearchOperationTestCase.java
index ed992d2..0f7e260 100644
--- a/opends/tests/unit-tests-testng/src/server/org/opends/server/core/SearchOperationTestCase.java
+++ b/opends/tests/unit-tests-testng/src/server/org/opends/server/core/SearchOperationTestCase.java
@@ -236,6 +236,13 @@
        ArrayList<LDAPControl> controls)
        throws IOException, LDAPException, ASN1Exception, InterruptedException
   {
+    // Since we are going to be watching the post-response count, we need to
+    // wait for the server to become idle before kicking off the next request to
+    // ensure that any remaining post-response processing from the previous
+    // operation has completed.
+    assertTrue(DirectoryServer.getWorkQueue().waitUntilIdle(10000));
+
+
     // Establish a connection to the server.
     Socket s = new Socket("127.0.0.1", (int) TestCaseUtils.getServerLdapPort());
     try
@@ -287,6 +294,13 @@
   private void bindAsManager(ASN1Writer w, ASN1Reader r)
        throws IOException, LDAPException, ASN1Exception, InterruptedException
   {
+    // Since we are going to be watching the post-response count, we need to
+    // wait for the server to become idle before kicking off the next request to
+    // ensure that any remaining post-response processing from the previous
+    // operation has completed.
+    assertTrue(DirectoryServer.getWorkQueue().waitUntilIdle(10000));
+
+
     InvocationCounterPlugin.resetAllCounters();
     BindRequestProtocolOp bindRequest =
          new BindRequestProtocolOp(
diff --git a/opends/tests/unit-tests-testng/src/server/org/opends/server/core/TestModifyDNOperation.java b/opends/tests/unit-tests-testng/src/server/org/opends/server/core/TestModifyDNOperation.java
index 3f57605..48b9106 100644
--- a/opends/tests/unit-tests-testng/src/server/org/opends/server/core/TestModifyDNOperation.java
+++ b/opends/tests/unit-tests-testng/src/server/org/opends/server/core/TestModifyDNOperation.java
@@ -1095,6 +1095,13 @@
   @Test
   public void testShortCircuitModify() throws Exception
   {
+    // Since we are going to be watching the post-response count, we need to
+    // wait for the server to become idle before kicking off the next request to
+    // ensure that any remaining post-response processing from the previous
+    // operation has completed.
+    assertTrue(DirectoryServer.getWorkQueue().waitUntilIdle(10000));
+
+
     // Establish a connection to the server.
     Socket s = new Socket("127.0.0.1", (int) TestCaseUtils.getServerLdapPort());
 
@@ -1128,6 +1135,13 @@
   @Test(groups = "slow")
   public void testWriteLockModify() throws Exception
   {
+    // Since we are going to be watching the post-response count, we need to
+    // wait for the server to become idle before kicking off the next request to
+    // ensure that any remaining post-response processing from the previous
+    // operation has completed.
+    assertTrue(DirectoryServer.getWorkQueue().waitUntilIdle(10000));
+
+
     // We need the operation to be run in a separate thread because we are going
     // to write lock the entry in the test case thread and check that the
     // modify DN operation does not proceed.

--
Gitblit v1.10.0