-
Notifications
You must be signed in to change notification settings - Fork 191
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 an integration test that runs on JDK-8 #795
Merged
Merged
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
name: Compatibility Unit Tests (JDK-8) | ||
|
||
on: [push, pull_request] | ||
|
||
jobs: | ||
test: | ||
runs-on: ${{ matrix.os }} | ||
strategy: | ||
matrix: | ||
os: [ubuntu-latest, windows-latest, macOS-latest] | ||
steps: | ||
- name: Checkout Java Client | ||
uses: actions/checkout@v3 | ||
|
||
- name: Set up JDK 8 | ||
uses: actions/setup-java@v3 | ||
with: | ||
java-version: 8 | ||
distribution: 'temurin' | ||
cache: 'gradle' | ||
|
||
- name: Set up JDK 11 | ||
uses: actions/setup-java@v3 | ||
with: | ||
java-version: 11 | ||
distribution: 'temurin' | ||
cache: 'gradle' | ||
|
||
- name: Run Unit Test | ||
run: ./gradlew clean unitTest -Pcheck-jdk8-compatibility=true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -32,6 +32,7 @@ | |
|
||
import com.github.jk1.license.ProjectData | ||
import com.github.jk1.license.render.ReportRenderer | ||
import org.gradle.api.tasks.testing.Test | ||
import java.io.FileWriter | ||
|
||
buildscript { | ||
|
@@ -337,7 +338,9 @@ publishing { | |
} | ||
} | ||
|
||
if (JavaVersion.current() >= JavaVersion.VERSION_11) { | ||
// Use `-Pcheck-jdk8-compatibility=true` to | ||
val jdk8compatibility = (project.findProperty("check-jdk8-compatibility") as String?).toBoolean() | ||
if (JavaVersion.current() >= JavaVersion.VERSION_11 && jdk8compatibility == false) { | ||
val java11: SourceSet = sourceSets.create("java11") { | ||
java { | ||
compileClasspath += sourceSets.main.get().output + sourceSets.test.get().output | ||
|
@@ -369,5 +372,17 @@ if (JavaVersion.current() >= JavaVersion.VERSION_11) { | |
testClassesDirs += java11.output.classesDirs | ||
classpath = sourceSets["java11"].runtimeClasspath | ||
} | ||
|
||
} else if (jdk8compatibility == true) { | ||
java { | ||
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. @dblock @VachaShah curious what you think about this approach: we cannot run Gradle build using JDK-8 but we could use toolchains to run tests under JDK-8. |
||
toolchain { | ||
languageVersion = JavaLanguageVersion.of(8) | ||
vendor = JvmVendorSpec.ADOPTIUM | ||
} | ||
} | ||
|
||
tasks.register<Test>("tests-jdk8") { | ||
javaLauncher = javaToolchains.launcherFor { | ||
languageVersion = JavaLanguageVersion.of(8) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
...ient/src/test/java/org/opensearch/client/opensearch/_types/query_dsl/PinnedQueryTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 3 additions & 3 deletions
6
.../test/java/org/opensearch/client/opensearch/_types/query_dsl/SpanContainingQueryTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
...est/java/org/opensearch/client/opensearch/_types/query_dsl/SpanFieldMaskingQueryTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
...t/src/test/java/org/opensearch/client/opensearch/_types/query_dsl/SpanFirstQueryTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 4 additions & 2 deletions
6
...nt/src/test/java/org/opensearch/client/opensearch/_types/query_dsl/SpanNearQueryTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 3 additions & 3 deletions
6
...ent/src/test/java/org/opensearch/client/opensearch/_types/query_dsl/SpanNotQueryTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 4 additions & 2 deletions
6
...ient/src/test/java/org/opensearch/client/opensearch/_types/query_dsl/SpanOrQueryTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
...client/src/test/java/org/opensearch/client/opensearch/_types/query_dsl/SpanQueryTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 3 additions & 3 deletions
6
.../src/test/java/org/opensearch/client/opensearch/_types/query_dsl/SpanWithinQueryTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
.../src/test/java/org/opensearch/client/opensearch/_types/query_dsl/TermsQueryFieldTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
java-client/src/test/java/org/opensearch/client/opensearch/core/ClearScrollRequestTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
java-client/src/test/java/org/opensearch/client/opensearch/core/MsearchRequestTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 4 additions & 2 deletions
6
...lient/src/test/java/org/opensearch/client/opensearch/core/MsearchTemplateRequestTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 dislike the whole
check-jdk8-compatibility=true
business. Why do we need this at all and not just 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.
That the thing, the
JavaVersion.current()
is the version Gradle run with, it is always 11 or higher. I will try to experiment with toolchains here (alternatively, we could make all tests JDK-8 compatible and that would eliminate the conditional part)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.
Ok, I see.
Maybe we could improve on this by introducing optional
JAVA_TOOLCHAIN_VERSION
and default it to 11. Basically avoiding this wholeif
logic?Stepping back, this does seem to work, so we should merge it and improve it later if you can't come up with something a lot nicer. Leave some TODOs with an explanation at the least?
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 a good idea, thanks @dblock , I refactored it to use similar to OpenSearch core approach with
runtime.java
version.