diff --git a/tests/jenkins/TestProcessAndRunOsdIntegTest.groovy b/tests/jenkins/TestProcessAndRunOsdIntegTest.groovy new file mode 100644 index 00000000..9bbc0c85 --- /dev/null +++ b/tests/jenkins/TestProcessAndRunOsdIntegTest.groovy @@ -0,0 +1,57 @@ +/* + * 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 TestProcessAndRunOsdIntegTest extends BuildPipelineTest { + + @Test + public void TestRunProcessScript() { + this.registerLibTester(new ProcessAndRunOsdIntegTestLibTester( + 'OpenSearch', + '', + 'false' + ) + ) + super.setUp() + super.testPipeline("tests/jenkins/jobs/ProcessAndRunOsdIntegTest_Jenkinsfile") + runScript("tests/jenkins/jobs/ProcessAndRunOsdIntegTest_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 --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 ProcessAndRunOsdIntegTestLibTester( + 'OpenSearch-Dashboards', + '1', + 'false' + ) + ) + super.setUp() + super.testPipeline("tests/jenkins/jobs/ProcessAndRunOsdIntegTestCiGroup_Jenkinsfile") + runScript("tests/jenkins/jobs/ProcessAndRunOsdIntegTestCiGroup_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/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/jobs/ProcessAndRunOsdIntegTestCiGroup_Jenkinsfile b/tests/jenkins/jobs/ProcessAndRunOsdIntegTestCiGroup_Jenkinsfile new file mode 100644 index 00000000..d39bb6aa --- /dev/null +++ b/tests/jenkins/jobs/ProcessAndRunOsdIntegTestCiGroup_Jenkinsfile @@ -0,0 +1,25 @@ +/* + * 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 { + processAndRunOsdIntegTest( + localComponent: 'OpenSearch-Dashboards', + ciGroup: "1", + switchUserNonRoot: 'false' + ) + } + } + } + } +} 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 b/tests/jenkins/jobs/ProcessAndRunOsdIntegTest_Jenkinsfile new file mode 100644 index 00000000..d1c4bc5f --- /dev/null +++ b/tests/jenkins/jobs/ProcessAndRunOsdIntegTest_Jenkinsfile @@ -0,0 +1,25 @@ +/* + * 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 { + processAndRunOsdIntegTest( + localComponent: 'OpenSearch', + ciGroup: "", + switchUserNonRoot: 'false' + ) + } + } + } + } +} 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/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/ProcessAndRunOsdIntegTestLibTester.groovy b/tests/jenkins/lib-testers/ProcessAndRunOsdIntegTestLibTester.groovy new file mode 100644 index 00000000..8f469124 --- /dev/null +++ b/tests/jenkins/lib-testers/ProcessAndRunOsdIntegTestLibTester.groovy @@ -0,0 +1,62 @@ +/* + * 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 ProcessAndRunOsdIntegTestLibTester extends LibFunctionTester { + + private String localComponent + private String ciGroup + private String switchUserNonRoot + + public ProcessAndRunOsdIntegTestLibTester(localComponent, ciGroup, switchUserNonRoot) { + this.localComponent = localComponent + this.ciGroup = ciGroup + this.switchUserNonRoot = switchUserNonRoot + } + + @Override + String libFunctionName() { + return 'processAndRunOsdIntegTest' + } + + @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('artifactPathOpenSearch', 'dummy-artifact-path-os') + binding.setVariable('ARTIFACT_BUCKET_NAME', 'test-bucket') + binding.setVariable('WORKSPACE', '/home/user') + binding.setVariable('artifactPath', 'dummy-artifact-path') + binding.setVariable('BUILD_MANIFEST', 'tests/data/opensearch-1.3.0-build.yml') + binding.setVariable('TEST_MANIFEST', 'tests/data/opensearch-1.3.0-test.yml') + binding.setVariable('distribution', 'x64') + } +} diff --git a/tests/manifests/opensearch-1.3.0-test.yml b/tests/manifests/opensearch-1.3.0-test.yml new file mode 100644 index 00000000..ecf2228f --- /dev/null +++ b/tests/manifests/opensearch-1.3.0-test.yml @@ -0,0 +1,95 @@ +--- +name: OpenSearch +ci: + image: + name: opensearchstaging/ci-runner:ci-runner-centos7-v1 + args: -e JAVA_HOME=/opt/java/openjdk-11 +components: + - name: index-management + integ-test: + build-dependencies: + - job-scheduler + test-configs: + - with-security + - without-security + additional-cluster-configs: + path.repo: [/tmp] + bwc-test: + test-configs: + - with-security + - without-security + + - name: anomaly-detection + integ-test: + build-dependencies: + - job-scheduler + test-configs: + - with-security + - without-security + bwc-test: + test-configs: + - with-security + - without-security + + - name: asynchronous-search + integ-test: + test-configs: + - with-security + - without-security + bwc-test: + test-configs: + - with-security + - without-security + + - name: alerting + integ-test: + test-configs: + - with-security + - without-security + additional-cluster-configs: + plugins.destination.host.deny_list: [10.0.0.0/8, 127.0.0.1] + bwc-test: + test-configs: + - with-security + - without-security + + - name: sql + integ-test: + test-configs: + - with-security + - without-security + additional-cluster-configs: + script.context.field.max_compilations_rate: 1000/1m + bwc-test: + test-configs: + - with-security + - without-security + + - name: k-NN + integ-test: + test-configs: + - with-security + - without-security + bwc-test: + test-configs: + - with-security + - without-security + + - name: dashboards-reports + working-directory: reports-scheduler + integ-test: + test-configs: + - without-security + bwc-test: + test-configs: + - without-security + + - name: dashboards-notebooks + working-directory: opensearch-notebooks + integ-test: + test-configs: + - without-security + bwc-test: + test-configs: + - without-security +schema-version: '1.0' diff --git a/vars/processAndRunOsdIntegTest.groovy b/vars/processAndRunOsdIntegTest.groovy new file mode 100644 index 00000000..f8976439 --- /dev/null +++ b/vars/processAndRunOsdIntegTest.groovy @@ -0,0 +1,54 @@ +/* + * 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. + */ +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: ${artifactPathOpenSearch}" + downloadFromS3( + assumedRoleName: 'opensearch-bundle', + roleAccountNumberCred: 'jenkins-aws-account-public', + downloadPath: "${artifactPathOpenSearch}/", + bucketName: "${ARTIFACT_BUCKET_NAME}", + 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: "${artifactPath}/", + bucketName: "${ARTIFACT_BUCKET_NAME}", + localPath: "${WORKSPACE}/artifacts", + force: true + ) + sh("cp -a ${WORKSPACE}/artifacts/${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: "${BUILD_MANIFEST}", + testManifest: "${TEST_MANIFEST}", + localPath: "${WORKSPACE}/${distribution}", + switchUserNonRoot: args.switchUserNonRoot, + ciGroup: args.ciGroup + ) +} diff --git a/vars/runIntegTestScript.groovy b/vars/runIntegTestScript.groovy index 8e55883a..a464a961 100644 --- a/vars/runIntegTestScript.groovy +++ b/vars/runIntegTestScript.groovy @@ -55,14 +55,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}", - "--ci-group ${args.ciGroup}", + isNullOrEmpty(args.ciGroup.toString()) ? "" : "--ci-group ${args.ciGroup}", "--test-run-id ${env.BUILD_NUMBER}", "--paths ${paths}", "--base-path ${basePath}", @@ -98,3 +100,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()) }