From 7217cf9a5eb4ca210efd78c461b3004246e6c71e Mon Sep 17 00:00:00 2001
From: neil_a_wilson <neil_a_wilson@localhost>
Date: Sun, 25 Mar 2007 20:54:58 +0000
Subject: [PATCH] Update the test suite to provide a mechanism to temporarily pause the unit tests if a test failure occurs. This will make it possible to examine the server more closely in the state that caused the failure. Before pausing the tests, the test suite will create a watchdog file, and when that file is removed, the server will resume running the test cases.
---
opends/build.xml | 13 +++++++++++++
opends/tests/unit-tests-testng/src/server/org/opends/server/TestListener.java | 31 +++++++++++++++++++++++++++++++
2 files changed, 44 insertions(+), 0 deletions(-)
diff --git a/opends/build.xml b/opends/build.xml
index e5669a3..e37efaa 100644
--- a/opends/build.xml
+++ b/opends/build.xml
@@ -1082,6 +1082,10 @@
<echo message=" -Dorg.opends.test.suppressOutput=false"/>
<echo message=" writes the unit test output to the screen"/>
<echo message=""/>
+ <echo message=" -Dorg.opends.test.pauseOnFailure=true"/>
+ <echo message=" pauses the test suite whenever a failure occurs allowing you to inspect"/>
+ <echo message=" the server more closely in the failure state"/>
+ <echo message=""/>
<echo message=" -Dtest.failed=true"/>
<echo message=" runs only the tests that failed last time"/>
<echo message=""/>
@@ -1151,6 +1155,14 @@
</not>
</condition>
+ <!-- This sets org.opends.test.pauseOnFailure if and only if it's not
+ already set. -->
+ <condition property="org.opends.test.pauseOnFailure" value="false">
+ <not>
+ <isset property="org.opends.test.pauseOnFailure" />
+ </not>
+ </condition>
+
<!-- This sets org.opends.test.debug.target if and only if its's not
alreadly set. -->
<condition property="org.opends.test.debug.target"
@@ -1198,6 +1210,7 @@
<jvmarg value="-Dorg.opends.server.BuildRoot=${basedir}" />
<jvmarg value="-Dorg.opends.server.RunningUnitTests=true" />
<jvmarg value="-Dorg.opends.test.suppressOutput=${org.opends.test.suppressOutput}" />
+ <jvmarg value="-Dorg.opends.test.pauseOnFailure=${org.opends.test.pauseOnFailure}" />
<jvmarg value="-Dorg.opends.test.debug.target=${org.opends.test.debug.target}" />
<jvmarg value="-Xms${MEM}" />
<jvmarg value="-Xmx${MEM}" />
diff --git a/opends/tests/unit-tests-testng/src/server/org/opends/server/TestListener.java b/opends/tests/unit-tests-testng/src/server/org/opends/server/TestListener.java
index c545422..387dbf5 100644
--- a/opends/tests/unit-tests-testng/src/server/org/opends/server/TestListener.java
+++ b/opends/tests/unit-tests-testng/src/server/org/opends/server/TestListener.java
@@ -274,6 +274,37 @@
originalSystemErr.print(DIVIDER_LINE + EOL + EOL);
_bufferedTestFailures.append(failureInfo);
+
+ String pauseStr = System.getProperty("org.opends.test.pauseOnFailure");
+ if ((pauseStr != null) && pauseStr.equalsIgnoreCase("true"))
+ {
+ File tempFile = null;
+ try
+ {
+ tempFile = File.createTempFile("testfailure", "watchdog");
+ tempFile.deleteOnExit();
+ originalSystemErr.println("**** Pausing test execution until file " +
+ tempFile.getCanonicalPath() + " is removed.");
+ }
+ catch (Exception e)
+ {
+ originalSystemErr.println("**** ERROR: Could not create a watchdog " +
+ "file. Pausing test execution indefinitely.");
+ originalSystemErr.println("**** You will have to manually kill the " +
+ "JVM when you're done investigating the problem.");
+ }
+
+ while ((tempFile == null) || tempFile.exists())
+ {
+ try
+ {
+ Thread.sleep(100);
+ } catch (Exception e) {}
+ }
+
+ originalSystemErr.println("**** Watchdog file removed. Resuming test " +
+ "case execution.");
+ }
}
private String getTestngLessStack(Throwable t) {
--
Gitblit v1.10.0