From bc392853e8129b523c1236b1dc2b5dc930163ce6 Mon Sep 17 00:00:00 2001 From: Dawid Weiss Date: Mon, 18 Dec 2023 09:14:30 +0100 Subject: [PATCH 1/3] Ignore the test if running on a client compiler. --- gradle/testing/randomization/policies/tests.policy | 3 --- .../src/test/org/apache/lucene/util/bkd/TestDocIdsWriter.java | 3 ++- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/gradle/testing/randomization/policies/tests.policy b/gradle/testing/randomization/policies/tests.policy index d833ea166cf3..46a351f4c619 100644 --- a/gradle/testing/randomization/policies/tests.policy +++ b/gradle/testing/randomization/policies/tests.policy @@ -60,9 +60,6 @@ grant { permission java.lang.RuntimePermission "getFileStoreAttributes"; permission java.lang.RuntimePermission "writeFileDescriptor"; - // needed to check if C2 (implied by the presence of the CI env) is enabled - permission java.lang.RuntimePermission "getenv.CI"; - // TestLockFactoriesMultiJVM opens a random port on 127.0.0.1 (port 0 = ephemeral port range): permission java.net.SocketPermission "127.0.0.1:0", "accept,listen,resolve"; diff --git a/lucene/core/src/test/org/apache/lucene/util/bkd/TestDocIdsWriter.java b/lucene/core/src/test/org/apache/lucene/util/bkd/TestDocIdsWriter.java index 6ddcabb03ae7..d129472d9098 100644 --- a/lucene/core/src/test/org/apache/lucene/util/bkd/TestDocIdsWriter.java +++ b/lucene/core/src/test/org/apache/lucene/util/bkd/TestDocIdsWriter.java @@ -34,6 +34,7 @@ import org.apache.lucene.tests.util.LuceneTestCase; import org.apache.lucene.tests.util.TestUtil; import org.apache.lucene.util.CollectionUtil; +import org.apache.lucene.util.Constants; import org.apache.lucene.util.SuppressForbidden; public class TestDocIdsWriter extends LuceneTestCase { @@ -162,7 +163,7 @@ public Relation compare(byte[] minPackedValue, byte[] maxPackedValue) { // Crashes only when run with C2, so with the environment variable `CI` set // Regardless of whether C2 is enabled or not, the test should never fail. public void testCrash() throws IOException { - assumeTrue("Requires C2, which is only enabled when CI env is set", getCIEnv() != null); + assumeFalse("Requires C2 compiler (won't work on client VM).", Constants.IS_CLIENT_VM); int itrs = atLeast(100); for (int i = 0; i < itrs; i++) { try (Directory dir = newDirectory(); From 31f232112bcaf14b34f965e5a82fd1cb346f3988 Mon Sep 17 00:00:00 2001 From: Dawid Weiss Date: Mon, 18 Dec 2023 12:06:31 +0100 Subject: [PATCH 2/3] Remove dead code, add 'only hotspot' condition. --- .../apache/lucene/util/bkd/TestDocIdsWriter.java | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/lucene/core/src/test/org/apache/lucene/util/bkd/TestDocIdsWriter.java b/lucene/core/src/test/org/apache/lucene/util/bkd/TestDocIdsWriter.java index d129472d9098..55f39d4092d1 100644 --- a/lucene/core/src/test/org/apache/lucene/util/bkd/TestDocIdsWriter.java +++ b/lucene/core/src/test/org/apache/lucene/util/bkd/TestDocIdsWriter.java @@ -17,8 +17,6 @@ package org.apache.lucene.util.bkd; import java.io.IOException; -import java.security.AccessController; -import java.security.PrivilegedAction; import java.util.Arrays; import java.util.List; import java.util.Set; @@ -35,7 +33,6 @@ import org.apache.lucene.tests.util.TestUtil; import org.apache.lucene.util.CollectionUtil; import org.apache.lucene.util.Constants; -import org.apache.lucene.util.SuppressForbidden; public class TestDocIdsWriter extends LuceneTestCase { @@ -163,7 +160,9 @@ public Relation compare(byte[] minPackedValue, byte[] maxPackedValue) { // Crashes only when run with C2, so with the environment variable `CI` set // Regardless of whether C2 is enabled or not, the test should never fail. public void testCrash() throws IOException { - assumeFalse("Requires C2 compiler (won't work on client VM).", Constants.IS_CLIENT_VM); + assumeTrue( + "Requires HotSpot C2 compiler (won't work on client VM).", + Constants.IS_HOTSPOT_VM && !Constants.IS_CLIENT_VM); int itrs = atLeast(100); for (int i = 0; i < itrs; i++) { try (Directory dir = newDirectory(); @@ -175,11 +174,4 @@ public void testCrash() throws IOException { } } } - - @SuppressForbidden(reason = "needed to check if C2 is enabled") - @SuppressWarnings("removal") - private static String getCIEnv() { - PrivilegedAction pa = () -> System.getenv("CI"); - return AccessController.doPrivileged(pa); - } } From ee008dcff5ac76b649aea9184ff71b95d8c68b56 Mon Sep 17 00:00:00 2001 From: Dawid Weiss Date: Mon, 18 Dec 2023 12:07:55 +0100 Subject: [PATCH 3/3] Remove CI variable reference from the comment. --- .../src/test/org/apache/lucene/util/bkd/TestDocIdsWriter.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lucene/core/src/test/org/apache/lucene/util/bkd/TestDocIdsWriter.java b/lucene/core/src/test/org/apache/lucene/util/bkd/TestDocIdsWriter.java index 55f39d4092d1..086eb460e56e 100644 --- a/lucene/core/src/test/org/apache/lucene/util/bkd/TestDocIdsWriter.java +++ b/lucene/core/src/test/org/apache/lucene/util/bkd/TestDocIdsWriter.java @@ -157,7 +157,7 @@ public Relation compare(byte[] minPackedValue, byte[] maxPackedValue) { } // This simple test tickles a JVM C2 JIT crash on JDK's less than 21.0.1 - // Crashes only when run with C2, so with the environment variable `CI` set + // Crashes only when run with HotSpot C2. // Regardless of whether C2 is enabled or not, the test should never fail. public void testCrash() throws IOException { assumeTrue(