-
Notifications
You must be signed in to change notification settings - Fork 202
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
Run tests on the current JVM / Gradle 8.8 #4730
Run tests on the current JVM / Gradle 8.8 #4730
Conversation
… tests. This fixes a problem with our current GitHub tests where we are running against only Java 11 even though we want to run against different Java versions (11, 17, 21). Updates the Gradle version to 8.8. Signed-off-by: David Venable <dlv@amazon.com>
…stop which now always throws an UnsupportedOperationException. Signed-off-by: David Venable <dlv@amazon.com>
9a48186
to
2ded41a
Compare
…'s stdout. This is too much noise. Signed-off-by: David Venable <dlv@amazon.com>
…o stdout. Signed-off-by: David Venable <dlv@amazon.com>
…vent_json codec. These tests are failing now on Java 17 and 21 with precision errors. Signed-off-by: David Venable <dlv@amazon.com>
…caused an IllegalArgumentException. Signed-off-by: David Venable <dlv@amazon.com>
@@ -76,7 +78,7 @@ public void output(Collection<T> records) { | |||
@Override | |||
public void shutdown() { | |||
if (retryThread != null) { | |||
retryThread.stop(); |
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.
In Java 21, Thread::stop
always throws an UnsupportedOperationException
. So I've changed this approach to tell the runnable below to stop itself.
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.
Do we have other locations in plugins where threads are stopped like this?
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 ran IntelliJ's "Find Usages" feature on Thread::stop
. It found this usage, but found no others. So I don't believe so.
@@ -48,7 +48,6 @@ dependencies { | |||
exclude group: 'commons-logging', module: 'commons-logging' | |||
} | |||
implementation 'software.amazon.cloudwatchlogs:aws-embedded-metrics:2.0.0-beta-1' | |||
testImplementation 'org.apache.logging.log4j:log4j-jpl:2.23.0' |
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.
For some reason, in Java 17 and 21, this results in all the logs going to stdout in the Gradle task. This makes understanding the build very difficult as there is far too much noise.
@@ -218,7 +218,7 @@ static class SomeUnknownTypesArgumentsProvider implements ArgumentsProvider { | |||
@Override | |||
public Stream<? extends Arguments> provideArguments(ExtensionContext context) { | |||
return Stream.of( | |||
arguments(Random.class), |
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.
In Java 21 (and maybe 17?), Random
is final
and this causes Mockito to fail when it mocks it. So, we test on the Timer
class instead.
@@ -328,7 +328,7 @@ public Stream<? extends Arguments> provideArguments(final ExtensionContext conte | |||
return Stream.of( | |||
Arguments.of(0, randomInt + 1, 0.0), | |||
Arguments.of(1, 100, 1.0), | |||
Arguments.of(randomInt, randomInt, 100.0), |
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.
This can sometimes be zero, and this will cause the test to fail. So, ensure it is not 0
.
@@ -11,9 +11,12 @@ | |||
import org.junit.jupiter.api.Test; | |||
import org.junit.jupiter.params.ParameterizedTest; | |||
import org.junit.jupiter.params.provider.ValueSource; | |||
|
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.
This is mostly running the IntelliJ formatter. The only other changes are the truncatedTo
. See comments below.
@@ -70,15 +74,15 @@ public void inCompatibleVersionTest() throws Exception { | |||
final String key = UUID.randomUUID().toString(); | |||
final String value = UUID.randomUUID().toString(); | |||
Map<String, Object> data = Map.of(key, value); | |||
Instant startTime = Instant.now(); |
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.
In later versions of Java on Linux, there is an issue where the nanosecond resolution results in test failures.
@@ -226,6 +226,9 @@ subprojects { | |||
|
|||
test { | |||
useJUnitPlatform() | |||
javaLauncher = javaToolchains.launcherFor { |
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.
This tells Gradle to use the current JVM version for running the tests. This is what now allows our tests to run on Java 17 or 21.
@@ -76,7 +78,7 @@ public void output(Collection<T> records) { | |||
@Override | |||
public void shutdown() { | |||
if (retryThread != null) { | |||
retryThread.stop(); |
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.
Do we have other locations in plugins where threads are stopped like this?
…h-project#4730) Run tests on the current JVM rather than always using Java 11 for the tests. This fixes a problem with our current GitHub tests where we are running against only Java 11 even though we want to run against different Java versions (11, 17, 21). Updates the Gradle version to 8.8. Fix Java 21 support in the AbstractSink by removing usage of Thread::stop which now always throws an UnsupportedOperationException. Use only microsecond precision time when comparing the times in the event_json codec. These tests are failing now on Java 17 and 21 with precision errors. Fixed a randomly failing test in BlockingBufferTests where a value 0 caused an IllegalArgumentException. Logging changes to avoid noise in the Gradle builds in GitHub. Signed-off-by: David Venable <dlv@amazon.com> Signed-off-by: Krishna Kondaka <krishkdk@dev-dsk-krishkdk-2c-bd29c437.us-west-2.amazon.com>
…pensearch-project#4730)" This reverts commit 67f3595. Signed-off-by: Hai Yan <oeyh@amazon.com>
…h-project#4730) Run tests on the current JVM rather than always using Java 11 for the tests. This fixes a problem with our current GitHub tests where we are running against only Java 11 even though we want to run against different Java versions (11, 17, 21). Updates the Gradle version to 8.8. Fix Java 21 support in the AbstractSink by removing usage of Thread::stop which now always throws an UnsupportedOperationException. Use only microsecond precision time when comparing the times in the event_json codec. These tests are failing now on Java 17 and 21 with precision errors. Fixed a randomly failing test in BlockingBufferTests where a value 0 caused an IllegalArgumentException. Logging changes to avoid noise in the Gradle builds in GitHub. Signed-off-by: David Venable <dlv@amazon.com> Signed-off-by: Krishna Kondaka <krishkdk@dev-dsk-krishkdk-2c-bd29c437.us-west-2.amazon.com>
…pensearch-project#4730)" (opensearch-project#4762) This reverts commit 67f3595. Signed-off-by: Hai Yan <oeyh@amazon.com> Signed-off-by: Krishna Kondaka <krishkdk@dev-dsk-krishkdk-2c-bd29c437.us-west-2.amazon.com>
…pensearch-project#4730)" (opensearch-project#4762) This reverts commit 67f3595. Signed-off-by: Hai Yan <oeyh@amazon.com> Signed-off-by: Krishna Kondaka <krishkdk@dev-dsk-krishkdk-2c-bd29c437.us-west-2.amazon.com>
…pensearch-project#4730)" (opensearch-project#4762) This reverts commit 5c7d58c. Signed-off-by: David Venable <dlv@amazon.com>
…h-project#4730) Run tests on the current JVM rather than always using Java 11 for the tests. This fixes a problem with our current GitHub tests where we are running against only Java 11 even though we want to run against different Java versions (11, 17, 21). Updates the Gradle version to 8.8. Fix Java 21 support in the AbstractSink by removing usage of Thread::stop which now always throws an UnsupportedOperationException. Use only microsecond precision time when comparing the times in the event_json codec. These tests are failing now on Java 17 and 21 with precision errors. Fixed a randomly failing test in BlockingBufferTests where a value 0 caused an IllegalArgumentException. Logging changes to avoid noise in the Gradle builds in GitHub. Signed-off-by: David Venable <dlv@amazon.com> Signed-off-by: Krishna Kondaka <krishkdk@dev-dsk-krishkdk-2c-bd29c437.us-west-2.amazon.com>
…pensearch-project#4730)" (opensearch-project#4762) This reverts commit 67f3595. Signed-off-by: Hai Yan <oeyh@amazon.com> Signed-off-by: Krishna Kondaka <krishkdk@dev-dsk-krishkdk-2c-bd29c437.us-west-2.amazon.com>
…h-project#4730) Run tests on the current JVM rather than always using Java 11 for the tests. This fixes a problem with our current GitHub tests where we are running against only Java 11 even though we want to run against different Java versions (11, 17, 21). Updates the Gradle version to 8.8. Fix Java 21 support in the AbstractSink by removing usage of Thread::stop which now always throws an UnsupportedOperationException. Use only microsecond precision time when comparing the times in the event_json codec. These tests are failing now on Java 17 and 21 with precision errors. Fixed a randomly failing test in BlockingBufferTests where a value 0 caused an IllegalArgumentException. Logging changes to avoid noise in the Gradle builds in GitHub. Signed-off-by: David Venable <dlv@amazon.com> Signed-off-by: Krishna Kondaka <krishkdk@dev-dsk-krishkdk-2c-bd29c437.us-west-2.amazon.com>
…pensearch-project#4730)" (opensearch-project#4762) This reverts commit 67f3595. Signed-off-by: Hai Yan <oeyh@amazon.com> Signed-off-by: Krishna Kondaka <krishkdk@dev-dsk-krishkdk-2c-bd29c437.us-west-2.amazon.com>
…pensearch-project#4730)" (opensearch-project#4762) (opensearch-project#4771) This reverts commit 5c7d58c. Signed-off-by: David Venable <dlv@amazon.com> Signed-off-by: Krishna Kondaka <krishkdk@dev-dsk-krishkdk-2c-bd29c437.us-west-2.amazon.com>
…h-project#4730) Run tests on the current JVM rather than always using Java 11 for the tests. This fixes a problem with our current GitHub tests where we are running against only Java 11 even though we want to run against different Java versions (11, 17, 21). Updates the Gradle version to 8.8. Fix Java 21 support in the AbstractSink by removing usage of Thread::stop which now always throws an UnsupportedOperationException. Use only microsecond precision time when comparing the times in the event_json codec. These tests are failing now on Java 17 and 21 with precision errors. Fixed a randomly failing test in BlockingBufferTests where a value 0 caused an IllegalArgumentException. Logging changes to avoid noise in the Gradle builds in GitHub. Signed-off-by: David Venable <dlv@amazon.com> Signed-off-by: Krishna Kondaka <krishkdk@dev-dsk-krishkdk-2c-bd29c437.us-west-2.amazon.com>
…pensearch-project#4730)" (opensearch-project#4762) This reverts commit 67f3595. Signed-off-by: Hai Yan <oeyh@amazon.com> Signed-off-by: Krishna Kondaka <krishkdk@dev-dsk-krishkdk-2c-bd29c437.us-west-2.amazon.com>
…pensearch-project#4730)" (opensearch-project#4762) (opensearch-project#4771) This reverts commit 5c7d58c. Signed-off-by: David Venable <dlv@amazon.com> Signed-off-by: Krishna Kondaka <krishkdk@dev-dsk-krishkdk-2c-bd29c437.us-west-2.amazon.com>
…h-project#4730) Run tests on the current JVM rather than always using Java 11 for the tests. This fixes a problem with our current GitHub tests where we are running against only Java 11 even though we want to run against different Java versions (11, 17, 21). Updates the Gradle version to 8.8. Fix Java 21 support in the AbstractSink by removing usage of Thread::stop which now always throws an UnsupportedOperationException. Use only microsecond precision time when comparing the times in the event_json codec. These tests are failing now on Java 17 and 21 with precision errors. Fixed a randomly failing test in BlockingBufferTests where a value 0 caused an IllegalArgumentException. Logging changes to avoid noise in the Gradle builds in GitHub. Signed-off-by: David Venable <dlv@amazon.com> Signed-off-by: Krishna Kondaka <krishkdk@dev-dsk-krishkdk-2c-bd29c437.us-west-2.amazon.com>
…pensearch-project#4730)" (opensearch-project#4762) This reverts commit 67f3595. Signed-off-by: Hai Yan <oeyh@amazon.com> Signed-off-by: Krishna Kondaka <krishkdk@dev-dsk-krishkdk-2c-bd29c437.us-west-2.amazon.com>
…pensearch-project#4730)" (opensearch-project#4762) (opensearch-project#4771) This reverts commit 5c7d58c. Signed-off-by: David Venable <dlv@amazon.com> Signed-off-by: Krishna Kondaka <krishkdk@dev-dsk-krishkdk-2c-bd29c437.us-west-2.amazon.com>
Description
While debugging a test recently, I noticed that the Java 17 test reports a basic
java.lang.NullPointerException
. Java 17 provides better NPE information that Java 11. It turns out that the tests are actually running against Java 11 entirely. Even in our matrix tests, these run on Java 11.This PR uses the current JVM versions (ie. what Gradle is running on) to execute the Java tests. This way, our tests will test actually test against other Java versions.
Also, I updated the Gradle 8.8 because
JavaLanguageVersion.current()
was added in 8.8.Verification
I created a simple test to prove this:
Running on Java 11:
yields:
Running on Java 17:
yields:
Issues Resolved
N/A
Check List
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.