diff --git a/.github/workflows/version-increment.yml b/.github/workflows/version-increment.yml index 025f133e..9e803e6c 100644 --- a/.github/workflows/version-increment.yml +++ b/.github/workflows/version-increment.yml @@ -33,7 +33,7 @@ jobs: uses: peter-evans/create-pull-request@v4 with: token: ${{ steps.github_app_token.outputs.token }} - base: '7.x' + base: '8.x' committer: opensearch-ci-bot author: opensearch-ci-bot commit-message: | diff --git a/build.gradle b/build.gradle index 756a79fa..eb0b5c8d 100644 --- a/build.gradle +++ b/build.gradle @@ -128,7 +128,7 @@ jacocoTestReport { } } -String version = '7.3.4' +String version = '8.0.0' task updateVersion { doLast { diff --git a/tests/jenkins/TestRunIntegTestScript.groovy b/tests/jenkins/TestRunIntegTestScript.groovy index 77dd13d7..03618c91 100644 --- a/tests/jenkins/TestRunIntegTestScript.groovy +++ b/tests/jenkins/TestRunIntegTestScript.groovy @@ -46,7 +46,8 @@ class TestRunIntegTestScript extends BuildPipelineTest { ) ) super.setUp() - super.testPipeline("tests/jenkins/jobs/RunIntegTestScript_OpenSearch_Dashboards_Jenkinsfile") + runScript("tests/jenkins/jobs/RunIntegTestScript_OpenSearch_Dashboards_Jenkinsfile") + assertThat(getShellCommands('sh', 'test.sh'), hasItems('env PATH=$PATH ./test.sh integ-test manifests/tests/data/opensearch-dashboards-1.2.0-test.yml --component functionalTestDashboards --ci-group 1 --test-run-id 987 --paths opensearch=https://ci.opensearch.org/ci/dbc/distribution-build-opensearch/1.2.0/latest/linux/x64/tar opensearch-dashboards=https://ci.opensearch.org/ci/dbc/dummy_job/1.2.0/215/linux/x64/tar --base-path https://dummy_link/dummy_integ_test/1.2.0/215/linux/x64/tar ')) } @Test @@ -92,7 +93,7 @@ class TestRunIntegTestScript extends BuildPipelineTest { ) super.setUp() runScript("tests/jenkins/jobs/RunIntegTestScript_Windows_Jenkinsfile") - assertThat(getShellCommands('sh', 'test.sh'), hasItems('env PATH=$PATH ./test.sh integ-test tests/data/opensearch-2.8.0-test.yml --component OpenSearch --test-run-id 987 --paths opensearch=https://ci.opensearch.org/ci/dbc/dummy_job/2.8.0/7923/windows/x64/zip --base-path https://dummy_link/dummy_integ_test/2.8.0/7923/windows/x64/zip ')) + assertThat(getShellCommands('sh', 'test.sh'), hasItems('env PATH=$PATH ./test.sh integ-test manifests/tests/data/opensearch-2.8.0-test.yml --component OpenSearch --test-run-id 987 --paths opensearch=https://ci.opensearch.org/ci/dbc/dummy_job/2.8.0/7923/windows/x64/zip --base-path https://dummy_link/dummy_integ_test/2.8.0/7923/windows/x64/zip ')) } @@ -109,7 +110,7 @@ class TestRunIntegTestScript extends BuildPipelineTest { ) 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-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 ')) + assertThat(getShellCommands('sh', 'test.sh'), hasItems('env PATH=$PATH ./test.sh integ-test manifests/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 ')) } @@ -126,7 +127,7 @@ class TestRunIntegTestScript extends BuildPipelineTest { ) super.setUp() runScript("tests/jenkins/jobs/RunIntegTestScript_LocalPath_Switch_Non_Root_Jenkinsfile") - assertThat(getShellCommands('sh', 'test.sh'), hasItems('su `id -un 1000` -c \"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=tests/jenkins/artifacts/tar --base-path https://dummy_link/dummy_integ_test/1.3.0/29/linux/x64/tar \"')) + assertThat(getShellCommands('sh', 'test.sh'), hasItems('su `id -un 1000` -c \"env PATH=$PATH JAVA_HOME=/opt/java/openjdk-11 ./test.sh integ-test manifests/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/29/linux/x64/tar \"')) } diff --git a/tests/jenkins/TestRunIntegTestScriptForOSD.groovy b/tests/jenkins/TestRunIntegTestScriptForOSD.groovy new file mode 100644 index 00000000..4130e5e2 --- /dev/null +++ b/tests/jenkins/TestRunIntegTestScriptForOSD.groovy @@ -0,0 +1,69 @@ +/* + * Copyright OpenSearch Contributors + * SPDX-License-Identifier: Apache-2.0 + * + * The OpenSearch Contributors require contributions made to + * this file be licensed under the Apache-2.0 license or a + * compatible open source license. + */ + +package jenkins.tests + +import org.junit.Test +import static com.lesfurets.jenkins.unit.MethodCall.callArgsToString +import static org.hamcrest.CoreMatchers.hasItems +import static org.hamcrest.MatcherAssert.assertThat + +class TestRunIntegTestScriptForOSD extends BuildPipelineTest { + + @Test + public void TestRunProcessScript() { + this.registerLibTester(new RunIntegTestScriptForOSDLibTester( + 'reportsDashboard', + '', + 'false', + 'dummy/path/opensearch', + 'test-bucket', + 'dummy/artifact/path', + 'x64', + 'tests/data/opensearch-1.3.0-build.yml', + 'tests/data/opensearch-1.3.0-test.yml' + ) + ) + super.setUp() + super.testPipeline("tests/jenkins/jobs/RunIntegTestScriptForOSD_Jenkinsfile") + runScript("tests/jenkins/jobs/RunIntegTestScriptForOSD_Jenkinsfile") + assertThat(getShellCommands('sh', 'test.sh'), hasItems('env PATH=$PATH JAVA_HOME=/opt/java/openjdk-11 ./test.sh integ-test manifests/tests/data/opensearch-1.3.0-test.yml --component reportsDashboard --test-run-id null --paths opensearch=/home/user/x64 --base-path null/null/1.3.0/29/linux/x64/tar ')) + } + + @Test + public void TestRunProcessScriptWithoutCiGroup() { + this.registerLibTester(new RunIntegTestScriptForOSDLibTester( + 'OpenSearch-Dashboards', + '1', + 'false', + 'dummy/path/opensearch', + 'test-bucket', + 'dummy/artifact/path', + 'x64', + 'tests/data/opensearch-1.3.0-build.yml', + 'tests/data/opensearch-1.3.0-test.yml' + ) + ) + super.setUp() + super.testPipeline("tests/jenkins/jobs/RunIntegTestScriptForOSDCiGroup_Jenkinsfile") + runScript("tests/jenkins/jobs/RunIntegTestScriptForOSDCiGroup_Jenkinsfile") + assertThat(getShellCommands('sh','test.sh'), hasItems('env PATH=$PATH JAVA_HOME=/opt/java/openjdk-11 ./test.sh integ-test manifests/tests/data/opensearch-1.3.0-test.yml --component OpenSearch-Dashboards --ci-group 1 --test-run-id null --paths opensearch=/home/user/x64 --base-path null/null/1.3.0/29/linux/x64/tar ')) + } + + def getShellCommands(methodName, searchString) { + def shCommands = helper.callStack.findAll { call -> + call.methodName == methodName + }.collect { call -> + callArgsToString(call) + }.findAll { command -> + command.contains(searchString) + } + return shCommands + } +} diff --git a/tests/jenkins/jobs/ProcessAndRunOsdIntegTestCiGroup_Jenkinsfile.txt b/tests/jenkins/jobs/ProcessAndRunOsdIntegTestCiGroup_Jenkinsfile.txt new file mode 100644 index 00000000..a6bb3991 --- /dev/null +++ b/tests/jenkins/jobs/ProcessAndRunOsdIntegTestCiGroup_Jenkinsfile.txt @@ -0,0 +1,38 @@ + ProcessAndRunOsdIntegTestCiGroup_Jenkinsfile.run() + ProcessAndRunOsdIntegTestCiGroup_Jenkinsfile.pipeline(groovy.lang.Closure) + ProcessAndRunOsdIntegTestCiGroup_Jenkinsfile.echo(Executing on agent [label:none]) + ProcessAndRunOsdIntegTestCiGroup_Jenkinsfile.stage(integ-test, groovy.lang.Closure) + ProcessAndRunOsdIntegTestCiGroup_Jenkinsfile.script(groovy.lang.Closure) + ProcessAndRunOsdIntegTestCiGroup_Jenkinsfile.processAndRunOsdIntegTest({localComponent=OpenSearch-Dashboards, ciGroup=1, switchUserNonRoot=false}) + processAndRunOsdIntegTest.legacySCM(groovy.lang.Closure) + processAndRunOsdIntegTest.library({identifier=jenkins@main, retriever=null}) + processAndRunOsdIntegTest.unstash(integtest-opensearch-dashboards-307) + processAndRunOsdIntegTest.echo(Not on Windows, unstash repository+artifacts) + processAndRunOsdIntegTest.sh(rm -rf test-results) + processAndRunOsdIntegTest.runIntegTestScript({jobName=dummy-integ-test, componentName=OpenSearch-Dashboards, buildManifest=tests/data/opensearch-1.3.0-build.yml, testManifest=tests/data/opensearch-1.3.0-test.yml, localPath=/home/user/x64, switchUserNonRoot=false, ciGroup=1}) + runIntegTestScript.legacySCM(groovy.lang.Closure) + runIntegTestScript.library({identifier=jenkins@main, retriever=null}) + runIntegTestScript.readYaml({file=tests/data/opensearch-1.3.0-build.yml}) + BuildManifest.asBoolean() + BuildManifest.getArtifactArchitecture() + BuildManifest.getDistribution() + BuildManifest.getArtifactPlatform() + runIntegTestScript.echo(Start integTest on: tar x64 linux) + 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: 29) + BuildManifest.getArtifactRootUrl(dummy-integ-test, 29) + runIntegTestScript.echo(Artifact root URL: https://ci.opensearch.org/ci/dbc/dummy-integ-test/1.3.0/29/linux/x64/tar) + runIntegTestScript.echo(User provides localPath, use local artifacts: /home/user/x64) + runIntegTestScript.echo(Paths: opensearch=/home/user/x64) + runIntegTestScript.echo(Base Path null/null/1.3.0/29/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 JAVA_HOME=/opt/java/openjdk-11 ./test.sh integ-test manifests/tests/data/opensearch-1.3.0-test.yml --component OpenSearch-Dashboards --ci-group 1 --test-run-id null --paths opensearch=/home/user/x64 --base-path null/null/1.3.0/29/linux/x64/tar ) + runIntegTestScript.sh(env PATH=$PATH JAVA_HOME=/opt/java/openjdk-11 ./test.sh integ-test manifests/tests/data/opensearch-1.3.0-test.yml --component OpenSearch-Dashboards --ci-group 1 --test-run-id null --paths opensearch=/home/user/x64 --base-path null/null/1.3.0/29/linux/x64/tar ) diff --git a/tests/jenkins/jobs/ProcessAndRunOsdIntegTest_Jenkinsfile.txt b/tests/jenkins/jobs/ProcessAndRunOsdIntegTest_Jenkinsfile.txt new file mode 100644 index 00000000..e3e7993a --- /dev/null +++ b/tests/jenkins/jobs/ProcessAndRunOsdIntegTest_Jenkinsfile.txt @@ -0,0 +1,38 @@ + ProcessAndRunOsdIntegTest_Jenkinsfile.run() + ProcessAndRunOsdIntegTest_Jenkinsfile.pipeline(groovy.lang.Closure) + ProcessAndRunOsdIntegTest_Jenkinsfile.echo(Executing on agent [label:none]) + ProcessAndRunOsdIntegTest_Jenkinsfile.stage(integ-test, groovy.lang.Closure) + ProcessAndRunOsdIntegTest_Jenkinsfile.script(groovy.lang.Closure) + ProcessAndRunOsdIntegTest_Jenkinsfile.processAndRunOsdIntegTest({localComponent=OpenSearch, ciGroup=, switchUserNonRoot=false}) + processAndRunOsdIntegTest.legacySCM(groovy.lang.Closure) + processAndRunOsdIntegTest.library({identifier=jenkins@main, retriever=null}) + processAndRunOsdIntegTest.unstash(integtest-opensearch-dashboards-307) + processAndRunOsdIntegTest.echo(Not on Windows, unstash repository+artifacts) + processAndRunOsdIntegTest.sh(rm -rf test-results) + processAndRunOsdIntegTest.runIntegTestScript({jobName=dummy-integ-test, componentName=OpenSearch, buildManifest=tests/data/opensearch-1.3.0-build.yml, testManifest=tests/data/opensearch-1.3.0-test.yml, localPath=/home/user/x64, switchUserNonRoot=false, ciGroup=}) + runIntegTestScript.legacySCM(groovy.lang.Closure) + runIntegTestScript.library({identifier=jenkins@main, retriever=null}) + runIntegTestScript.readYaml({file=tests/data/opensearch-1.3.0-build.yml}) + BuildManifest.asBoolean() + BuildManifest.getArtifactArchitecture() + BuildManifest.getDistribution() + BuildManifest.getArtifactPlatform() + runIntegTestScript.echo(Start integTest on: tar x64 linux) + 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: 29) + BuildManifest.getArtifactRootUrl(dummy-integ-test, 29) + runIntegTestScript.echo(Artifact root URL: https://ci.opensearch.org/ci/dbc/dummy-integ-test/1.3.0/29/linux/x64/tar) + runIntegTestScript.echo(User provides localPath, use local artifacts: /home/user/x64) + runIntegTestScript.echo(Paths: opensearch=/home/user/x64) + runIntegTestScript.echo(Base Path null/null/1.3.0/29/linux/x64/tar) + runIntegTestScript.echo(Component: OpenSearch) + runIntegTestScript.echo(Switch User to Non-Root (uid=1000): false) + runIntegTestScript.echo(Run command: env PATH=$PATH JAVA_HOME=/opt/java/openjdk-11 ./test.sh integ-test manifests/tests/data/opensearch-1.3.0-test.yml --component OpenSearch --test-run-id null --paths opensearch=/home/user/x64 --base-path null/null/1.3.0/29/linux/x64/tar ) + runIntegTestScript.sh(env PATH=$PATH JAVA_HOME=/opt/java/openjdk-11 ./test.sh integ-test manifests/tests/data/opensearch-1.3.0-test.yml --component OpenSearch --test-run-id null --paths opensearch=/home/user/x64 --base-path null/null/1.3.0/29/linux/x64/tar ) diff --git a/tests/jenkins/jobs/RunIntegTestScriptForOSDCiGroup_Jenkinsfile b/tests/jenkins/jobs/RunIntegTestScriptForOSDCiGroup_Jenkinsfile new file mode 100644 index 00000000..d9af9e82 --- /dev/null +++ b/tests/jenkins/jobs/RunIntegTestScriptForOSDCiGroup_Jenkinsfile @@ -0,0 +1,31 @@ +/* + * Copyright OpenSearch Contributors + * SPDX-License-Identifier: Apache-2.0 + * + * The OpenSearch Contributors require contributions made to + * this file be licensed under the Apache-2.0 license or a + * compatible open source license. + */ + +pipeline { + agent none + stages { + stage('integ-test') { + steps { + script { + runIntegTestScriptForOSD( + localComponent: 'OpenSearch-Dashboards', + ciGroup: "1", + switchUserNonRoot: 'false', + artifactPathOpenSearch:'dummy/path/opensearch', + artifactBucketName:'test-bucket', + artifactPath:'dummy/artifact/path', + distribution:'x64', + buildManifest:'tests/data/opensearch-1.3.0-build.yml', + testManifest:'tests/data/opensearch-1.3.0-test.yml' + ) + } + } + } + } +} diff --git a/tests/jenkins/jobs/RunIntegTestScriptForOSDCiGroup_Jenkinsfile.txt b/tests/jenkins/jobs/RunIntegTestScriptForOSDCiGroup_Jenkinsfile.txt new file mode 100644 index 00000000..f1bcc707 --- /dev/null +++ b/tests/jenkins/jobs/RunIntegTestScriptForOSDCiGroup_Jenkinsfile.txt @@ -0,0 +1,38 @@ + RunIntegTestScriptForOSDCiGroup_Jenkinsfile.run() + RunIntegTestScriptForOSDCiGroup_Jenkinsfile.pipeline(groovy.lang.Closure) + RunIntegTestScriptForOSDCiGroup_Jenkinsfile.echo(Executing on agent [label:none]) + RunIntegTestScriptForOSDCiGroup_Jenkinsfile.stage(integ-test, groovy.lang.Closure) + RunIntegTestScriptForOSDCiGroup_Jenkinsfile.script(groovy.lang.Closure) + RunIntegTestScriptForOSDCiGroup_Jenkinsfile.runIntegTestScriptForOSD({localComponent=OpenSearch-Dashboards, ciGroup=1, switchUserNonRoot=false, artifactPathOpenSearch=dummy/path/opensearch, artifactBucketName=test-bucket, artifactPath=dummy/artifact/path, distribution=x64, buildManifest=tests/data/opensearch-1.3.0-build.yml, testManifest=tests/data/opensearch-1.3.0-test.yml}) + runIntegTestScriptForOSD.legacySCM(groovy.lang.Closure) + runIntegTestScriptForOSD.library({identifier=jenkins@main, retriever=null}) + runIntegTestScriptForOSD.unstash(integtest-opensearch-dashboards-307) + runIntegTestScriptForOSD.echo(Not on Windows, unstash repository+artifacts) + runIntegTestScriptForOSD.sh(rm -rf test-results) + runIntegTestScriptForOSD.runIntegTestScript({jobName=dummy-integ-test, componentName=OpenSearch-Dashboards, buildManifest=tests/data/opensearch-1.3.0-build.yml, testManifest=tests/data/opensearch-1.3.0-test.yml, localPath=/home/user/x64, switchUserNonRoot=false, ciGroup=1}) + runIntegTestScript.legacySCM(groovy.lang.Closure) + runIntegTestScript.library({identifier=jenkins@main, retriever=null}) + runIntegTestScript.readYaml({file=tests/data/opensearch-1.3.0-build.yml}) + BuildManifest.asBoolean() + BuildManifest.getArtifactArchitecture() + BuildManifest.getDistribution() + BuildManifest.getArtifactPlatform() + runIntegTestScript.echo(Start integTest on: tar x64 linux) + 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: 29) + BuildManifest.getArtifactRootUrl(dummy-integ-test, 29) + runIntegTestScript.echo(Artifact root URL: https://ci.opensearch.org/ci/dbc/dummy-integ-test/1.3.0/29/linux/x64/tar) + runIntegTestScript.echo(User provides localPath, use local artifacts: /home/user/x64) + runIntegTestScript.echo(Paths: opensearch=/home/user/x64) + runIntegTestScript.echo(Base Path null/null/1.3.0/29/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 JAVA_HOME=/opt/java/openjdk-11 ./test.sh integ-test manifests/tests/data/opensearch-1.3.0-test.yml --component OpenSearch-Dashboards --ci-group 1 --test-run-id null --paths opensearch=/home/user/x64 --base-path null/null/1.3.0/29/linux/x64/tar ) + runIntegTestScript.sh(env PATH=$PATH JAVA_HOME=/opt/java/openjdk-11 ./test.sh integ-test manifests/tests/data/opensearch-1.3.0-test.yml --component OpenSearch-Dashboards --ci-group 1 --test-run-id null --paths opensearch=/home/user/x64 --base-path null/null/1.3.0/29/linux/x64/tar ) diff --git a/tests/jenkins/jobs/RunIntegTestScriptForOSD_Jenkinsfile b/tests/jenkins/jobs/RunIntegTestScriptForOSD_Jenkinsfile new file mode 100644 index 00000000..9c338567 --- /dev/null +++ b/tests/jenkins/jobs/RunIntegTestScriptForOSD_Jenkinsfile @@ -0,0 +1,31 @@ +/* + * Copyright OpenSearch Contributors + * SPDX-License-Identifier: Apache-2.0 + * + * The OpenSearch Contributors require contributions made to + * this file be licensed under the Apache-2.0 license or a + * compatible open source license. + */ + +pipeline { + agent none + stages { + stage('integ-test') { + steps { + script { + runIntegTestScriptForOSD( + localComponent: 'reportsDashboard', + ciGroup: "", + switchUserNonRoot: 'false', + artifactPathOpenSearch:'dummy/path/opensearch', + artifactBucketName:'test-bucket', + artifactPath:'dummy/artifact/path', + distribution:'x64', + buildManifest:'tests/data/opensearch-1.3.0-build.yml', + testManifest:'tests/data/opensearch-1.3.0-test.yml' + ) + } + } + } + } +} diff --git a/tests/jenkins/jobs/RunIntegTestScriptForOSD_Jenkinsfile.txt b/tests/jenkins/jobs/RunIntegTestScriptForOSD_Jenkinsfile.txt new file mode 100644 index 00000000..c2fe0112 --- /dev/null +++ b/tests/jenkins/jobs/RunIntegTestScriptForOSD_Jenkinsfile.txt @@ -0,0 +1,38 @@ + RunIntegTestScriptForOSD_Jenkinsfile.run() + RunIntegTestScriptForOSD_Jenkinsfile.pipeline(groovy.lang.Closure) + RunIntegTestScriptForOSD_Jenkinsfile.echo(Executing on agent [label:none]) + RunIntegTestScriptForOSD_Jenkinsfile.stage(integ-test, groovy.lang.Closure) + RunIntegTestScriptForOSD_Jenkinsfile.script(groovy.lang.Closure) + RunIntegTestScriptForOSD_Jenkinsfile.runIntegTestScriptForOSD({localComponent=reportsDashboard, ciGroup=, switchUserNonRoot=false, artifactPathOpenSearch=dummy/path/opensearch, artifactBucketName=test-bucket, artifactPath=dummy/artifact/path, distribution=x64, buildManifest=tests/data/opensearch-1.3.0-build.yml, testManifest=tests/data/opensearch-1.3.0-test.yml}) + runIntegTestScriptForOSD.legacySCM(groovy.lang.Closure) + runIntegTestScriptForOSD.library({identifier=jenkins@main, retriever=null}) + runIntegTestScriptForOSD.unstash(integtest-opensearch-dashboards-307) + runIntegTestScriptForOSD.echo(Not on Windows, unstash repository+artifacts) + runIntegTestScriptForOSD.sh(rm -rf test-results) + runIntegTestScriptForOSD.runIntegTestScript({jobName=dummy-integ-test, componentName=reportsDashboard, buildManifest=tests/data/opensearch-1.3.0-build.yml, testManifest=tests/data/opensearch-1.3.0-test.yml, localPath=/home/user/x64, switchUserNonRoot=false, ciGroup=}) + runIntegTestScript.legacySCM(groovy.lang.Closure) + runIntegTestScript.library({identifier=jenkins@main, retriever=null}) + runIntegTestScript.readYaml({file=tests/data/opensearch-1.3.0-build.yml}) + BuildManifest.asBoolean() + BuildManifest.getArtifactArchitecture() + BuildManifest.getDistribution() + BuildManifest.getArtifactPlatform() + runIntegTestScript.echo(Start integTest on: tar x64 linux) + 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: 29) + BuildManifest.getArtifactRootUrl(dummy-integ-test, 29) + runIntegTestScript.echo(Artifact root URL: https://ci.opensearch.org/ci/dbc/dummy-integ-test/1.3.0/29/linux/x64/tar) + runIntegTestScript.echo(User provides localPath, use local artifacts: /home/user/x64) + runIntegTestScript.echo(Paths: opensearch=/home/user/x64) + runIntegTestScript.echo(Base Path null/null/1.3.0/29/linux/x64/tar) + runIntegTestScript.echo(Component: reportsDashboard) + runIntegTestScript.echo(Switch User to Non-Root (uid=1000): false) + runIntegTestScript.echo(Run command: env PATH=$PATH JAVA_HOME=/opt/java/openjdk-11 ./test.sh integ-test manifests/tests/data/opensearch-1.3.0-test.yml --component reportsDashboard --test-run-id null --paths opensearch=/home/user/x64 --base-path null/null/1.3.0/29/linux/x64/tar ) + runIntegTestScript.sh(env PATH=$PATH JAVA_HOME=/opt/java/openjdk-11 ./test.sh integ-test manifests/tests/data/opensearch-1.3.0-test.yml --component reportsDashboard --test-run-id null --paths opensearch=/home/user/x64 --base-path null/null/1.3.0/29/linux/x64/tar ) diff --git a/tests/jenkins/jobs/RunIntegTestScript_Jenkinsfile b/tests/jenkins/jobs/RunIntegTestScript_Jenkinsfile index ac2ac8b0..e46f3ada 100644 --- a/tests/jenkins/jobs/RunIntegTestScript_Jenkinsfile +++ b/tests/jenkins/jobs/RunIntegTestScript_Jenkinsfile @@ -18,6 +18,7 @@ pipeline { componentName: 'OpenSearch', buildManifest: 'tests/data/opensearch-1.3.0-build.yml', testManifest: 'tests/data/opensearch-1.3.0-test.yml', + ciGroup: "" ) } } diff --git a/tests/jenkins/jobs/RunIntegTestScript_Jenkinsfile.txt b/tests/jenkins/jobs/RunIntegTestScript_Jenkinsfile.txt index 729a8730..3a0cc476 100644 --- a/tests/jenkins/jobs/RunIntegTestScript_Jenkinsfile.txt +++ b/tests/jenkins/jobs/RunIntegTestScript_Jenkinsfile.txt @@ -3,7 +3,7 @@ RunIntegTestScript_Jenkinsfile.echo(Executing on agent [label:none]) RunIntegTestScript_Jenkinsfile.stage(integ-test, groovy.lang.Closure) RunIntegTestScript_Jenkinsfile.script(groovy.lang.Closure) - RunIntegTestScript_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}) + RunIntegTestScript_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, ciGroup=}) runIntegTestScript.legacySCM(groovy.lang.Closure) runIntegTestScript.library({identifier=jenkins@main, retriever=null}) runIntegTestScript.readYaml({file=tests/data/opensearch-1.3.0-build.yml}) @@ -28,5 +28,5 @@ runIntegTestScript.echo(Base Path https://dummy_link/dummy_integ_test/1.3.0/29/linux/x64/tar) runIntegTestScript.echo(Component: OpenSearch) runIntegTestScript.echo(Switch User to Non-Root (uid=1000): false) - 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/29/linux/x64/tar --base-path https://dummy_link/dummy_integ_test/1.3.0/29/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/29/linux/x64/tar --base-path https://dummy_link/dummy_integ_test/1.3.0/29/linux/x64/tar ) + runIntegTestScript.echo(Run command: env PATH=$PATH JAVA_HOME=/opt/java/openjdk-11 ./test.sh integ-test manifests/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/29/linux/x64/tar --base-path https://dummy_link/dummy_integ_test/1.3.0/29/linux/x64/tar ) + runIntegTestScript.sh(env PATH=$PATH JAVA_HOME=/opt/java/openjdk-11 ./test.sh integ-test manifests/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/29/linux/x64/tar --base-path https://dummy_link/dummy_integ_test/1.3.0/29/linux/x64/tar ) diff --git a/tests/jenkins/jobs/RunIntegTestScript_LocalPath_Jenkinsfile b/tests/jenkins/jobs/RunIntegTestScript_LocalPath_Jenkinsfile index 3d528e98..1345a94a 100644 --- a/tests/jenkins/jobs/RunIntegTestScript_LocalPath_Jenkinsfile +++ b/tests/jenkins/jobs/RunIntegTestScript_LocalPath_Jenkinsfile @@ -19,6 +19,7 @@ pipeline { 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', + ciGroup: "" ) } } diff --git a/tests/jenkins/jobs/RunIntegTestScript_LocalPath_Jenkinsfile.txt b/tests/jenkins/jobs/RunIntegTestScript_LocalPath_Jenkinsfile.txt index 972fa002..3175669f 100644 --- a/tests/jenkins/jobs/RunIntegTestScript_LocalPath_Jenkinsfile.txt +++ b/tests/jenkins/jobs/RunIntegTestScript_LocalPath_Jenkinsfile.txt @@ -3,7 +3,7 @@ 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-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_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, ciGroup=}) runIntegTestScript.legacySCM(groovy.lang.Closure) runIntegTestScript.library({identifier=jenkins@main, retriever=null}) runIntegTestScript.readYaml({file=tests/data/opensearch-dashboards-1.2.0-build.yml}) @@ -21,5 +21,5 @@ 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-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 ) + runIntegTestScript.echo(Run command: env PATH=$PATH ./test.sh integ-test manifests/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 manifests/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 ) diff --git a/tests/jenkins/jobs/RunIntegTestScript_LocalPath_Switch_Non_Root_Jenkinsfile b/tests/jenkins/jobs/RunIntegTestScript_LocalPath_Switch_Non_Root_Jenkinsfile index 02579aee..16ca3a1f 100644 --- a/tests/jenkins/jobs/RunIntegTestScript_LocalPath_Switch_Non_Root_Jenkinsfile +++ b/tests/jenkins/jobs/RunIntegTestScript_LocalPath_Switch_Non_Root_Jenkinsfile @@ -20,6 +20,7 @@ pipeline { testManifest: 'tests/data/opensearch-1.3.0-test.yml', localPath: 'tests/jenkins/artifacts/tar', switchUserNonRoot: 'true', + ciGroup: "" ) } } diff --git a/tests/jenkins/jobs/RunIntegTestScript_LocalPath_Switch_Non_Root_Jenkinsfile.txt b/tests/jenkins/jobs/RunIntegTestScript_LocalPath_Switch_Non_Root_Jenkinsfile.txt index 649a74c4..258e790f 100644 --- a/tests/jenkins/jobs/RunIntegTestScript_LocalPath_Switch_Non_Root_Jenkinsfile.txt +++ b/tests/jenkins/jobs/RunIntegTestScript_LocalPath_Switch_Non_Root_Jenkinsfile.txt @@ -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=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_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, ciGroup=}) runIntegTestScript.legacySCM(groovy.lang.Closure) runIntegTestScript.library({identifier=jenkins@main, retriever=null}) runIntegTestScript.readYaml({file=tests/data/opensearch-1.3.0-build.yml}) @@ -28,5 +28,5 @@ runIntegTestScript.echo(Base Path https://dummy_link/dummy_integ_test/1.3.0/29/linux/x64/tar) runIntegTestScript.echo(Component: OpenSearch) runIntegTestScript.echo(Switch User to Non-Root (uid=1000): true) - runIntegTestScript.echo(Run command: su `id -un 1000` -c "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=tests/jenkins/artifacts/tar --base-path https://dummy_link/dummy_integ_test/1.3.0/29/linux/x64/tar ") - runIntegTestScript.sh(su `id -un 1000` -c "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=tests/jenkins/artifacts/tar --base-path https://dummy_link/dummy_integ_test/1.3.0/29/linux/x64/tar ") + runIntegTestScript.echo(Run command: su `id -un 1000` -c "env PATH=$PATH JAVA_HOME=/opt/java/openjdk-11 ./test.sh integ-test manifests/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/29/linux/x64/tar ") + runIntegTestScript.sh(su `id -un 1000` -c "env PATH=$PATH JAVA_HOME=/opt/java/openjdk-11 ./test.sh integ-test manifests/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/29/linux/x64/tar ") diff --git a/tests/jenkins/jobs/RunIntegTestScript_OpenSearch_Dashboards_Jenkinsfile b/tests/jenkins/jobs/RunIntegTestScript_OpenSearch_Dashboards_Jenkinsfile index 41fabd59..cf9e4f2a 100644 --- a/tests/jenkins/jobs/RunIntegTestScript_OpenSearch_Dashboards_Jenkinsfile +++ b/tests/jenkins/jobs/RunIntegTestScript_OpenSearch_Dashboards_Jenkinsfile @@ -17,7 +17,8 @@ pipeline { jobName: 'dummy_job', componentName: 'functionalTestDashboards', buildManifest: 'tests/data/opensearch-dashboards-1.2.0-build.yml', - testManifest: 'tests/data/opensearch-dashboards-1.2.0-test.yml' + testManifest: 'tests/data/opensearch-dashboards-1.2.0-test.yml', + ciGroup: '1' ) } } diff --git a/tests/jenkins/jobs/RunIntegTestScript_OpenSearch_Dashboards_Jenkinsfile.txt b/tests/jenkins/jobs/RunIntegTestScript_OpenSearch_Dashboards_Jenkinsfile.txt index 3c28a6f1..34a14ea9 100644 --- a/tests/jenkins/jobs/RunIntegTestScript_OpenSearch_Dashboards_Jenkinsfile.txt +++ b/tests/jenkins/jobs/RunIntegTestScript_OpenSearch_Dashboards_Jenkinsfile.txt @@ -3,7 +3,7 @@ RunIntegTestScript_OpenSearch_Dashboards_Jenkinsfile.echo(Executing on agent [label:none]) RunIntegTestScript_OpenSearch_Dashboards_Jenkinsfile.stage(integ-test, groovy.lang.Closure) RunIntegTestScript_OpenSearch_Dashboards_Jenkinsfile.script(groovy.lang.Closure) - RunIntegTestScript_OpenSearch_Dashboards_Jenkinsfile.runIntegTestScript({jobName=dummy_job, componentName=functionalTestDashboards, buildManifest=tests/data/opensearch-dashboards-1.2.0-build.yml, testManifest=tests/data/opensearch-dashboards-1.2.0-test.yml}) + RunIntegTestScript_OpenSearch_Dashboards_Jenkinsfile.runIntegTestScript({jobName=dummy_job, componentName=functionalTestDashboards, buildManifest=tests/data/opensearch-dashboards-1.2.0-build.yml, testManifest=tests/data/opensearch-dashboards-1.2.0-test.yml, ciGroup=1}) runIntegTestScript.legacySCM(groovy.lang.Closure) runIntegTestScript.library({identifier=jenkins@main, retriever=null}) runIntegTestScript.readYaml({file=tests/data/opensearch-dashboards-1.2.0-build.yml}) @@ -21,5 +21,5 @@ runIntegTestScript.echo(Base Path https://dummy_link/dummy_integ_test/1.2.0/215/linux/x64/tar) runIntegTestScript.echo(Component: functionalTestDashboards) runIntegTestScript.echo(Switch User to Non-Root (uid=1000): false) - runIntegTestScript.echo(Run command: env PATH=$PATH ./test.sh integ-test tests/data/opensearch-dashboards-1.2.0-test.yml --component functionalTestDashboards --test-run-id 987 --paths opensearch=https://ci.opensearch.org/ci/dbc/distribution-build-opensearch/1.2.0/latest/linux/x64/tar opensearch-dashboards=https://ci.opensearch.org/ci/dbc/dummy_job/1.2.0/215/linux/x64/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 functionalTestDashboards --test-run-id 987 --paths opensearch=https://ci.opensearch.org/ci/dbc/distribution-build-opensearch/1.2.0/latest/linux/x64/tar opensearch-dashboards=https://ci.opensearch.org/ci/dbc/dummy_job/1.2.0/215/linux/x64/tar --base-path https://dummy_link/dummy_integ_test/1.2.0/215/linux/x64/tar ) + runIntegTestScript.echo(Run command: env PATH=$PATH ./test.sh integ-test tests/data/opensearch-dashboards-1.2.0-test.yml --component functionalTestDashboards --ci-group 1 --test-run-id 987 --paths opensearch=https://ci.opensearch.org/ci/dbc/distribution-build-opensearch/1.2.0/latest/linux/x64/tar opensearch-dashboards=https://ci.opensearch.org/ci/dbc/dummy_job/1.2.0/215/linux/x64/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 functionalTestDashboards --ci-group 1 --test-run-id 987 --paths opensearch=https://ci.opensearch.org/ci/dbc/distribution-build-opensearch/1.2.0/latest/linux/x64/tar opensearch-dashboards=https://ci.opensearch.org/ci/dbc/dummy_job/1.2.0/215/linux/x64/tar --base-path https://dummy_link/dummy_integ_test/1.2.0/215/linux/x64/tar ) diff --git a/tests/jenkins/jobs/RunIntegTestScript_Windows_Jenkinsfile b/tests/jenkins/jobs/RunIntegTestScript_Windows_Jenkinsfile index 5fab440d..3baeddde 100644 --- a/tests/jenkins/jobs/RunIntegTestScript_Windows_Jenkinsfile +++ b/tests/jenkins/jobs/RunIntegTestScript_Windows_Jenkinsfile @@ -18,6 +18,7 @@ pipeline { componentName: 'OpenSearch', buildManifest: 'tests/data/opensearch-2.8.0-build-windows.yml', testManifest: 'tests/data/opensearch-2.8.0-test.yml', + ciGroup: "" ) } } diff --git a/tests/jenkins/lib-testers/RunIntegTestScriptForOSDLibTester.groovy b/tests/jenkins/lib-testers/RunIntegTestScriptForOSDLibTester.groovy new file mode 100644 index 00000000..d13b8daf --- /dev/null +++ b/tests/jenkins/lib-testers/RunIntegTestScriptForOSDLibTester.groovy @@ -0,0 +1,69 @@ +/* + * Copyright OpenSearch Contributors + * SPDX-License-Identifier: Apache-2.0 + * + * The OpenSearch Contributors require contributions made to + * this file be licensed under the Apache-2.0 license or a + * compatible open source license. + */ +import static org.hamcrest.CoreMatchers.notNullValue +import static org.hamcrest.MatcherAssert.assertThat + +class RunIntegTestScriptForOSDLibTester extends LibFunctionTester { + + private String localComponent + private String ciGroup + private String switchUserNonRoot + private String artifactPathOpenSearch + private String artifactBucketName + private String artifactPath + private String distribution + private String buildManifest + private String testManifest + + public RunIntegTestScriptForOSDLibTester(localComponent, ciGroup, switchUserNonRoot, artifactPathOpenSearch, artifactBucketName, + artifactPath, distribution, buildManifest, testManifest) { + this.localComponent = localComponent + this.ciGroup = ciGroup + this.switchUserNonRoot = switchUserNonRoot + this.artifactPathOpenSearch = artifactPathOpenSearch + this.artifactBucketName = artifactBucketName + this.artifactPath = artifactPath + this.distribution = distribution + this.buildManifest = buildManifest + this.testManifest = testManifest + } + + @Override + String libFunctionName() { + return 'runIntegTestScriptForOSD' + } + + @Override + void parameterInvariantsAssertions(Object call) { + assertThat(call.args.localComponent.first(), notNullValue()) + assertThat(call.args.switchUserNonRoot.first(), notNullValue()) + } + + @Override + boolean expectedParametersMatcher(Object call) { + return call.args.localComponent.first().toString().equals(this.localComponent) + && call.args.switchUserNonRoot.first().toString().equals(this.switchUserNonRoot) + } + + @Override + void configure(Object helper, Object binding) { + helper.registerAllowedMethod('downloadFromS3', [Map.class], { args -> return null }) + helper.registerAllowedMethod('runIntegTestScript', [Map.class], { args -> return null }) + helper.registerAllowedMethod('unstash', [String.class], { name -> return null }) + helper.registerAllowedMethod("withAWS", [Map, Closure], { + args, + closure -> + closure.delegate = delegate + return helper.callClosure(closure) + }) + binding.setVariable('BUILD_NUMBER', '307') + binding.setVariable('BUILD_JOB_NAME', 'dummy-integ-test') + binding.setVariable('WORKSPACE', '/home/user') + } +} diff --git a/vars/runIntegTestScript.groovy b/vars/runIntegTestScript.groovy index 068ad544..946d9a82 100644 --- a/vars/runIntegTestScript.groovy +++ b/vars/runIntegTestScript.groovy @@ -6,6 +6,17 @@ * this file be licensed under the Apache-2.0 license or a * compatible open source license. */ +/**@ + * Contains logic to execute the integration test workflow + * + * @param args A map of the following parameters + * @param args.componentName The plugin/component name + * @param args.switchUserNonRoot Run as root user + * @param args.testManifest Test manifest file location + * @param args.jobName Job name that triggered the workflow. + * @param args.localPath Local path for downloaded build artifacts + * @param args.ciGroup The particular ci-group number to run the integration tests for + */ void call(Map args = [:]) { lib = library(identifier: 'jenkins@main', retriever: legacySCM(scm)) @@ -55,13 +66,16 @@ void call(Map args = [:]) { String switchCommandStart = switchUser.equals('true') ? "su `id -un 1000` -c \"env PATH=\$PATH $javaHomeCommand" : "env PATH=\$PATH $javaHomeCommand" String switchCommandEnd = switchUser.equals('true') ? '"' : '' + String testManifest = "manifests/${args.testManifest}" + String testCommand = [ switchCommandStart, './test.sh', 'integ-test', - "${args.testManifest}", + "${testManifest}", "--component ${component}", + isNullOrEmpty(args.ciGroup.toString()) ? "" : "--ci-group ${args.ciGroup}", "--test-run-id ${env.BUILD_NUMBER}", "--paths ${paths}", "--base-path ${basePath}", @@ -97,3 +111,5 @@ String generatePaths(buildManifest, artifactRootUrl, localPath) { String generateBasePaths(buildManifest) { return ["${env.PUBLIC_ARTIFACT_URL}", "${env.JOB_NAME}", buildManifest.build.version, buildManifest.build.id, buildManifest.build.platform, buildManifest.build.architecture, buildManifest.build.distribution].join("/") } + +boolean isNullOrEmpty(String str) { return (str == null || str.allWhitespace || str.isEmpty()) } diff --git a/vars/runIntegTestScriptForOSD.groovy b/vars/runIntegTestScriptForOSD.groovy new file mode 100644 index 00000000..5675d293 --- /dev/null +++ b/vars/runIntegTestScriptForOSD.groovy @@ -0,0 +1,68 @@ +/* + * Copyright OpenSearch Contributors + * SPDX-License-Identifier: Apache-2.0 + * + * The OpenSearch Contributors require contributions made to + * this file be licensed under the Apache-2.0 license or a + * compatible open source license. + */ +/**@ + * Contains logic to invoke runIntegTestScript script for OSD integration tests + * + * @param args A map of the following parameters + * @param args.localComponent The component name from OpenSearch-Dashboards manifest + * @param args.switchUserNonRoot Run as root user + * @param args.ciGroup The particular ci-group number to run the integration tests for + * @param args.artifactPathOpenSearch OpenSearch artifact path + * @param args.artifactPath OpenSearch-Dashboards artifact path + * @param args.artifactBucketName S3 build bucket name that contains all the required artifacts + * @param args.distribution Distribution type (tar/zip/rpm/deb) + * @param args.buildManifest OS and OSD distribution build manifest path + * @param args.testManifest OSD test manifest for release version + */ +void call(Map args = [:]) { + lib = library(identifier: 'jenkins@main', retriever: legacySCM(scm)) + + unstash "integtest-opensearch-dashboards-${BUILD_NUMBER}" + + if (env.platform == 'windows') { + echo "On Windows Platform, unstash repository and download the artifacts" + echo "Downloading from S3: ${args.artifactPathOpenSearch}" + downloadFromS3( + assumedRoleName: 'opensearch-bundle', + roleAccountNumberCred: 'jenkins-aws-account-public', + downloadPath: "${args.artifactPathOpenSearch}/", + bucketName: args.artifactBucketName, + localPath: "${WORKSPACE}/artifacts", + force: true + ) + sh("cp -a ${WORKSPACE}/artifacts/${artifactPathOpenSearch} ${WORKSPACE}") + + echo "Downloading from S3: ${artifactPath}" + downloadFromS3( + assumedRoleName: 'opensearch-bundle', + roleAccountNumberCred: 'jenkins-aws-account-public', + downloadPath: "${args.artifactPath}/", + bucketName: args.artifactBucketName, + localPath: "${WORKSPACE}/artifacts", + force: true + ) + sh("cp -a ${WORKSPACE}/artifacts/${args.artifactPath} ${WORKSPACE}") + sh("rm -rf ${WORKSPACE}/artifacts") + } + else { + echo "Not on Windows, unstash repository+artifacts" + } + + sh("rm -rf test-results") + + runIntegTestScript( + jobName: "${BUILD_JOB_NAME}", + componentName: args.localComponent, + buildManifest: args.buildManifest, + testManifest: args.testManifest, + localPath: "${WORKSPACE}/${args.distribution}", + switchUserNonRoot: args.switchUserNonRoot, + ciGroup: args.ciGroup + ) +}