From 39b6bdb24bae1de63de3b979369f2e5bd285ef6a Mon Sep 17 00:00:00 2001
From: davidely <davidely@localhost>
Date: Wed, 18 Apr 2007 15:43:28 +0000
Subject: [PATCH] This is a fix for race condition problems in the unit tests where operations left over from the previous test cause the following test to fail. For the affected tests, the solution was to wait for all previous operations to complete before starting the next test.
---
opends/tests/unit-tests-testng/src/server/org/opends/server/TestCaseUtils.java | 23 +++++++++++++++++++++++
1 files changed, 23 insertions(+), 0 deletions(-)
diff --git a/opends/tests/unit-tests-testng/src/server/org/opends/server/TestCaseUtils.java b/opends/tests/unit-tests-testng/src/server/org/opends/server/TestCaseUtils.java
index 9c39954..ca0f3d9 100644
--- a/opends/tests/unit-tests-testng/src/server/org/opends/server/TestCaseUtils.java
+++ b/opends/tests/unit-tests-testng/src/server/org/opends/server/TestCaseUtils.java
@@ -79,6 +79,7 @@
import static org.opends.server.util.ServerConstants.*;
import static org.opends.server.util.StaticUtils.*;
import org.opends.server.tasks.TaskUtils;
+import org.opends.server.api.WorkQueue;
/**
* This class defines some utility functions which can be used by test
@@ -316,6 +317,28 @@
}
/**
+ * Bring the server to a quiescent state. This includes waiting for all
+ * operations to complete. This can be used in a @BeforeMethod setup method
+ * to make sure that the server has finished processing all operations
+ * from previous tests.
+ */
+ public static void quiesceServer()
+ {
+ waitForOpsToComplete();
+ }
+
+ /**
+ * This can be made public if quiesceServer becomes too heavy-weight in
+ * some circumstance.
+ */
+ private static void waitForOpsToComplete()
+ {
+ WorkQueue workQueue = DirectoryServer.getWorkQueue();
+ final long NO_TIMEOUT = -1;
+ workQueue.waitUntilIdle(NO_TIMEOUT);
+ }
+
+ /**
* Binds to the given socket port on the local host.
* @return the bounded Server socket.
*
--
Gitblit v1.10.0