From 73dd9bc58413442f19cdff6a450b1a1ae167c270 Mon Sep 17 00:00:00 2001
From: neil_a_wilson <neil_a_wilson@localhost>
Date: Tue, 28 Aug 2007 21:43:46 +0000
Subject: [PATCH] Update the TestCaseUtils.clearJEBackend() method to use a different approach. Instead of closing the environment, deleting the files, and re-opening the environment, we are keeping the environment open and just truncating the databases. This dramatically reduces the amount of memory required to run the unit tests, apparently as a result of a memory leak in the Berkeley DB JE when the environment is repeatedly opened and closed.
---
opends/tests/unit-tests-testng/src/server/org/opends/server/TestCaseUtils.java | 31 +++++++------------------------
1 files changed, 7 insertions(+), 24 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 2e48a53..53d7357 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
@@ -48,6 +48,8 @@
import org.opends.server.backends.MemoryBackend;
import org.opends.server.backends.jeb.BackendImpl;
+import org.opends.server.backends.jeb.EntryContainer;
+import org.opends.server.backends.jeb.RootContainer;
import org.opends.server.config.ConfigException;
import org.opends.server.core.AddOperation;
import org.opends.server.core.DirectoryServer;
@@ -469,32 +471,13 @@
throws Exception
{
BackendImpl backend = (BackendImpl)DirectoryServer.getBackend(beID);
-
- TaskUtils.disableBackend(beID);
-
- try
+ RootContainer rootContainer = backend.getRootContainer();
+ for (EntryContainer ec : rootContainer.getEntryContainers())
{
- String lockFile = LockFileManager.getBackendLockFileName(backend);
- StringBuilder failureReason = new StringBuilder();
-
- if (!LockFileManager.acquireExclusiveLock(lockFile, failureReason))
- {
- throw new RuntimeException(failureReason.toString());
- }
-
- try
- {
- backend.clearBackend();
- }
- finally
- {
- LockFileManager.releaseLock(lockFile, failureReason);
- }
+ ec.clear();
+ assertEquals(ec.getHighestEntryID().longValue(), 0L);
}
- finally
- {
- TaskUtils.enableBackend(beID);
- }
+ rootContainer.resetNextEntryID();
if (createBaseEntry)
{
--
Gitblit v1.10.0