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

neil_a_wilson
25.54.2007 5e161f9fca51fcdd00f16ff0d1ce14e0187d153d
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.
2 files modified
44 ■■■■■ changed files
opendj-sdk/opends/build.xml 13 ●●●●● patch | view | raw | blame | history
opendj-sdk/opends/tests/unit-tests-testng/src/server/org/opends/server/TestListener.java 31 ●●●●● patch | view | raw | blame | history
opendj-sdk/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}" />
opendj-sdk/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) {