changeset 60650:5ca905e0c514

8240634: event/runtime/TestMetaspaceAllocationFailure.java times out Summary: Limit number of iterations Reviewed-by: egahlin, stuefe
author mseledtsov
date Thu, 26 Mar 2020 10:03:35 -0700
parents e886b0d7ff87
children 5ac19bd3a1e2
files test/jdk/jdk/jfr/event/runtime/TestMetaspaceAllocationFailure.java
diffstat 1 files changed, 12 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/test/jdk/jdk/jfr/event/runtime/TestMetaspaceAllocationFailure.java	Thu Mar 26 09:03:52 2020 -0700
+++ b/test/jdk/jdk/jfr/event/runtime/TestMetaspaceAllocationFailure.java	Thu Mar 26 10:03:35 2020 -0700
@@ -29,9 +29,11 @@
  * @modules java.base/jdk.internal.misc java.compiler
  * @run main/othervm -Xmx1G -XX:MaxMetaspaceSize=200M
  *      -XX:StartFlightRecording -Xshare:off
+ *      -Xlog:gc+metaspace*=debug
  *      jdk.jfr.event.runtime.TestMetaspaceAllocationFailure
- * @run main/othervm -Xmx1G -XX:CompressedClassSpaceSize=200M
+ * @run main/othervm -Xmx1G -XX:CompressedClassSpaceSize=10M
  *      -XX:StartFlightRecording -Xshare:off
+ *      -Xlog:gc+metaspace*=debug
  *      jdk.jfr.event.runtime.TestMetaspaceAllocationFailure
  */
 package jdk.jfr.event.runtime;
@@ -40,21 +42,27 @@
 import jdk.jfr.consumer.RecordingStream;
 import jdk.test.lib.classloader.GeneratingCompilingClassLoader;
 import jdk.test.lib.Asserts;
-
+import jtreg.SkippedException;
 
 public class TestMetaspaceAllocationFailure {
+    private static final int MAX_ITERATIONS = 100;
+
     public static void main(String... args) throws Exception {
         AtomicBoolean eventArrived = new AtomicBoolean(false);
+
         try (RecordingStream r = new RecordingStream()) {
             r.onEvent("jdk.MetaspaceAllocationFailure", e -> eventArrived.set(true));
             r.startAsync();
 
             try {
+                int iteration = 0;
                 while (!eventArrived.get()) {
                     GeneratingCompilingClassLoader cl = new GeneratingCompilingClassLoader();
                     cl.getGeneratedClasses(50, 20);
-                    Thread.sleep(100);
-                    System.out.println("Iteration");
+                    System.out.println("Iteration:" + iteration++);
+                    if (iteration > MAX_ITERATIONS) {
+                        throw new SkippedException("Exceeded MAX_ITERATIONS of " + MAX_ITERATIONS);
+                    }
                 }
                 System.gc();
                 System.out.println("main(): Event arrived");