diff --git a/runtime/criusupport/criusupport.cpp b/runtime/criusupport/criusupport.cpp index c393912a35f..5c667254112 100644 --- a/runtime/criusupport/criusupport.cpp +++ b/runtime/criusupport/criusupport.cpp @@ -656,13 +656,13 @@ Java_org_eclipse_openj9_criu_CRIUSupport_checkpointJVMImpl(JNIEnv *env, bool setupCRIU = true; PORT_ACCESS_FROM_VMC(currentThread); + Trc_CRIU_checkpointJVMImpl_Entry(currentThread); if (NULL == vm->checkpointState.criuJVMCheckpointExceptionClass) { setupCRIU = setupJNIFieldIDsAndCRIUAPI(env, ¤tExceptionClass, &systemReturnCode, &nlsMsgFormat); } vm->checkpointState.checkpointThread = currentThread; - Trc_CRIU_checkpointJVMImpl_Entry(currentThread); if (vmFuncs->isCheckpointAllowed(currentThread) && setupCRIU) { #if defined(LINUX) j9object_t cpDir = NULL; diff --git a/test/functional/cmdLineTests/criu/playlist.xml b/test/functional/cmdLineTests/criu/playlist.xml index 8eda2355acb..9f186d56749 100644 --- a/test/functional/cmdLineTests/criu/playlist.xml +++ b/test/functional/cmdLineTests/criu/playlist.xml @@ -65,6 +65,12 @@ -Xint -XX:+CRIURestoreNonPortableMode -Xjit:count=0 -XX:+CRIURestoreNonPortableMode + + + https://github.com/eclipse-openj9/openj9/issues/18468 + ppc64le.* + + $(JAVA_COMMAND) $(CMDLINETESTER_JVM_OPTIONS) -Xdump \ -DSCRIPPATH=$(TEST_RESROOT)$(D)criuScript.sh -DTEST_RESROOT=$(TEST_RESROOT) \ @@ -99,6 +105,12 @@ -Xgcpolicy:gencon -Xgcthreads64 -XX:CheckpointGCThreads=1 -Xgcpolicy:gencon -Xgcthreads1 + + + https://github.com/eclipse-openj9/openj9/issues/18468 + ppc64le.* + + TR_Options=$(Q)exclude={org/openj9/criu/TimeChangeTest.nanoTimeInt()J},dontInline={org/openj9/criu/TimeChangeTest.nanoTimeInt()J|org/openj9/criu/TimeChangeTest.nanoTimeJit()J},{org/openj9/criu/TimeChangeTest.nanoTimeJit()J}(count=1)$(Q) \ $(JAVA_COMMAND) $(CMDLINETESTER_JVM_OPTIONS) -Xdump \ @@ -128,6 +140,12 @@ -Xjit:count=0 -Xjit:vlog=vlog + + + https://github.com/eclipse-openj9/openj9/issues/18468 + ppc64le.* + + TR_Options=$(Q)disableSuffixLogs$(Q) \ $(JAVA_COMMAND) $(CMDLINETESTER_JVM_OPTIONS) -Xdump \ @@ -156,6 +174,12 @@ NoOptions + + + https://github.com/eclipse-openj9/openj9/issues/18468 + ppc64le.* + + if [ -x $(Q)$(TEST_JDK_BIN)$(D)jitserver$(Q) ]; \ then \ @@ -195,6 +219,12 @@ -Xjit:vlog=vlog -XX:+JVMPortableRestoreMode + + + https://github.com/eclipse-openj9/openj9/issues/18468 + ppc64le.* + + if [ -x $(Q)$(TEST_JDK_BIN)$(D)jitserver$(Q) ]; \ then \ @@ -234,6 +264,12 @@ -Xgcpolicy:optthruput -Xgcpolicy:optavgpause + + + https://github.com/eclipse-openj9/openj9/issues/18468 + ppc64le.* + + TR_Options=$(Q)exclude={org/openj9/criu/TimeChangeTest.nanoTimeInt()J},dontInline={org/openj9/criu/TimeChangeTest.nanoTimeInt()J|org/openj9/criu/TimeChangeTest.nanoTimeJit()J},{org/openj9/criu/TimeChangeTest.nanoTimeJit()J}(count=1)$(Q) \ $(JAVA_COMMAND) $(CMDLINETESTER_JVM_OPTIONS) -Xdump \ @@ -265,6 +301,12 @@ -Xgcpolicy:optthruput -Xgcpolicy:optavgpause + + + https://github.com/eclipse-openj9/openj9/issues/18468 + ppc64le.* + + TR_Options=$(Q)exclude={org/openj9/criu/TimeChangeTest.nanoTimeInt()J},dontInline={org/openj9/criu/TimeChangeTest.nanoTimeInt()J|org/openj9/criu/TimeChangeTest.nanoTimeJit()J},{org/openj9/criu/TimeChangeTest.nanoTimeJit()J}(count=1)$(Q) \ $(JAVA_COMMAND) $(CMDLINETESTER_JVM_OPTIONS) -Xdump \ @@ -296,6 +338,12 @@ -Xgcpolicy:optthruput -Xgcpolicy:optavgpause + + + https://github.com/eclipse-openj9/openj9/issues/18468 + ppc64le.* + + TR_Options=$(Q)exclude={org/openj9/criu/TimeChangeTest.nanoTimeInt()J},dontInline={org/openj9/criu/TimeChangeTest.nanoTimeInt()J|org/openj9/criu/TimeChangeTest.nanoTimeJit()J},{org/openj9/criu/TimeChangeTest.nanoTimeJit()J}(count=1)$(Q) \ $(JAVA_COMMAND) $(CMDLINETESTER_JVM_OPTIONS) -Xdump \ @@ -327,6 +375,12 @@ -Xgcpolicy:optthruput -Xgcpolicy:optavgpause + + + https://github.com/eclipse-openj9/openj9/issues/18468 + ppc64le.* + + TR_Options=$(Q)exclude={org/openj9/criu/TimeChangeTest.nanoTimeInt()J},dontInline={org/openj9/criu/TimeChangeTest.nanoTimeInt()J|org/openj9/criu/TimeChangeTest.nanoTimeJit()J},{org/openj9/criu/TimeChangeTest.nanoTimeJit()J}(count=1)$(Q) \ $(JAVA_COMMAND) $(CMDLINETESTER_JVM_OPTIONS) -Xdump \ @@ -357,6 +411,12 @@ -Xjit:count=0 -XX:+CRIURestoreNonPortableMode -XX:+JVMPortableRestoreMode + + + https://github.com/eclipse-openj9/openj9/issues/18468 + ppc64le.* + + $(JAVA_COMMAND) $(CMDLINETESTER_JVM_OPTIONS) -Xdump \ -DSCRIPPATH=$(TEST_RESROOT)$(D)criuScript.sh -DTEST_RESROOT=$(TEST_RESROOT) \ @@ -388,6 +448,12 @@ -Xint -XX:+CRIURestoreNonPortableMode -Xjit:count=0 -XX:+CRIURestoreNonPortableMode + + + https://github.com/eclipse-openj9/openj9/issues/18468 + ppc64le.* + + $(JAVA_COMMAND) $(CMDLINETESTER_JVM_OPTIONS) -Xdump \ -DSCRIPPATH=$(TEST_RESROOT)$(D)criuScript.sh -DTEST_RESROOT=$(TEST_RESROOT) \ @@ -417,6 +483,12 @@ -XX:+CRIURestoreNonPortableMode -Denable.j9internal.checkpoint.security.api.debug=true + + + https://github.com/eclipse-openj9/openj9/issues/18468 + ppc64le.* + + $(JAVA_COMMAND) $(CMDLINETESTER_JVM_OPTIONS) -Xdump \ -DSCRIPPATH=$(TEST_RESROOT)$(D)criuSecurityScript.sh -DTEST_RESROOT=$(TEST_RESROOT) \ @@ -443,6 +515,12 @@ -Denable.j9internal.checkpoint.security.api.debug=true + + + https://github.com/eclipse-openj9/openj9/issues/18468 + ppc64le.* + + $(JAVA_COMMAND) $(CMDLINETESTER_JVM_OPTIONS) -Xdump \ -DSCRIPPATH=$(TEST_RESROOT)$(D)criuRandomScript.sh -DTEST_RESROOT=$(TEST_RESROOT) \ diff --git a/test/functional/cmdLineTests/criu/src/org/openj9/criu/CRIUTestUtils.java b/test/functional/cmdLineTests/criu/src/org/openj9/criu/CRIUTestUtils.java index 8f04d605ce5..726a416f2d4 100644 --- a/test/functional/cmdLineTests/criu/src/org/openj9/criu/CRIUTestUtils.java +++ b/test/functional/cmdLineTests/criu/src/org/openj9/criu/CRIUTestUtils.java @@ -82,27 +82,25 @@ public static void checkPointJVM(CRIUSupport criu, Path path, boolean deleteDir) deleteCheckpointDirectory(path); } } else { - System.err.println("CRIU is not enabled"); + throw new RuntimeException("CRIU is not enabled"); } } public static CRIUSupport prepareCheckPointJVM(Path path) { - CRIUSupport criu = null; if (CRIUSupport.isCRIUSupportEnabled()) { deleteCheckpointDirectory(path); createCheckpointDirectory(path); - criu = new CRIUSupport(path); + return (new CRIUSupport(path)).setLeaveRunning(false).setShellJob(true).setFileLocks(true); } else { - System.err.println("CRIU is not enabled"); + throw new RuntimeException("CRIU is not enabled"); } - return criu; } public static void checkPointJVMNoSetup(CRIUSupport criu, Path path, boolean deleteDir) { if (criu != null) { try { showThreadCurrentTime("Performing CRIUSupport.checkpointJVM()"); - criu.setLeaveRunning(false).setShellJob(true).setFileLocks(true).checkpointJVM(); + criu.checkpointJVM(); } catch (SystemRestoreException e) { e.printStackTrace(); } @@ -110,7 +108,7 @@ public static void checkPointJVMNoSetup(CRIUSupport criu, Path path, boolean del deleteCheckpointDirectory(path); } } else { - System.err.println("CRIU is not enabled"); + throw new RuntimeException("CRIU is not enabled"); } } diff --git a/test/functional/cmdLineTests/criu/src/org/openj9/criu/JDK11UpTimeoutAdjustmentTest.java b/test/functional/cmdLineTests/criu/src/org/openj9/criu/JDK11UpTimeoutAdjustmentTest.java index 395af3ec6b2..3391131cb9f 100644 --- a/test/functional/cmdLineTests/criu/src/org/openj9/criu/JDK11UpTimeoutAdjustmentTest.java +++ b/test/functional/cmdLineTests/criu/src/org/openj9/criu/JDK11UpTimeoutAdjustmentTest.java @@ -30,7 +30,15 @@ public class JDK11UpTimeoutAdjustmentTest { private static final long NANOS_PER_MILLI = 1000_000L; private static final long NANOS_PER_SECOND = 1000_000_000L; - private static Unsafe unsafe = Unsafe.getUnsafe(); + private static final int nsTime500kns = 500000; + private static final long msTime2s = 2 * MILLIS_PER_SECOND; + private static final long nsTime2s = 2 * NANOS_PER_SECOND; + private static final long msTime5s = 5 * MILLIS_PER_SECOND; + private static final long nsTime5s = 5 * NANOS_PER_SECOND; + + private static final Object objWait = new Object(); + private static final TestResult testResult = new TestResult(true, 0); + private static final Unsafe unsafe = Unsafe.getUnsafe(); public static void main(String[] args) throws InterruptedException { if (args.length == 0) { @@ -41,44 +49,37 @@ public static void main(String[] args) throws InterruptedException { } } - private static Object objWait = new Object(); - // 5s time in ms - private static final long msWaitNotify5s = 5 * MILLIS_PER_SECOND; - final TestResult testResult = new TestResult(true, 0); - private void test(String testName) throws InterruptedException { CRIUSupport criu = CRIUTestUtils.prepareCheckPointJVM(CRIUTestUtils.imagePath); - if (criu == null) { - return; - } System.out.println("Start test name: " + testName); CRIUTestUtils.showThreadCurrentTime("Before starting " + testName); + Thread testThread; switch (testName) { case "testThreadPark": testThreadParkHelper("testThreadPark NO C/R"); - testThreadPark(); + testThread = testThreadPark(); break; case "testThreadSleep": - testThreadParkHelper("testThreadSleep NO C/R"); - testThreadSleep(); + testThreadSleepHelper("testThreadSleep NO C/R"); + testThread = testThreadSleep(); break; case "testObjectWaitNotify": - testObjectWaitNotify(); + testThread = testObjectWaitNotify(); break; case "testObjectWaitTimedNoNanoSecond": - testObjectWaitTimedHelper("testObjectWaitTimedNoNanoSecond NO C/R", msSleepTime10s, 0); - testObjectWaitTimedNoNanoSecond(); + testObjectWaitTimedHelper("testObjectWaitTimedNoNanoSecond NO C/R", msTime2s, 0); + testThread = testObjectWaitTimedNoNanoSecond(); break; case "testObjectWaitTimedWithNanoSecond": - testObjectWaitTimedHelper("testObjectWaitTimedWithNanoSecond NO C/R", msSleepTime10s, 500000); - testObjectWaitTimedWithNanoSecond(); + testObjectWaitTimedHelper("testObjectWaitTimedWithNanoSecond NO C/R", msTime2s, nsTime500kns); + testThread = testObjectWaitTimedWithNanoSecond(); break; default: throw new RuntimeException("Unrecognized test name: " + testName); } while (testResult.lockStatus == 0) { - Thread.yield(); + Thread.currentThread().yield(); } CRIUTestUtils.checkPointJVMNoSetup(criu, CRIUTestUtils.imagePath, false); @@ -90,24 +91,28 @@ private void test(String testName) throws InterruptedException { testThreadSleepHelper("testThreadSleep NO C/R"); break; case "testObjectWaitNotify": - Thread.sleep(msWaitNotify5s); - CRIUTestUtils.showThreadCurrentTime("Before objWait.notify()"); + Thread.sleep(msTime5s); synchronized (objWait) { objWait.notify(); } - Thread.sleep(5 * MILLIS_PER_SECOND); break; case "testObjectWaitTimedNoNanoSecond": - testObjectWaitTimedHelper("testObjectWaitTimedNoNanoSecond NO C/R", msSleepTime10s, 0); + testObjectWaitTimedHelper("testObjectWaitTimedNoNanoSecond NO C/R", msTime2s, 0); break; case "testObjectWaitTimedWithNanoSecond": - testObjectWaitTimedHelper("testObjectWaitTimedWithNanoSecond NO C/R", msSleepTime10s, 500000); + testObjectWaitTimedHelper("testObjectWaitTimedWithNanoSecond NO C/R", msTime2s, nsTime500kns); break; default: } + CRIUTestUtils.showThreadCurrentTime("After run test : " + testName); - // maximum test running time is 12s, sleep another 2s - Thread.sleep(2 * MILLIS_PER_SECOND); + if (testThread != null) { + try { + testThread.join(); + } catch (InterruptedException e) { + e.printStackTrace(); + } + } CRIUTestUtils.showThreadCurrentTime("End " + testName); } @@ -130,53 +135,41 @@ public static void showMessages(String logStr, long expectedTime, boolean isMill + "ns, CheckpointRestoreNanoTimeDelta: " + crDeltaNs + "ns (~" + (crDeltaNs / NANOS_PER_MILLI) + "ms)"); } - // 10s parkt time in ns - private static final long nsParkTime10s = 10 * NANOS_PER_SECOND; - private void testThreadParkHelper(String testName) { CRIUTestUtils.showThreadCurrentTime(testName + " before park()"); final long startNanoTime = System.nanoTime(); testResult.lockStatus = 1; - unsafe.park(false, nsParkTime10s); + unsafe.park(false, nsTime5s); final long endNanoTime = System.nanoTime(); - final long elapsedTime = endNanoTime - startNanoTime; - boolean pass = false; - if (elapsedTime >= nsParkTime10s) { - pass = true; - } CRIUTestUtils.showThreadCurrentTime(testName + " after park()"); - if (pass) { - showMessages("PASSED: expected park time ", nsParkTime10s, false, elapsedTime, startNanoTime, endNanoTime); + final long nsElapsedTime = endNanoTime - startNanoTime; + if (nsElapsedTime < nsTime5s) { + showMessages("FAILED: expected park time ", nsTime5s, false, nsElapsedTime, startNanoTime, endNanoTime); } else { - showMessages("FAILED: expected park time ", nsParkTime10s, false, elapsedTime, startNanoTime, endNanoTime); + showMessages("PASSED: expected park time ", nsTime5s, false, nsElapsedTime, startNanoTime, endNanoTime); } } - private void testThreadPark() { - new Thread(() -> testThreadParkHelper("testThreadPark")).start(); + private Thread testThreadPark() { + Thread parkThread = new Thread(() -> testThreadParkHelper("testThreadPark")); + parkThread.start(); + return parkThread; } - // 10s sleep time in ms - private static final long msSleepTime10s = 10 * MILLIS_PER_SECOND; - private void testThreadSleepHelper(String testName) { CRIUTestUtils.showThreadCurrentTime(testName + " before sleep()"); final long startNanoTime = System.nanoTime(); try { testResult.lockStatus = 1; - Thread.sleep(msSleepTime10s); - boolean pass = false; + Thread.sleep(msTime5s); final long endNanoTime = System.nanoTime(); - final long elapsedTime = endNanoTime - startNanoTime; - if (elapsedTime >= msSleepTime10s) { - pass = true; - } CRIUTestUtils.showThreadCurrentTime(testName + " after sleep()"); - if (pass) { - showMessages("PASSED: expected sleep time ", msSleepTime10s, true, elapsedTime, startNanoTime, + final long nsElapsedTime = endNanoTime - startNanoTime; + if (nsElapsedTime < nsTime5s) { + showMessages("FAILED: expected sleep time ", msTime5s, true, nsElapsedTime, startNanoTime, endNanoTime); } else { - showMessages("FAILED: expected sleep time ", msSleepTime10s, true, elapsedTime, startNanoTime, + showMessages("PASSED: expected sleep time ", msTime5s, true, nsElapsedTime, startNanoTime, endNanoTime); } } catch (InterruptedException ie) { @@ -184,32 +177,31 @@ private void testThreadSleepHelper(String testName) { } } - private void testThreadSleep() { - new Thread(() -> testThreadParkHelper("testThreadSleep")).start(); + private Thread testThreadSleep() { + Thread sleepThread = new Thread(() -> testThreadSleepHelper("testThreadSleep")); + sleepThread.start(); + return sleepThread; } - private void testObjectWaitNotify() { + private Thread testObjectWaitNotify() { Thread threadWait = new Thread(new Runnable() { public void run() { CRIUTestUtils.showThreadCurrentTime("testObjectWaitNotify() before wait()"); try { - final long startNanoTime = System.nanoTime(); + final long startNanoTime; synchronized (objWait) { + startNanoTime = System.nanoTime(); testResult.lockStatus = 1; objWait.wait(); } - boolean pass = false; final long endNanoTime = System.nanoTime(); - final long elapsedTime = endNanoTime - startNanoTime; - if (elapsedTime >= msWaitNotify5s) { - pass = true; - } CRIUTestUtils.showThreadCurrentTime("testObjectWaitNotify() after wait()"); - if (pass) { - showMessages("PASSED: expected wait time ", msWaitNotify5s, true, elapsedTime, startNanoTime, + final long msElapsedTime = (endNanoTime - startNanoTime) / NANOS_PER_MILLI; + if (msElapsedTime < msTime5s) { + showMessages("FAILED: expected wait time ", msTime5s, true, msElapsedTime, startNanoTime, endNanoTime); } else { - showMessages("FAILED: expected wait time ", msWaitNotify5s, true, elapsedTime, startNanoTime, + showMessages("PASSED: expected wait time ", msTime5s, true, msElapsedTime, startNanoTime, endNanoTime); } } catch (InterruptedException ie) { @@ -217,31 +209,29 @@ public void run() { } } }); - threadWait.setDaemon(true); threadWait.start(); + + return threadWait; } private void testObjectWaitTimedHelper(String testName, long ms, int ns) { CRIUTestUtils.showThreadCurrentTime(testName + " before wait(" + ms + ", " + ns + ")"); try { - final long startNanoTime = System.nanoTime(); + final long startNanoTime; synchronized (objWait) { + startNanoTime = System.nanoTime(); testResult.lockStatus = 1; objWait.wait(ms, ns); } - boolean pass = false; final long endNanoTime = System.nanoTime(); - final long elapsedTime = endNanoTime - startNanoTime; - final long nsSleepTime = ms * NANOS_PER_MILLI + ns; - if (elapsedTime >= nsSleepTime) { - pass = true; - } CRIUTestUtils.showThreadCurrentTime(testName + " after wait(" + ms + ", " + ns + ")"); - if (pass) { - showMessages("PASSED: expected wait time ", nsSleepTime, false, elapsedTime, startNanoTime, + final long nsElapsedTime = endNanoTime - startNanoTime; + final long nsSleepTime = ms * NANOS_PER_MILLI + ns; + if (nsElapsedTime < nsSleepTime) { + showMessages("FAILED: expected wait time ", nsSleepTime, false, nsElapsedTime, startNanoTime, endNanoTime); } else { - showMessages("FAILED: expected wait time ", nsSleepTime, false, elapsedTime, startNanoTime, + showMessages("PASSED: expected wait time ", nsSleepTime, false, nsElapsedTime, startNanoTime, endNanoTime); } } catch (InterruptedException ie) { @@ -249,11 +239,15 @@ private void testObjectWaitTimedHelper(String testName, long ms, int ns) { } } - private void testObjectWaitTimedNoNanoSecond() { - new Thread(() -> testObjectWaitTimedHelper("testObjectWaitTimedNoNanoSecond", msSleepTime10s, 0)).start(); + private Thread testObjectWaitTimedNoNanoSecond() { + Thread waitThread = new Thread(() -> testObjectWaitTimedHelper("testObjectWaitTimedNoNanoSecond", msTime5s, 0)); + waitThread.start(); + return waitThread; } - private void testObjectWaitTimedWithNanoSecond() { - new Thread(() -> testObjectWaitTimedHelper("testObjectWaitTimedWithNanoSecond", msSleepTime10s, 500000)).start(); + private Thread testObjectWaitTimedWithNanoSecond() { + Thread waitThread = new Thread(() -> testObjectWaitTimedHelper("testObjectWaitTimedWithNanoSecond", msTime5s, nsTime500kns)); + waitThread.start(); + return waitThread; } } diff --git a/test/functional/cmdLineTests/criu/src/org/openj9/criu/TestConcurrentMode.java b/test/functional/cmdLineTests/criu/src/org/openj9/criu/TestConcurrentMode.java index d83a1d93315..bb95ad0c4ed 100644 --- a/test/functional/cmdLineTests/criu/src/org/openj9/criu/TestConcurrentMode.java +++ b/test/functional/cmdLineTests/criu/src/org/openj9/criu/TestConcurrentMode.java @@ -75,10 +75,6 @@ public static void main(String[] args) { static void TestConcurrentModePreCheckpointHookThrowException() { CRIUTestUtils.showThreadCurrentTime("TestConcurrentModePreCheckpointHookThrowException() starts .."); CRIUSupport criu = CRIUTestUtils.prepareCheckPointJVM(CRIUTestUtils.imagePath); - if (criu == null) { - // "CRIU is not enabled" is to appear and cause the test failure. - return; - } criu.registerPreCheckpointHook(() -> { throw new RuntimeException("TestConcurrentModePreCheckpointHookThrowException() within preCheckpointHook"); }, CRIUSupport.HookMode.CONCURRENT_MODE, USER_HOOK_MODE_PRIORITY_LOW); @@ -92,10 +88,6 @@ static void TestConcurrentModePreCheckpointHookThrowException() { static void TestConcurrentModePreCheckpointHookThrowExceptionPriority() { CRIUTestUtils.showThreadCurrentTime("TestConcurrentModePreCheckpointHookThrowExceptionPriority() starts .."); CRIUSupport criu = CRIUTestUtils.prepareCheckPointJVM(CRIUTestUtils.imagePath); - if (criu == null) { - // "CRIU is not enabled" is to appear and cause the test failure. - return; - } criu.registerPreCheckpointHook( () -> CRIUTestUtils.showThreadCurrentTime("TestConcurrentModePreCheckpointHookThrowExceptionPriority() within preCheckpointHook"), CRIUSupport.HookMode.CONCURRENT_MODE, 100); @@ -109,10 +101,6 @@ static void TestConcurrentModePreCheckpointHookThrowExceptionPriority() { static void TestConcurrentModePreCheckpointHookRunOnce() { CRIUTestUtils.showThreadCurrentTime("TestConcurrentModePreCheckpointHookRunOnce() starts .."); CRIUSupport criu = CRIUTestUtils.prepareCheckPointJVM(CRIUTestUtils.imagePath); - if (criu == null) { - // "CRIU is not enabled" is to appear and cause the test failure. - return; - } criu.registerPreCheckpointHook( () -> CRIUTestUtils.showThreadCurrentTime("TestConcurrentModePreCheckpointHookRunOnce() within preCheckpointHook"), CRIUSupport.HookMode.CONCURRENT_MODE, USER_HOOK_MODE_PRIORITY_LOW); @@ -126,10 +114,6 @@ static void TestConcurrentModePreCheckpointHookRunOnce() { static void TestConcurrentModePreCheckpointHookPriorities() { CRIUTestUtils.showThreadCurrentTime("TestConcurrentModePreCheckpointHookPriorities() starts .."); CRIUSupport criu = CRIUTestUtils.prepareCheckPointJVM(CRIUTestUtils.imagePath); - if (criu == null) { - // "CRIU is not enabled" is to appear and cause the test failure. - return; - } final TestResult testResult = new TestResult(true, 0); criu.registerPreCheckpointHook(() -> { CRIUTestUtils.showThreadCurrentTime("The preCheckpointHook with lower priority in CONCURRENT_MODE"); @@ -190,10 +174,6 @@ static void TestConcurrentModePreCheckpointHookPriorities() { static void TestConcurrentModePostRestoreHookThrowException() { CRIUTestUtils.showThreadCurrentTime("TestConcurrentModePostRestoreHookThrowException() starts .."); CRIUSupport criu = CRIUTestUtils.prepareCheckPointJVM(CRIUTestUtils.imagePath); - if (criu == null) { - // "CRIU is not enabled" is to appear and cause the test failure. - return; - } criu.registerPostRestoreHook(() -> { throw new RuntimeException("TestConcurrentModePostRestoreHookThrowException() within postRestoreHook"); }, CRIUSupport.HookMode.CONCURRENT_MODE, 1); @@ -207,10 +187,6 @@ static void TestConcurrentModePostRestoreHookThrowException() { static void TestConcurrentModePostRestoreHookThrowExceptionPriority() { CRIUTestUtils.showThreadCurrentTime("TestConcurrentModePostRestoreHookThrowExceptionPriority() starts .."); CRIUSupport criu = CRIUTestUtils.prepareCheckPointJVM(CRIUTestUtils.imagePath); - if (criu == null) { - // "CRIU is not enabled" is to appear and cause the test failure. - return; - } criu.registerPostRestoreHook( () -> CRIUTestUtils.showThreadCurrentTime("TestConcurrentModePostRestoreHookRunOnce() within postRestoreHook"), CRIUSupport.HookMode.CONCURRENT_MODE, -1); @@ -224,10 +200,6 @@ static void TestConcurrentModePostRestoreHookThrowExceptionPriority() { static void TestConcurrentModePostRestoreHookRunOnce() { CRIUTestUtils.showThreadCurrentTime("TestConcurrentModePostRestoreHookRunOnce() starts .."); CRIUSupport criu = CRIUTestUtils.prepareCheckPointJVM(CRIUTestUtils.imagePath); - if (criu == null) { - // "CRIU is not enabled" is to appear and cause the test failure. - return; - } criu.registerPostRestoreHook( () -> CRIUTestUtils.showThreadCurrentTime("TestConcurrentModePostRestoreHookRunOnce() within postRestoreHook"), CRIUSupport.HookMode.CONCURRENT_MODE, 1); @@ -241,10 +213,6 @@ static void TestConcurrentModePostRestoreHookRunOnce() { static void TestConcurrentModePostRestoreHookPriorities() { CRIUTestUtils.showThreadCurrentTime("TestConcurrentModePostRestoreHookPriorities() starts .."); CRIUSupport criu = CRIUTestUtils.prepareCheckPointJVM(CRIUTestUtils.imagePath); - if (criu == null) { - // "CRIU is not enabled" is to appear and cause the test failure. - return; - } final TestResult testResult = new TestResult(true, 0); criu.registerPostRestoreHook(() -> { CRIUTestUtils.showThreadCurrentTime("The postRestoreHook with lower priority in CONCURRENT_MODE"); diff --git a/test/functional/cmdLineTests/criu/src/org/openj9/criu/TestMachineResourceChange.java b/test/functional/cmdLineTests/criu/src/org/openj9/criu/TestMachineResourceChange.java index ff92bfc9ba0..9ff2d866a36 100644 --- a/test/functional/cmdLineTests/criu/src/org/openj9/criu/TestMachineResourceChange.java +++ b/test/functional/cmdLineTests/criu/src/org/openj9/criu/TestMachineResourceChange.java @@ -97,10 +97,6 @@ private void testVirtualThreadForkJoinPoolParallelism(boolean isCheckpoint, bool private void test(String testName) throws InterruptedException { CRIUSupport criu = CRIUTestUtils.prepareCheckPointJVM(CRIUTestUtils.imagePath); - if (criu == null) { - // prepareCheckPointJVM() has an error message "CRIU is not enabled". - return; - } CRIUTestUtils.showThreadCurrentTime("Before starting " + testName); switch (testName) { case "testVirtualThreadForkJoinPoolParallelism": diff --git a/test/functional/cmdLineTests/criu/src/org/openj9/criu/TestSingleThreadModeCheckpointException.java b/test/functional/cmdLineTests/criu/src/org/openj9/criu/TestSingleThreadModeCheckpointException.java index c80cb4ad8d2..e06016433cf 100644 --- a/test/functional/cmdLineTests/criu/src/org/openj9/criu/TestSingleThreadModeCheckpointException.java +++ b/test/functional/cmdLineTests/criu/src/org/openj9/criu/TestSingleThreadModeCheckpointException.java @@ -77,10 +77,6 @@ void testSingleThreadModeCheckpointExceptionJUCLock() { CRIUTestUtils.showThreadCurrentTime("testSingleThreadModeCheckpointExceptionJUCLock() before ReentrantLock.lock()"); jucLock.lock(); CRIUSupport criu = CRIUTestUtils.prepareCheckPointJVM(CRIUTestUtils.imagePath); - if (criu == null) { - // "CRIU is not enabled" is to appear and cause the test failure. - return; - } try { // ensure the lock already taken before performing a checkpoint @@ -131,10 +127,6 @@ void testSingleThreadModeCheckpointExceptionSynLock() { "testSingleThreadModeCheckpointExceptionSynLock() before synchronized on " + synLock); synchronized (synLock) { CRIUSupport criu = CRIUTestUtils.prepareCheckPointJVM(CRIUTestUtils.imagePath); - if (criu == null) { - // "CRIU is not enabled" is to appear and cause the test failure. - return; - } try { // ensure the lock already taken before performing a checkpoint diff --git a/test/functional/cmdLineTests/criu/src/org/openj9/criu/TestSingleThreadModeRestoreException.java b/test/functional/cmdLineTests/criu/src/org/openj9/criu/TestSingleThreadModeRestoreException.java index 09d4626d558..d4b9bc6af24 100644 --- a/test/functional/cmdLineTests/criu/src/org/openj9/criu/TestSingleThreadModeRestoreException.java +++ b/test/functional/cmdLineTests/criu/src/org/openj9/criu/TestSingleThreadModeRestoreException.java @@ -82,10 +82,6 @@ void testSingleThreadModeRestoreExceptionJUCLock() { CRIUTestUtils.showThreadCurrentTime("testSingleThreadModeRestoreExceptionJUCLock() before ReentrantLock.lock()"); jucLock.lock(); CRIUSupport criu = CRIUTestUtils.prepareCheckPointJVM(CRIUTestUtils.imagePath); - if (criu == null) { - // "CRIU is not enabled" is to appear and cause the test failure. - return; - } try { // ensure the lock already taken before performing a checkpoint @@ -139,10 +135,6 @@ void testSingleThreadModeRestoreExceptionSynLock() { "testSingleThreadModeRestoreExceptionSynLock() before synchronized on " + synLock); synchronized (synLock) { CRIUSupport criu = CRIUTestUtils.prepareCheckPointJVM(CRIUTestUtils.imagePath); - if (criu == null) { - // "CRIU is not enabled" is to appear and cause the test failure. - return; - } try { // ensure the lock already taken before performing a checkpoint diff --git a/test/functional/cmdLineTests/criu/src/org/openj9/criu/TimeChangeTest.java b/test/functional/cmdLineTests/criu/src/org/openj9/criu/TimeChangeTest.java index e9c8551ba90..52a574bcb8c 100644 --- a/test/functional/cmdLineTests/criu/src/org/openj9/criu/TimeChangeTest.java +++ b/test/functional/cmdLineTests/criu/src/org/openj9/criu/TimeChangeTest.java @@ -42,7 +42,6 @@ public class TimeChangeTest { private final static long MILLIS_DELAY_AFTERCHECKPOINTDONE = 5000; private final long startNanoTime = System.nanoTime(); private final long currentTimeMillis = System.currentTimeMillis(); - private final static Path imagePath = Paths.get("cpData"); public static void main(String args[]) throws InterruptedException { if (args.length == 0) { @@ -74,6 +73,7 @@ public static void main(String args[]) throws InterruptedException { } private void test(String testName) throws InterruptedException { + CRIUSupport criu = CRIUTestUtils.prepareCheckPointJVM(CRIUTestUtils.imagePath); System.out.println("Start test name: " + testName); showThreadCurrentTime("Before starting " + testName); Timer timer = new Timer(); @@ -93,7 +93,7 @@ private void test(String testName) throws InterruptedException { default: throw new RuntimeException("Unrecognized test name: " + testName); } - CRIUTestUtils.checkPointJVM(imagePath, false); + CRIUTestUtils.checkPointJVMNoSetup(criu, CRIUTestUtils.imagePath, false); // maximum test running time is 12s Thread.sleep(12000); showThreadCurrentTime("End " + testName); @@ -101,9 +101,10 @@ private void test(String testName) throws InterruptedException { } public void testSystemNanoTime() { + CRIUSupport criu = CRIUTestUtils.prepareCheckPointJVM(CRIUTestUtils.imagePath); final long beforeCheckpoint = System.nanoTime(); System.out.println("System.nanoTime() before CRIU checkpoint: " + beforeCheckpoint); - CRIUTestUtils.checkPointJVM(imagePath, false); + CRIUTestUtils.checkPointJVMNoSetup(criu, CRIUTestUtils.imagePath, false); final long afterRestore = System.nanoTime(); final long elapsedTime = afterRestore - beforeCheckpoint; if (elapsedTime < MAX_TARDINESS_NS) { @@ -121,8 +122,9 @@ private void testGetLastRestoreTime() { System.out.println("FAILED: InternalCRIUSupport.getLastRestoreTime() - " + lastRestoreTime + " should be -1 before restore"); } + CRIUSupport criu = CRIUTestUtils.prepareCheckPointJVM(CRIUTestUtils.imagePath); long beforeCheckpoint = System.currentTimeMillis(); - CRIUTestUtils.checkPointJVM(imagePath, false); + CRIUTestUtils.checkPointJVMNoSetup(criu, CRIUTestUtils.imagePath, false); lastRestoreTime = InternalCRIUSupport.getLastRestoreTime(); long afterRestore = System.currentTimeMillis(); if (beforeCheckpoint >= lastRestoreTime) { @@ -139,36 +141,33 @@ private void testGetLastRestoreTime() { } private void testMXBeanUpTime() { + CRIUSupport criu = CRIUTestUtils.prepareCheckPointJVM(CRIUTestUtils.imagePath); RuntimeMXBean mxb = ManagementFactory.getRuntimeMXBean(); long uptimeBeforeCheckpoint = mxb.getUptime(); - CRIUTestUtils.checkPointJVM(imagePath, false); + CRIUTestUtils.checkPointJVMNoSetup(criu, CRIUTestUtils.imagePath, false); long uptimeAfterCheckpoint = mxb.getUptime(); - // UpTime adjustment less than the JVM down time 2s. - long adjustMillis = 1500; if (uptimeAfterCheckpoint <= uptimeBeforeCheckpoint) { System.out.println("FAILED: testMXBeanUpTime() - uptimeAfterCheckpoint " + uptimeAfterCheckpoint + " can't be less than uptimeBeforeCheckpoint " + uptimeBeforeCheckpoint); - } else if (uptimeAfterCheckpoint >= (uptimeBeforeCheckpoint + adjustMillis)) { - System.out.println("FAILED: testMXBeanUpTime() - uptimeAfterCheckpoint " + uptimeAfterCheckpoint - + " can't be greater than uptimeBeforeCheckpoint " + uptimeBeforeCheckpoint + " + " + adjustMillis); } else { System.out.println("PASSED: testMXBeanUpTime() - uptimeAfterCheckpoint " + uptimeAfterCheckpoint - + " is less than uptimeBeforeCheckpoint " + uptimeBeforeCheckpoint + " + " - + adjustMillis); + + " is greater than uptimeBeforeCheckpoint " + uptimeBeforeCheckpoint); } } public void testSystemNanoTimeJitPreCheckpointCompile() { + CRIUSupport criu = CRIUTestUtils.prepareCheckPointJVM(CRIUTestUtils.imagePath); testSystemNanoTimeJitTestPreCheckpointPhase(); testSystemNanoTimeJitWarmupPhase(); - CRIUTestUtils.checkPointJVM(imagePath, false); + CRIUTestUtils.checkPointJVMNoSetup(criu, CRIUTestUtils.imagePath, false); testSystemNanoTimeJitTestPostCheckpointPhase(); } public void testSystemNanoTimeJitPostCheckpointCompile() { + CRIUSupport criu = CRIUTestUtils.prepareCheckPointJVM(CRIUTestUtils.imagePath); testSystemNanoTimeJitTestPreCheckpointPhase(); - CRIUTestUtils.checkPointJVM(imagePath, false); + CRIUTestUtils.checkPointJVMNoSetup(criu, CRIUTestUtils.imagePath, false); testSystemNanoTimeJitWarmupPhase(); testSystemNanoTimeJitTestPostCheckpointPhase(); }