-
Notifications
You must be signed in to change notification settings - Fork 25.7k
Add early-access check #23743
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add early-access check #23743
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -560,12 +560,48 @@ private void runMightForkTest( | |
| consumer.accept(e); | ||
| } | ||
|
|
||
| public void testEarlyAccessCheck() throws NodeValidationException { | ||
| final AtomicReference<String> javaVersion | ||
| = new AtomicReference<>(randomFrom("1.8.0_152-ea", "9-ea")); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why does this need to be an
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Because I set it to a different value further down in the method to simulate a check where the Java version is not an early-access build. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ++, i didn't realize it was just one instance of the |
||
| final BootstrapChecks.EarlyAccessCheck eaCheck = new BootstrapChecks.EarlyAccessCheck() { | ||
|
|
||
| @Override | ||
| String jvmVendor() { | ||
| return "Oracle Corporation"; | ||
| } | ||
|
|
||
| @Override | ||
| String javaVersion() { | ||
| return javaVersion.get(); | ||
| } | ||
|
|
||
| }; | ||
|
|
||
| final List<BootstrapCheck> checks = Collections.singletonList(eaCheck); | ||
| final NodeValidationException e = expectThrows( | ||
| NodeValidationException.class, | ||
| () -> { | ||
| BootstrapChecks.check(true, checks, "testEarlyAccessCheck"); | ||
| }); | ||
| assertThat( | ||
| e.getMessage(), | ||
| containsString( | ||
| "Java version [" | ||
| + javaVersion.get() | ||
| + "] is an early-access build, only use release builds")); | ||
|
|
||
| // if not on an early-access build, nothing should happen | ||
| javaVersion.set(randomFrom("1.8.0_152", "9")); | ||
| BootstrapChecks.check(true, checks, "testEarlyAccessCheck"); | ||
|
|
||
| } | ||
|
|
||
| public void testG1GCCheck() throws NodeValidationException { | ||
| final AtomicBoolean isG1GCEnabled = new AtomicBoolean(true); | ||
| final AtomicBoolean isJava8 = new AtomicBoolean(true); | ||
| final AtomicReference<String> jvmVersion = | ||
| new AtomicReference<>(String.format(Locale.ROOT, "25.%d-b%d", randomIntBetween(0, 39), randomIntBetween(1, 128))); | ||
| final BootstrapChecks.G1GCCheck oracleCheck = new BootstrapChecks.G1GCCheck() { | ||
| final BootstrapChecks.G1GCCheck g1GCCheck = new BootstrapChecks.G1GCCheck() { | ||
|
|
||
| @Override | ||
| String jvmVendor() { | ||
|
|
@@ -592,20 +628,20 @@ boolean isJava8() { | |
| final NodeValidationException e = | ||
| expectThrows( | ||
| NodeValidationException.class, | ||
| () -> BootstrapChecks.check(true, Collections.singletonList(oracleCheck), "testG1GCCheck")); | ||
| () -> BootstrapChecks.check(true, Collections.singletonList(g1GCCheck), "testG1GCCheck")); | ||
| assertThat( | ||
| e.getMessage(), | ||
| containsString( | ||
| "JVM version [" + jvmVersion.get() + "] can cause data corruption when used with G1GC; upgrade to at least Java 8u40")); | ||
|
|
||
| // if G1GC is disabled, nothing should happen | ||
| isG1GCEnabled.set(false); | ||
| BootstrapChecks.check(true, Collections.singletonList(oracleCheck), "testG1GCCheck"); | ||
| BootstrapChecks.check(true, Collections.singletonList(g1GCCheck), "testG1GCCheck"); | ||
|
|
||
| // if on or after update 40, nothing should happen independent of whether or not G1GC is enabled | ||
| isG1GCEnabled.set(randomBoolean()); | ||
| jvmVersion.set(String.format(Locale.ROOT, "25.%d-b%d", randomIntBetween(40, 112), randomIntBetween(1, 128))); | ||
| BootstrapChecks.check(true, Collections.singletonList(oracleCheck), "testG1GCCheck"); | ||
| BootstrapChecks.check(true, Collections.singletonList(g1GCCheck), "testG1GCCheck"); | ||
|
|
||
| final BootstrapChecks.G1GCCheck nonOracleCheck = new BootstrapChecks.G1GCCheck() { | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit:
return "Oracle Corporation".equals(jvmVendor()) && javaVersion().endsWith("-ea")more succinct?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I pushed 6cf944e.