mirror of https://github.com/apache/lucene.git
Silence odd test runner warnings after gradle upgrade (#13471)
This commit is contained in:
parent
fb94403e0f
commit
06f86a5096
|
@ -133,7 +133,12 @@ allprojects {
|
||||||
jvmArgs '--add-modules', 'jdk.incubator.vector'
|
jvmArgs '--add-modules', 'jdk.incubator.vector'
|
||||||
}
|
}
|
||||||
|
|
||||||
jvmArgs '--enable-native-access=' + (project.path == ':lucene:core' ? 'ALL-UNNAMED' : 'org.apache.lucene.core')
|
jvmArgs '--enable-native-access=' + (project.path in [
|
||||||
|
':lucene:core',
|
||||||
|
':lucene:codecs',
|
||||||
|
":lucene:distribution.tests",
|
||||||
|
":lucene:test-framework"
|
||||||
|
] ? 'ALL-UNNAMED' : 'org.apache.lucene.core')
|
||||||
|
|
||||||
def loggingConfigFile = layout.projectDirectory.file("${resources}/logging.properties")
|
def loggingConfigFile = layout.projectDirectory.file("${resources}/logging.properties")
|
||||||
def tempDir = layout.projectDirectory.dir(testsTmpDir.toString())
|
def tempDir = layout.projectDirectory.dir(testsTmpDir.toString())
|
||||||
|
|
|
@ -16,8 +16,12 @@
|
||||||
*/
|
*/
|
||||||
package org.apache.lucene.codecs;
|
package org.apache.lucene.codecs;
|
||||||
|
|
||||||
|
import com.carrotsearch.randomizedtesting.LifecycleScope;
|
||||||
import com.carrotsearch.randomizedtesting.RandomizedContext;
|
import com.carrotsearch.randomizedtesting.RandomizedContext;
|
||||||
import com.carrotsearch.randomizedtesting.RandomizedRunner;
|
import com.carrotsearch.randomizedtesting.RandomizedRunner;
|
||||||
|
import com.carrotsearch.randomizedtesting.RandomizedTest;
|
||||||
|
import java.nio.file.Files;
|
||||||
|
import java.nio.file.Path;
|
||||||
import java.nio.file.Paths;
|
import java.nio.file.Paths;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
@ -34,6 +38,7 @@ import java.util.stream.Collectors;
|
||||||
import java.util.stream.IntStream;
|
import java.util.stream.IntStream;
|
||||||
import org.apache.lucene.tests.util.LuceneTestCase;
|
import org.apache.lucene.tests.util.LuceneTestCase;
|
||||||
import org.apache.lucene.util.NamedThreadFactory;
|
import org.apache.lucene.util.NamedThreadFactory;
|
||||||
|
import org.apache.lucene.util.SuppressForbidden;
|
||||||
import org.junit.Assert;
|
import org.junit.Assert;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
|
@ -46,6 +51,7 @@ public class TestCodecLoadingDeadlock extends Assert {
|
||||||
private static final int MAX_TIME_SECONDS = 30;
|
private static final int MAX_TIME_SECONDS = 30;
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@SuppressForbidden(reason = "Uses Path.toFile because ProcessBuilder requires it.")
|
||||||
public void testDeadlock() throws Exception {
|
public void testDeadlock() throws Exception {
|
||||||
// pick random codec names for stress test in separate process:
|
// pick random codec names for stress test in separate process:
|
||||||
final Random rnd = RandomizedContext.current().getRandom();
|
final Random rnd = RandomizedContext.current().getRandom();
|
||||||
|
@ -67,12 +73,23 @@ public class TestCodecLoadingDeadlock extends Assert {
|
||||||
args.addAll(List.of(getClass().getName(), codecName, pfName, dvfName));
|
args.addAll(List.of(getClass().getName(), codecName, pfName, dvfName));
|
||||||
|
|
||||||
// Fork a separate JVM to reinitialize classes.
|
// Fork a separate JVM to reinitialize classes.
|
||||||
final Process p = new ProcessBuilder(args).inheritIO().start();
|
final Path output = RandomizedTest.newTempFile(LifecycleScope.TEST);
|
||||||
if (p.waitFor(MAX_TIME_SECONDS * 2, TimeUnit.SECONDS)) {
|
final Process p =
|
||||||
assertEquals("Process died abnormally?", 0, p.waitFor());
|
new ProcessBuilder(args).redirectErrorStream(true).redirectOutput(output.toFile()).start();
|
||||||
} else {
|
boolean success = false;
|
||||||
p.destroyForcibly().waitFor();
|
try {
|
||||||
fail("Process did not exit after 60 secs?");
|
if (p.waitFor(MAX_TIME_SECONDS * 2, TimeUnit.SECONDS)) {
|
||||||
|
assertEquals("Process died abnormally?", 0, p.waitFor());
|
||||||
|
success = true;
|
||||||
|
} else {
|
||||||
|
p.destroyForcibly().waitFor();
|
||||||
|
fail("Process did not exit after 60 secs?");
|
||||||
|
}
|
||||||
|
} finally {
|
||||||
|
if (!success) {
|
||||||
|
System.out.println("Subprocess emitted the following output:");
|
||||||
|
System.out.write(Files.readAllBytes(output));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue