Skip to content

Commit

Permalink
Refactor integTest java version handling logic for all distributions (o…
Browse files Browse the repository at this point in the history
…pensearch-project#314)

Signed-off-by: Peter Zhu <[email protected]>
  • Loading branch information
peterzhuamazon authored Sep 15, 2023
1 parent 96b32c7 commit 63eb337
Show file tree
Hide file tree
Showing 8 changed files with 63 additions and 56 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ jacocoTestReport {
}
}

String version = '5.9.0'
String version = '5.9.1'

task updateVersion {
doLast {
Expand Down
62 changes: 31 additions & 31 deletions tests/jenkins/TestRunIntegTestScript.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@ class TestRunIntegTestScript extends BuildPipelineTest {
@Test
public void TestRunIntegTestScript() {
this.registerLibTester(new RunIntegTestScriptLibTester(
'dummy_job',
'OpenSearch',
'tests/data/opensearch-1.3.0-build.yml',
'tests/data/opensearch-1.3.0-test.yml',
'',
'',
'dummy_job',
'OpenSearch',
'tests/data/opensearch-1.3.0-build.yml',
'tests/data/opensearch-1.3.0-test.yml',
'',
'',
)
)
super.setUp()
Expand All @@ -37,12 +37,12 @@ class TestRunIntegTestScript extends BuildPipelineTest {
@Test
public void TestRunIntegTestScript_OpenSearch_Dashboards() {
this.registerLibTester(new RunIntegTestScriptLibTester(
'dummy_job',
'functionalTestDashboards',
'tests/data/opensearch-dashboards-1.2.0-build.yml',
'tests/data/opensearch-dashboards-1.2.0-test.yml',
'',
'',
'dummy_job',
'functionalTestDashboards',
'tests/data/opensearch-dashboards-1.2.0-build.yml',
'tests/data/opensearch-dashboards-1.2.0-test.yml',
'',
'',
)
)
super.setUp()
Expand All @@ -52,12 +52,12 @@ class TestRunIntegTestScript extends BuildPipelineTest {
@Test
public void TestRunIntegTestScript_LocalPath() {
this.registerLibTester(new RunIntegTestScriptLibTester(
'dummy_job',
'OpenSearch',
'tests/data/opensearch-1.3.0-build.yml',
'tests/data/opensearch-1.3.0-test.yml',
'tests/jenkins/artifacts/tar',
'',
'dummy_job',
'OpenSearch-Dashboards',
'tests/data/opensearch-dashboards-1.2.0-build.yml',
'tests/data/opensearch-dashboards-1.2.0-test.yml',
'tests/jenkins/artifacts/tar',
'',
)
)
super.setUp()
Expand All @@ -67,12 +67,12 @@ class TestRunIntegTestScript extends BuildPipelineTest {
@Test
public void TestRunIntegTestScript_LocalPath_Switch_Non_Root() {
this.registerLibTester(new RunIntegTestScriptLibTester(
'distribution-build-opensearch',
'OpenSearch',
'tests/data/opensearch-1.3.0-build.yml',
'tests/data/opensearch-1.3.0-test.yml',
'tests/jenkins/artifacts/tar',
'true',
'dummy_job',
'OpenSearch',
'tests/data/opensearch-1.3.0-build.yml',
'tests/data/opensearch-1.3.0-test.yml',
'tests/jenkins/artifacts/tar',
'true',
)
)
super.setUp()
Expand Down Expand Up @@ -100,28 +100,28 @@ class TestRunIntegTestScript extends BuildPipelineTest {
void 'IntegTest LocalPath SwitchNonRoot=false'() {
this.registerLibTester(new RunIntegTestScriptLibTester(
'dummy_job',
'OpenSearch',
'tests/data/opensearch-1.3.0-build.yml',
'tests/data/opensearch-1.3.0-test.yml',
'OpenSearch-Dashboards',
'tests/data/opensearch-dashboards-1.2.0-build.yml',
'tests/data/opensearch-dashboards-1.2.0-test.yml',
'tests/jenkins/artifacts/tar',
'false'
'false',
)
)
super.setUp()
runScript("tests/jenkins/jobs/RunIntegTestScript_LocalPath_Jenkinsfile")
assertThat(getShellCommands('sh', 'test.sh'), hasItems('env PATH=$PATH ./test.sh integ-test tests/data/opensearch-1.3.0-test.yml --component OpenSearch --test-run-id 987 --paths opensearch=tests/jenkins/artifacts/tar --base-path https://dummy_link/dummy_integ_test/1.3.0/c3ff7a232d25403fa8cc14c97799c323/linux/x64/tar '))
assertThat(getShellCommands('sh', 'test.sh'), hasItems('env PATH=$PATH ./test.sh integ-test tests/data/opensearch-dashboards-1.2.0-test.yml --component OpenSearch-Dashboards --test-run-id 987 --paths opensearch=tests/jenkins/artifacts/tar opensearch-dashboards=tests/jenkins/artifacts/tar --base-path https://dummy_link/dummy_integ_test/1.2.0/215/linux/x64/tar '))

}

@Test
void 'IntegTest LocalPath SwitchNonRoot=true with JAVA_HOME'() {
this.registerLibTester(new RunIntegTestScriptLibTester(
'distribution-build-opensearch',
'dummy_job',
'OpenSearch',
'tests/data/opensearch-1.3.0-build.yml',
'tests/data/opensearch-1.3.0-test.yml',
'tests/jenkins/artifacts/tar',
'true'
'true',
)
)
super.setUp()
Expand Down
13 changes: 10 additions & 3 deletions tests/jenkins/jobs/RunIntegTestScript_Jenkinsfile.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,14 @@
BuildManifest.getDistribution()
BuildManifest.getArtifactPlatform()
runIntegTestScript.echo(Start integTest on: tar x64 linux)
runIntegTestScript.echo(Possible Java Home: )
runIntegTestScript.detectTestDockerAgent({testManifest=tests/data/opensearch-1.3.0-test.yml})
detectTestDockerAgent.legacySCM(groovy.lang.Closure)
detectTestDockerAgent.library({identifier=jenkins@main, retriever=null})
detectTestDockerAgent.readYaml({file=tests/data/opensearch-1.3.0-test.yml})
TestManifest.asBoolean()
detectTestDockerAgent.echo(Using Docker image opensearchstaging/ci-runner:ci-runner-centos7-v1 (-e JAVA_HOME=/opt/java/openjdk-11))
detectTestDockerAgent.echo(Using java version openjdk-11)
runIntegTestScript.echo(Possible Java Home: JAVA_HOME=/opt/java/openjdk-11)
runIntegTestScript.echo(Build Id: c3ff7a232d25403fa8cc14c97799c323)
BuildManifest.getArtifactRootUrl(dummy_job, c3ff7a232d25403fa8cc14c97799c323)
runIntegTestScript.echo(Artifact root URL: https://ci.opensearch.org/ci/dbc/dummy_job/1.3.0/c3ff7a232d25403fa8cc14c97799c323/linux/x64/tar)
Expand All @@ -21,5 +28,5 @@
runIntegTestScript.echo(Base Path https://dummy_link/dummy_integ_test/1.3.0/c3ff7a232d25403fa8cc14c97799c323/linux/x64/tar)
runIntegTestScript.echo(Component: OpenSearch)
runIntegTestScript.echo(Switch User to Non-Root (uid=1000): false)
runIntegTestScript.echo(Run command: env PATH=$PATH ./test.sh integ-test tests/data/opensearch-1.3.0-test.yml --component OpenSearch --test-run-id 987 --paths opensearch=https://ci.opensearch.org/ci/dbc/dummy_job/1.3.0/c3ff7a232d25403fa8cc14c97799c323/linux/x64/tar --base-path https://dummy_link/dummy_integ_test/1.3.0/c3ff7a232d25403fa8cc14c97799c323/linux/x64/tar )
runIntegTestScript.sh(env PATH=$PATH ./test.sh integ-test tests/data/opensearch-1.3.0-test.yml --component OpenSearch --test-run-id 987 --paths opensearch=https://ci.opensearch.org/ci/dbc/dummy_job/1.3.0/c3ff7a232d25403fa8cc14c97799c323/linux/x64/tar --base-path https://dummy_link/dummy_integ_test/1.3.0/c3ff7a232d25403fa8cc14c97799c323/linux/x64/tar )
runIntegTestScript.echo(Run command: env PATH=$PATH JAVA_HOME=/opt/java/openjdk-11 ./test.sh integ-test tests/data/opensearch-1.3.0-test.yml --component OpenSearch --test-run-id 987 --paths opensearch=https://ci.opensearch.org/ci/dbc/dummy_job/1.3.0/c3ff7a232d25403fa8cc14c97799c323/linux/x64/tar --base-path https://dummy_link/dummy_integ_test/1.3.0/c3ff7a232d25403fa8cc14c97799c323/linux/x64/tar )
runIntegTestScript.sh(env PATH=$PATH JAVA_HOME=/opt/java/openjdk-11 ./test.sh integ-test tests/data/opensearch-1.3.0-test.yml --component OpenSearch --test-run-id 987 --paths opensearch=https://ci.opensearch.org/ci/dbc/dummy_job/1.3.0/c3ff7a232d25403fa8cc14c97799c323/linux/x64/tar --base-path https://dummy_link/dummy_integ_test/1.3.0/c3ff7a232d25403fa8cc14c97799c323/linux/x64/tar )
6 changes: 3 additions & 3 deletions tests/jenkins/jobs/RunIntegTestScript_LocalPath_Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ pipeline {
script {
runIntegTestScript(
jobName: 'dummy_job',
componentName: 'OpenSearch',
buildManifest: 'tests/data/opensearch-1.3.0-build.yml',
testManifest: 'tests/data/opensearch-1.3.0-test.yml',
componentName: 'OpenSearch-Dashboards',
buildManifest: 'tests/data/opensearch-dashboards-1.2.0-build.yml',
testManifest: 'tests/data/opensearch-dashboards-1.2.0-test.yml',
localPath: 'tests/jenkins/artifacts/tar',
)
}
Expand Down
20 changes: 10 additions & 10 deletions tests/jenkins/jobs/RunIntegTestScript_LocalPath_Jenkinsfile.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,23 @@
RunIntegTestScript_LocalPath_Jenkinsfile.echo(Executing on agent [label:none])
RunIntegTestScript_LocalPath_Jenkinsfile.stage(integ-test, groovy.lang.Closure)
RunIntegTestScript_LocalPath_Jenkinsfile.script(groovy.lang.Closure)
RunIntegTestScript_LocalPath_Jenkinsfile.runIntegTestScript({jobName=dummy_job, componentName=OpenSearch, buildManifest=tests/data/opensearch-1.3.0-build.yml, testManifest=tests/data/opensearch-1.3.0-test.yml, localPath=tests/jenkins/artifacts/tar})
RunIntegTestScript_LocalPath_Jenkinsfile.runIntegTestScript({jobName=dummy_job, componentName=OpenSearch-Dashboards, buildManifest=tests/data/opensearch-dashboards-1.2.0-build.yml, testManifest=tests/data/opensearch-dashboards-1.2.0-test.yml, localPath=tests/jenkins/artifacts/tar})
runIntegTestScript.legacySCM(groovy.lang.Closure)
runIntegTestScript.library({identifier=jenkins@main, retriever=null})
runIntegTestScript.readYaml({file=tests/data/opensearch-1.3.0-build.yml})
runIntegTestScript.readYaml({file=tests/data/opensearch-dashboards-1.2.0-build.yml})
BuildManifest.asBoolean()
BuildManifest.getArtifactArchitecture()
BuildManifest.getDistribution()
BuildManifest.getArtifactPlatform()
runIntegTestScript.echo(Start integTest on: tar x64 linux)
runIntegTestScript.echo(Possible Java Home: )
runIntegTestScript.echo(Build Id: c3ff7a232d25403fa8cc14c97799c323)
BuildManifest.getArtifactRootUrl(dummy_job, c3ff7a232d25403fa8cc14c97799c323)
runIntegTestScript.echo(Artifact root URL: https://ci.opensearch.org/ci/dbc/dummy_job/1.3.0/c3ff7a232d25403fa8cc14c97799c323/linux/x64/tar)
runIntegTestScript.echo(Build Id: 215)
BuildManifest.getArtifactRootUrl(dummy_job, 215)
runIntegTestScript.echo(Artifact root URL: https://ci.opensearch.org/ci/dbc/dummy_job/1.2.0/215/linux/x64/tar)
runIntegTestScript.echo(User provides localPath, use local artifacts: tests/jenkins/artifacts/tar)
runIntegTestScript.echo(Paths: opensearch=tests/jenkins/artifacts/tar)
runIntegTestScript.echo(Base Path https://dummy_link/dummy_integ_test/1.3.0/c3ff7a232d25403fa8cc14c97799c323/linux/x64/tar)
runIntegTestScript.echo(Component: OpenSearch)
runIntegTestScript.echo(Paths: opensearch=tests/jenkins/artifacts/tar opensearch-dashboards=tests/jenkins/artifacts/tar)
runIntegTestScript.echo(Base Path https://dummy_link/dummy_integ_test/1.2.0/215/linux/x64/tar)
runIntegTestScript.echo(Component: OpenSearch-Dashboards)
runIntegTestScript.echo(Switch User to Non-Root (uid=1000): false)
runIntegTestScript.echo(Run command: env PATH=$PATH ./test.sh integ-test tests/data/opensearch-1.3.0-test.yml --component OpenSearch --test-run-id 987 --paths opensearch=tests/jenkins/artifacts/tar --base-path https://dummy_link/dummy_integ_test/1.3.0/c3ff7a232d25403fa8cc14c97799c323/linux/x64/tar )
runIntegTestScript.sh(env PATH=$PATH ./test.sh integ-test tests/data/opensearch-1.3.0-test.yml --component OpenSearch --test-run-id 987 --paths opensearch=tests/jenkins/artifacts/tar --base-path https://dummy_link/dummy_integ_test/1.3.0/c3ff7a232d25403fa8cc14c97799c323/linux/x64/tar )
runIntegTestScript.echo(Run command: env PATH=$PATH ./test.sh integ-test tests/data/opensearch-dashboards-1.2.0-test.yml --component OpenSearch-Dashboards --test-run-id 987 --paths opensearch=tests/jenkins/artifacts/tar opensearch-dashboards=tests/jenkins/artifacts/tar --base-path https://dummy_link/dummy_integ_test/1.2.0/215/linux/x64/tar )
runIntegTestScript.sh(env PATH=$PATH ./test.sh integ-test tests/data/opensearch-dashboards-1.2.0-test.yml --component OpenSearch-Dashboards --test-run-id 987 --paths opensearch=tests/jenkins/artifacts/tar opensearch-dashboards=tests/jenkins/artifacts/tar --base-path https://dummy_link/dummy_integ_test/1.2.0/215/linux/x64/tar )
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ pipeline {
steps {
script {
runIntegTestScript(
jobName: 'distribution-build-opensearch',
jobName: 'dummy_job',
componentName: 'OpenSearch',
buildManifest: 'tests/data/opensearch-1.3.0-build.yml',
testManifest: 'tests/data/opensearch-1.3.0-test.yml',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
RunIntegTestScript_LocalPath_Switch_Non_Root_Jenkinsfile.echo(Executing on agent [label:none])
RunIntegTestScript_LocalPath_Switch_Non_Root_Jenkinsfile.stage(integ-test, groovy.lang.Closure)
RunIntegTestScript_LocalPath_Switch_Non_Root_Jenkinsfile.script(groovy.lang.Closure)
RunIntegTestScript_LocalPath_Switch_Non_Root_Jenkinsfile.runIntegTestScript({jobName=distribution-build-opensearch, componentName=OpenSearch, buildManifest=tests/data/opensearch-1.3.0-build.yml, testManifest=tests/data/opensearch-1.3.0-test.yml, localPath=tests/jenkins/artifacts/tar, switchUserNonRoot=true})
RunIntegTestScript_LocalPath_Switch_Non_Root_Jenkinsfile.runIntegTestScript({jobName=dummy_job, componentName=OpenSearch, buildManifest=tests/data/opensearch-1.3.0-build.yml, testManifest=tests/data/opensearch-1.3.0-test.yml, localPath=tests/jenkins/artifacts/tar, switchUserNonRoot=true})
runIntegTestScript.legacySCM(groovy.lang.Closure)
runIntegTestScript.library({identifier=jenkins@main, retriever=null})
runIntegTestScript.readYaml({file=tests/data/opensearch-1.3.0-build.yml})
Expand All @@ -21,8 +21,8 @@
detectTestDockerAgent.echo(Using java version openjdk-11)
runIntegTestScript.echo(Possible Java Home: JAVA_HOME=/opt/java/openjdk-11)
runIntegTestScript.echo(Build Id: c3ff7a232d25403fa8cc14c97799c323)
BuildManifest.getArtifactRootUrl(distribution-build-opensearch, c3ff7a232d25403fa8cc14c97799c323)
runIntegTestScript.echo(Artifact root URL: https://ci.opensearch.org/ci/dbc/distribution-build-opensearch/1.3.0/c3ff7a232d25403fa8cc14c97799c323/linux/x64/tar)
BuildManifest.getArtifactRootUrl(dummy_job, c3ff7a232d25403fa8cc14c97799c323)
runIntegTestScript.echo(Artifact root URL: https://ci.opensearch.org/ci/dbc/dummy_job/1.3.0/c3ff7a232d25403fa8cc14c97799c323/linux/x64/tar)
runIntegTestScript.echo(User provides localPath, use local artifacts: tests/jenkins/artifacts/tar)
runIntegTestScript.echo(Paths: opensearch=tests/jenkins/artifacts/tar)
runIntegTestScript.echo(Base Path https://dummy_link/dummy_integ_test/1.3.0/c3ff7a232d25403fa8cc14c97799c323/linux/x64/tar)
Expand Down
8 changes: 4 additions & 4 deletions vars/runIntegTestScript.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@ void call(Map args = [:]) {
String architecture = buildManifest.getArtifactArchitecture()
String distribution = buildManifest.getDistribution()
String platform = buildManifest.getArtifactPlatform()
String filename = buildManifest.build.getFilename()
echo "Start integTest on: " + distribution + " " + architecture + " " + platform

def javaVersion = (jobName.equals('distribution-build-opensearch')) ? detectTestDockerAgent(testManifest: args.testManifest).javaVersion : ''
String javaHomeCommand = (jobName.equals('distribution-build-opensearch') && ! javaVersion.equals('')) ? "JAVA_HOME=/opt/java/${javaVersion}" : ''
if (platform.equals('windows')) { // Windows use scoop to switch the Java Version
def javaVersion = (filename == 'opensearch') ? detectTestDockerAgent(testManifest: args.testManifest).javaVersion : ''
String javaHomeCommand = (javaVersion != '' && platform != 'windows') ? "JAVA_HOME=/opt/java/${javaVersion}" : ''
if (filename == 'opensearch' && platform == 'windows') { // Windows use scoop to switch the Java Version
String javaVersionNumber = javaVersion.replaceAll("[^0-9]", "") // Only get number
echo("Switching to Java ${javaVersionNumber} on Windows Docker Container")
sh("scoop reset `scoop list jdk | grep ${javaVersionNumber} | head -1 | cut -d ' ' -f1`")
javaHomeCommand = ''
}
echo "Possible Java Home: ${javaHomeCommand}"

Expand Down

0 comments on commit 63eb337

Please sign in to comment.