-
Notifications
You must be signed in to change notification settings - Fork 37
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 integration test with a given Java version and vendor #1749
Conversation
879575b
to
d10c9d5
Compare
d10c9d5
to
affa33c
Compare
.github/workflows/ci.yaml
Outdated
@@ -1,19 +1,44 @@ | |||
name: CI | |||
run-name: "${{ github.event_name == 'workflow_dispatch' && format('Dispatch : Run integration test with JDK {0} ({1})', inputs.int_test_java_version, inputs.int_test_java_vendor) || '' }}" |
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.
When the workflow is triggered manually, set a specific name to identify which SDK version and vendor were used to run the integration test.
It uses a ternary operator syntax explained here
.github/workflows/ci.yaml
Outdated
inputs: | ||
int_test_java_version: | ||
description: JDK version used to run the integration test | ||
type: choice | ||
required: false | ||
default: '8' | ||
options: | ||
- '8' | ||
- '11' | ||
- '17' | ||
- '21' | ||
int_test_java_vendor: | ||
description: Vendor of the JDK used to run the integration test | ||
type: choice | ||
required: false | ||
default: 'temurin' | ||
options: | ||
- 'corretto' | ||
- 'microsoft' | ||
- 'oracle' | ||
- 'temurin' |
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.
The parameters when triggering the workflow manually to select the JDK version and vendor for the integration test.
.github/workflows/ci.yaml
Outdated
- name: Setup and execute Gradle 'integrationTestCassandra' task | ||
uses: gradle/gradle-build-action@v3 | ||
with: | ||
arguments: integrationTestCassandra | ||
arguments: integrationTestCassandra -PcompilationJavaVendor=temurin -PintegrationTestJavaVersion=${{ env.INT_TEST_JAVA_VERSION }} -PintegrationTestJavaVendor=${{ env.INT_TEST_JAVA_VENDOR }} |
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.
Always set the compilation vendor to temurin with -PcompilationJavaVendor=temurin
to avoid nondeterministic behavior if the integration test uses the JDK 8 with another vendor.
* gradle integrationTestJdbc -PcompilationJavaVendor=amazon -PintegrationTestJavaVersion=11 -PintegrationJavaVendor=temurin | ||
* </code></pre> | ||
*/ | ||
public class JdkConfigurationPlugin implements Plugin<Project> { |
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 Gradle plugin used to configure the compilation and integration test tasks to use a given SDK configured through Gradle properties.
Instead of writing a plugin, I could have added logic directly in build.gradle
files but it was easier to develop that way and our build.gradle
files are already complicated enough.
task integrationTestCassandra(type: Test) { | ||
description = 'Runs the integration tests for Cassandra.' | ||
group = 'verification' | ||
testClassesDirs = sourceSets.integrationTestCassandra.output.classesDirs | ||
classpath = sourceSets.integrationTestCassandra.runtimeClasspath | ||
outputs.upToDateWhen { false } // ensures integration tests are run every time when called | ||
options { | ||
systemProperties(System.getProperties()) | ||
systemProperties(System.getProperties().findAll{it.key.toString().startsWith("scalardb")}) |
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.
When running the integration test with Java 9 but using Java 8 to run IDEA, some Java 8 environment properties were unwillingly added by IDEA that caused the test to crash, so I restricted only to passing properties starting with scalardb
@@ -1,5 +1,5 @@ | |||
distributionBase=GRADLE_USER_HOME | |||
distributionPath=wrapper/dists | |||
distributionUrl=https\://services.gradle.org/distributions/gradle-7.0.2-bin.zip | |||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip |
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.
Upgraded Gradlew to the latest stable version 8.7
schema-loader/build.gradle
Outdated
task copyFilesToDockerBuildContextDir(type: Copy) { | ||
description 'Copy files to a temporary folder to build the Docker image' | ||
dependsOn shadowJar | ||
name "ghcr.io/scalar-labs/scalardb-schema-loader:${project.version}" | ||
files tasks.shadowJar.outputs | ||
from("Dockerfile") | ||
from(tasks.shadowJar.archiveFile) | ||
into('build/docker') | ||
} | ||
|
||
task dockerfileLint(type: Exec) { | ||
description 'Lint the Dockerfile' | ||
commandLine "${project.rootDir}/ci/dockerfile_lint.sh" | ||
task docker(type: Exec) { | ||
description 'Build ScalarDB Schema Loader Docker image' | ||
dependsOn copyFilesToDockerBuildContextDir | ||
workingDir 'build/docker' | ||
commandLine 'docker', 'build', "--tag=ghcr.io/scalar-labs/scalardb-schema-loader:${project.version}", "." |
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.
The com.palantir.docker
plugin we used to build the Docker image supports the latest Gradle version but requires to use Java >=11 with Gradle, so I removed it.
Since the plugin was just a wrapper for the Docker CLI, I think we can go without it, considering our simple use of building a Docker image from a Dockerfile.
task copyFilesToDockerBuildContextDir(type: Copy) { | ||
description 'Copy files to a temporary folder to build the Docker image' | ||
dependsOn distTar | ||
from('Dockerfile') | ||
from('conf') { | ||
include 'log4j2.properties' | ||
include 'database.properties' | ||
} | ||
from('docker-entrypoint.sh') | ||
from(tasks.distTar.archiveFile) | ||
into('build/docker') | ||
} | ||
|
||
task docker(type: Exec) { | ||
description 'Build ScalarDB Server Docker image' | ||
dependsOn copyFilesToDockerBuildContextDir | ||
workingDir 'build/docker' | ||
commandLine 'docker', 'build', "--tag=ghcr.io/scalar-labs/scalardb-server:${project.version}", "." | ||
} |
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.
Likewise here
@@ -33,16 +36,24 @@ dependencies { | |||
javadoc { | |||
title = "ScalarDB Schema Loader" | |||
} | |||
task dockerfileLint(type: Exec) { |
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.
[minor] An empty line would be nice?
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.
Thank you, I revised it in 6869be5
public class JdkConfigurationPlugin implements Plugin<Project> { | ||
private static final Logger logger = LoggerFactory.getLogger(JdkConfigurationPlugin.class); | ||
|
||
private static final JavaLanguageVersion COMPILATION_JAVA_VERSION = JavaLanguageVersion.of(8); |
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 Java version for CompileJava
is fixed to 8 while Java vendor can be specified. It might be a bit confusing, considering the case that someone wants to build with Java vender oracle
and version 17
, but only the Java vender can be passed and Oracle JDK 1.8 is needed in the end.
If we want to always build JavaCompile
with temurin
JDK 1.8, I guess we can remove compilationJavaVendor
property?
Or, adding compilationJavaVersion
for consistency while we'll basically use temurin
JDK 1.8 for our CI may be an option.
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.
You are right; forcing the same Java version and vendor for compilation and building release makes sense. If so, we can remove compilationJavaVendor
Adding a compilationJavaVersion
is a possibility, but in what case do you think it is useful?
Do you want to provide this so that anybody can check out ScalarDB code without requiring Java 8 installation?
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.
Adding a compilationJavaVersion is a possibility, but in what case do you think it is useful?
I have no idea for now. For example, we might want to build our CLI applications with GraalVM to shorten the bootstrap time in the future? I'm not sure, though. I think we can simply remove compilationJavaVendor
for 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.
All right, thanks for your comment.
I will remove the compilationJavaVendor
and require the compilation task to use JDK 8 (temurin).
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 revised it in 6869be5
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.
Sorry for the late reply.
Eventually, we will use JDK 11 for compilation, so enabling it to specify a version (and vendor) for compilation might be helpful.
What do you think?
In that case, the following names might be more consistent, but this is a minor comment from my preference.
JavaCompilerVersion
JavaCompilerVendor
integrationTestJavaRuntimeVersion
integrationTestJavaRuntimeVendor
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.
You wish to set JDK 11 (temurin) as the default compiler, which can be overriden via the javaCompilerVersion
and the javaCompilerVendor
Gradle properties. Is my understanding correct?
I don't see a problem with making the compiler configurable, but as discussed above with Mitsu, we are not sure if there is really a use case for it now. Do you have something in mind?
Thank you for the naming suggestion. The naming is getting longer, but it's more consistent and correct, so I agree with it.
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.
You wish to set JDK 11 (temurin) as the default compiler, which can be overriden via the javaCompilerVersion and the javaCompilerVendor Gradle properties. Is my understanding correct?
No. Using JDK 8 (temurin) by default is fine, but I would like the compilation version to be configurable so that we don't have to update the code and ci.yaml
when we end the support for JDK 8, which might be coming soon (or might not be coming soon).
Of-course, we can update JdkConfigurationPlugin.java
to do that, but we want to avoid it if it is simply avoidable.
What do you think?
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 see. In that case, to limit changes when we switch the compiler to Java 11, in my opinion, setting the compiler version in the JdkConfigurationPlugin.java
without making it configurable with Gradle properties is still the best course of action.
In any scenario, we can't avoid making changes, but not having a configurable compiler only requires slight changes when switching to Java 11.
If we compare the impact of making the JDK configurable or not and then switching to Java 11:
- Without a configurable JDK, we need to:
- in the CI file, replace all mentions of JDK 8 by JDK 11
- update a single variable in the
JdkConfigurationPlugin.java
- With a configurable JDK, we need to :
- in the CI file, replace all mentions of JDK 8 by JDK 11
- we will need to add
-PjavaCompilerVersion=11 -PjavaCompilerVendor=temurin
every time we use gradle, which yields poor usability. We also need to add the same parameters for each gradle job in the CI too, which is a bit verbose. - increase the
JdkConfigurationPlugin.java
complexity since we need to parse properties to configure the compiler.
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.
@feeblefakie @brfrn169
Per our offline discussion, I will :
- In the Gradle build, make the compiler version and vendor configurable with Gradle properties
- refactor the CI to use global variables that define the compiler version and vendor to remove the hardcoded usage of
Java 8 temurin
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.
LGTM! Thank you!
buildSrc/build.gradle
Outdated
@@ -0,0 +1,26 @@ | |||
plugins { | |||
id 'java-gradle-plugin' | |||
id "com.diffplug.spotless" version "6.13.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.
Small nit:
id "com.diffplug.spotless" version "6.13.0" | |
id 'com.diffplug.spotless' version '6.13.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.
Thank you.
I revised it in 6869be5
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.
LGTM! Thank you!
…alardb into run_int_test_with_any_jdk
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.
LGTM, thank you!
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.
Overall, looking good.
Left one comment and suggestion. PTAL!
public class JdkConfigurationPlugin implements Plugin<Project> { | ||
private static final Logger logger = LoggerFactory.getLogger(JdkConfigurationPlugin.class); | ||
|
||
private static final JavaLanguageVersion COMPILATION_JAVA_VERSION = JavaLanguageVersion.of(8); |
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.
Sorry for the late reply.
Eventually, we will use JDK 11 for compilation, so enabling it to specify a version (and vendor) for compilation might be helpful.
What do you think?
In that case, the following names might be more consistent, but this is a minor comment from my preference.
JavaCompilerVersion
JavaCompilerVendor
integrationTestJavaRuntimeVersion
integrationTestJavaRuntimeVendor
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.
LGTM! Thank you!
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.
LGTM, thank you!
# Conflicts: # .github/workflows/ci.yaml # server/build.gradle
# Conflicts: # .github/workflows/ci.yaml # server/build.gradle
# Conflicts: # .github/workflows/ci.yaml # build.gradle # server/build.gradle
Description
To verify that ScalarDB is compatible with JDK with version >8, we can now determine which SDK version and vendor (any version and vendors are possible) are used to run the integration test.
Additionally, when triggering the CI manually, we can determine the JDK LTS version (8, 11, 17, or 21) and vendor (Temurin, Oracle, Microsoft, or Amazon) used to run the integration test.
Related issues and/or PRs
N/A
Changes made
-compilationJavaVendor
: configure the SDK vendor used by compilation tasksintegrationTestJavaVersion
: configure all tasks name starting with "integrationTest" to run with the given SDK versionintegrationTestJavaVendor
: configure all tasks name starting with "integrationTest" to run with the given SDK vendorGradle will search the system for a JDK that matches the criteria; if Gradle cannot detect the desired SDK, please refer to the Gradle Toolchain documentation.
com.palentir.docker
plugin and call directly the Docker cli fordocker
taskbase
plugin configuration to reduce deprecation warnings.Checklist
Additional notes (optional)
N/A
Release notes
N/A