8314614: jdk/jshell/ImportTest.java failed with "InternalError: Failed remote listen"
8312140: jdk/jshell tests failed with JDI socket timeouts Reviewed-by: asotona
This commit is contained in:
parent
864b39a893
commit
14193a049e
@ -64,6 +64,7 @@ public class AnalyzeSnippetTest {
|
||||
state = JShell.builder()
|
||||
.out(new PrintStream(new ByteArrayOutputStream()))
|
||||
.err(new PrintStream(new ByteArrayOutputStream()))
|
||||
.executionEngine(Presets.TEST_DEFAULT_EXECUTION)
|
||||
.build();
|
||||
sca = state.sourceCodeAnalysis();
|
||||
}
|
||||
|
@ -90,7 +90,8 @@ public class CustomInputToolBuilder extends KullaTesting {
|
||||
.interactiveTerminal(interactiveTerminal)
|
||||
.promptCapture(true)
|
||||
.persistence(new HashMap<>())
|
||||
.start("--no-startup");
|
||||
.start("--no-startup",
|
||||
"--execution", Presets.TEST_DEFAULT_EXECUTION);
|
||||
|
||||
String actual = new String(out.toByteArray());
|
||||
List<String> actualLines = Arrays.asList(actual.split("\\R"));
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2016, 2023, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -25,28 +25,14 @@ import javax.tools.Diagnostic;
|
||||
|
||||
import org.testng.annotations.Test;
|
||||
import jdk.jshell.VarSnippet;
|
||||
import java.net.InetAddress;
|
||||
|
||||
import static jdk.jshell.Snippet.Status.VALID;
|
||||
import static jdk.jshell.Snippet.SubKind.*;
|
||||
|
||||
public class ExecutionControlTestBase extends KullaTesting {
|
||||
|
||||
String standardListenSpec() {
|
||||
String loopback = InetAddress.getLoopbackAddress().getHostAddress();
|
||||
return "jdi:hostname(" + loopback + ")";
|
||||
}
|
||||
|
||||
String standardLaunchSpec() {
|
||||
return "jdi:launch(true)";
|
||||
}
|
||||
|
||||
String standardJdiSpec() {
|
||||
return "jdi";
|
||||
}
|
||||
|
||||
String standardSpecs() {
|
||||
return "5(" + standardListenSpec() + "), 6(" + standardLaunchSpec() + "), 7(" + standardJdiSpec() + ")";
|
||||
String alwaysPassingSpec() {
|
||||
return "5(local)";
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2016, 2023, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -129,9 +129,7 @@ public class FailOverDirectExecutionControlTest extends ExecutionControlTestBase
|
||||
Map<String, String> pm = provider.defaultParameters();
|
||||
pm.put("0", "alwaysFailing");
|
||||
pm.put("1", "alwaysFailing");
|
||||
pm.put("2", standardListenSpec());
|
||||
pm.put("3", standardLaunchSpec());
|
||||
pm.put("4", standardJdiSpec());
|
||||
pm.put("2", "local");
|
||||
setUp(builder -> builder.executionEngine(provider, pm));
|
||||
}
|
||||
|
||||
@ -159,9 +157,7 @@ public class FailOverDirectExecutionControlTest extends ExecutionControlTestBase
|
||||
assertTrue(log.contains("This operation intentionally broken"), log);
|
||||
log = logged.get(Level.FINEST).get(0);
|
||||
assertTrue(
|
||||
log.contains("Success failover -- 2 = " + standardListenSpec())
|
||||
|| log.contains("Success failover -- 3 = " + standardLaunchSpec())
|
||||
|| log.contains("Success failover -- 4 = " + standardJdiSpec()),
|
||||
log.contains("Success failover -- 2 = local"),
|
||||
log);
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2016, 2023, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -43,6 +43,6 @@ public class FailOverExecutionControlDyingLaunchTest extends ExecutionControlTes
|
||||
public void setUp() {
|
||||
setUp(builder -> builder.executionEngine(
|
||||
"failover:0(jdi:remoteAgent(DyingRemoteAgent),launch(true)), "
|
||||
+ standardSpecs()));
|
||||
+ alwaysPassingSpec()));
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2016, 2023, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -42,6 +42,6 @@ public class FailOverExecutionControlHangingLaunchTest extends ExecutionControlT
|
||||
public void setUp() {
|
||||
setUp(builder -> builder.executionEngine(
|
||||
"failover:0(jdi:remoteAgent(HangingRemoteAgent),launch(true)), "
|
||||
+ standardSpecs()));
|
||||
+ alwaysPassingSpec()));
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2016, 2023, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -45,6 +45,6 @@ public class FailOverExecutionControlHangingListenTest extends ExecutionControlT
|
||||
String loopback = InetAddress.getLoopbackAddress().getHostAddress();
|
||||
setUp(builder -> builder.executionEngine(
|
||||
"failover:0(jdi:remoteAgent(HangingRemoteAgent),hostname(" + loopback + ")),"
|
||||
+ standardSpecs()));
|
||||
+ alwaysPassingSpec()));
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2016, 2023, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -41,7 +41,7 @@ public class FailOverExecutionControlTest extends ExecutionControlTestBase {
|
||||
@Override
|
||||
public void setUp() {
|
||||
setUp(builder -> builder.executionEngine("failover:0(expectedFailureNonExistent1), 1(expectedFailureNonExistent2), "
|
||||
+ standardSpecs()));
|
||||
+ alwaysPassingSpec()));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -53,7 +53,8 @@ public class IdGeneratorTest {
|
||||
return JShell.builder()
|
||||
.in(inStream)
|
||||
.out(new PrintStream(outStream))
|
||||
.err(new PrintStream(errStream));
|
||||
.err(new PrintStream(errStream))
|
||||
.executionEngine(Presets.TEST_DEFAULT_EXECUTION);
|
||||
}
|
||||
|
||||
public void testTempNameGenerator() {
|
||||
|
@ -100,7 +100,9 @@ public class KullaTesting {
|
||||
private Set<Snippet> allSnippets = new LinkedHashSet<>();
|
||||
|
||||
static {
|
||||
JShell js = JShell.create();
|
||||
JShell js = JShell.builder()
|
||||
.executionEngine(Presets.TEST_DEFAULT_EXECUTION)
|
||||
.build();
|
||||
MAIN_SNIPPET = js.eval("MAIN_SNIPPET").get(0).snippet();
|
||||
js.close();
|
||||
assertTrue(MAIN_SNIPPET != null, "Bad MAIN_SNIPPET set-up -- must not be null");
|
||||
@ -192,7 +194,8 @@ public class KullaTesting {
|
||||
JShell.Builder builder = JShell.builder()
|
||||
.in(in)
|
||||
.out(new PrintStream(outStream))
|
||||
.err(new PrintStream(errStream));
|
||||
.err(new PrintStream(errStream))
|
||||
.executionEngine(Presets.TEST_DEFAULT_EXECUTION);
|
||||
bc.accept(builder);
|
||||
state = builder.build();
|
||||
allSnippets = new LinkedHashSet<>();
|
||||
|
59
test/langtools/jdk/jshell/Presets.java
Normal file
59
test/langtools/jdk/jshell/Presets.java
Normal file
@ -0,0 +1,59 @@
|
||||
/*
|
||||
* Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
import java.net.InetAddress;
|
||||
import java.util.*;
|
||||
|
||||
public class Presets {
|
||||
public static final String TEST_DEFAULT_EXECUTION;
|
||||
public static final String TEST_STANDARD_EXECUTION;
|
||||
|
||||
static {
|
||||
String loopback = InetAddress.getLoopbackAddress().getHostAddress();
|
||||
|
||||
TEST_DEFAULT_EXECUTION = "failover:0(jdi:hostname(" + loopback + "))," +
|
||||
"1(jdi:launch(true)), 2(jdi), 3(local)";
|
||||
TEST_STANDARD_EXECUTION = "failover:0(jdi:hostname(" + loopback + "))," +
|
||||
"1(jdi:launch(true)), 2(jdi)";
|
||||
}
|
||||
|
||||
public static String[] addExecutionIfMissing(String[] args) {
|
||||
if (Arrays.stream(args).noneMatch(Presets::remoteRelatedOption)) {
|
||||
List<String> augmentedArgs = new ArrayList<>();
|
||||
|
||||
augmentedArgs.add("--execution");
|
||||
augmentedArgs.add(Presets.TEST_DEFAULT_EXECUTION);
|
||||
augmentedArgs.addAll(List.of(args));
|
||||
|
||||
return augmentedArgs.toArray(s -> new String[s]);
|
||||
}
|
||||
|
||||
return args;
|
||||
}
|
||||
|
||||
private static boolean remoteRelatedOption(String option) {
|
||||
return "--execution".equals(option) ||
|
||||
"--add-modules".equals(option) ||
|
||||
option.startsWith("-R");
|
||||
}
|
||||
}
|
@ -304,7 +304,7 @@ public class ReplToolTesting {
|
||||
private void testRaw(Locale locale, String[] args,
|
||||
String expectedErrorOutput, ReplTest... tests) {
|
||||
testRawInit(tests);
|
||||
testRawRun(locale, args);
|
||||
testRawRun(locale, Presets.addExecutionIfMissing(args));
|
||||
testRawCheck(locale, expectedErrorOutput);
|
||||
}
|
||||
|
||||
|
@ -81,7 +81,7 @@ public class StartOptionTest {
|
||||
protected int runShell(String... args) {
|
||||
try {
|
||||
return builder()
|
||||
.start(args);
|
||||
.start(Presets.addExecutionIfMissing(args));
|
||||
} catch (Exception ex) {
|
||||
fail("Repl tool died with exception", ex);
|
||||
}
|
||||
|
@ -201,7 +201,7 @@ public class ToolReloadTest extends ReplToolTesting {
|
||||
}
|
||||
|
||||
public void testEnvBadModule() {
|
||||
test(
|
||||
test(new String[] {"--execution", Presets.TEST_STANDARD_EXECUTION},
|
||||
(a) -> assertVariable(a, "int", "x", "5", "5"),
|
||||
(a) -> assertMethod(a, "int m(int z) { return z * z; }",
|
||||
"(int)int", "m"),
|
||||
|
@ -93,7 +93,8 @@ public class UITesting {
|
||||
.promptCapture(true)
|
||||
.persistence(new HashMap<>())
|
||||
.locale(Locale.US)
|
||||
.run("--no-startup");
|
||||
.run("--no-startup",
|
||||
"--execution", Presets.TEST_DEFAULT_EXECUTION);
|
||||
} catch (Exception ex) {
|
||||
throw new IllegalStateException(ex);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user