From c0c923dceb6c013b5ded3c3c96fac7a3d19fd008 Mon Sep 17 00:00:00 2001 From: Kawika Avilla Date: Mon, 21 Mar 2022 23:07:20 +0000 Subject: [PATCH] [Tests][BWC] add BWC tests to Jenkins For OpenSearch and OpenSearch Dashboards. Also fix a bug with the test config showing incorrectly. Issue resolved: https://github.com/opensearch-project/opensearch-build/issues/705 Signed-off-by: Kawika Avilla --- .../bwc-test.jenkinsfile | 141 +++++++++++++++++ .../distribution-build.jenkinsfile | 46 ++++++ jenkins/opensearch/bwc-test.jenkinsfile | 142 ++++++++++++++++++ .../opensearch/distribution-build.jenkinsfile | 48 +++++- src/test_workflow/bwc_test/bwc_test_suite.py | 2 +- tests/jenkins/TestRunBwcTestScript.groovy | 41 +++++ tests/jenkins/TestRunIntegTestScript.groovy | 2 +- .../data/opensearch-dashboards-1.2.0-test.yml | 5 + .../jenkins/jobs/RunBwcTestScript_Jenkinsfile | 25 +++ .../jobs/RunBwcTestScript_Jenkinsfile.txt | 14 ++ ...stScript_OpenSearch_Dashboards_Jenkinsfile | 25 +++ ...ript_OpenSearch_Dashboards_Jenkinsfile.txt | 14 ++ .../RunBwcTestScriptLibTest.groovy | 39 +++++ vars/runBwcTestScript.groovy | 24 +++ 14 files changed, 565 insertions(+), 3 deletions(-) create mode 100644 jenkins/opensearch-dashboards/bwc-test.jenkinsfile create mode 100644 jenkins/opensearch/bwc-test.jenkinsfile create mode 100644 tests/jenkins/TestRunBwcTestScript.groovy create mode 100644 tests/jenkins/jobs/RunBwcTestScript_Jenkinsfile create mode 100644 tests/jenkins/jobs/RunBwcTestScript_Jenkinsfile.txt create mode 100644 tests/jenkins/jobs/RunBwcTestScript_OpenSearch_Dashboards_Jenkinsfile create mode 100644 tests/jenkins/jobs/RunBwcTestScript_OpenSearch_Dashboards_Jenkinsfile.txt create mode 100644 tests/jenkins/lib-testers/RunBwcTestScriptLibTest.groovy create mode 100644 vars/runBwcTestScript.groovy diff --git a/jenkins/opensearch-dashboards/bwc-test.jenkinsfile b/jenkins/opensearch-dashboards/bwc-test.jenkinsfile new file mode 100644 index 0000000000..85f4d8ac75 --- /dev/null +++ b/jenkins/opensearch-dashboards/bwc-test.jenkinsfile @@ -0,0 +1,141 @@ +lib = library(identifier: "jenkins@20211118", retriever: legacySCM(scm)) + +pipeline { + options { + timeout(time: 3, unit: 'HOURS') + } + agent none + environment { + BUILD_MANIFEST = "build-manifest.yml" + DEFAULT_BUILD_JOB_NAME = "distribution-build-opensearch-dashboards" + } + parameters { + string( + name: 'TEST_MANIFEST', + description: 'Test manifest under the manifests folder, e.g. 2.0.0/opensearch-dashboards-2.0.0-test.yml.', + trim: true + ) + string( + name: 'BUILD_MANIFEST_URL', + description: 'The build manifest URL, e.g. https://ci.opensearch.org/ci/dbc/distribution-build-opensearch-dashboards/2.0.0/98/linux/x64/builds/opensearch-dashboards/manifest.yml.', + trim: true + ) + string( + name: 'AGENT_LABEL', + description: 'The agent label where the tests should be executed, e.g. Jenkins-Agent-al2-x64-c54xlarge-Docker-Host.', + trim: true + ) + } + stages { + stage('verify-parameters') { + agent { + node { + label AGENT_LABEL + } + } + steps { + script { + if (AGENT_LABEL == '') { + currentBuild.result = 'ABORTED' + error("BWC Tests failed to start. Missing parameter: AGENT_LABEL.") + } + if (!fileExists("manifests/${TEST_MANIFEST}")) { + currentBuild.result = 'ABORTED' + error("BWC Tests failed to start. Test manifest not found in manifests/${TEST_MANIFEST}.") + } + env.BUILD_JOB_NAME = currentBuild.upstreamBuilds ? + currentBuild.upstreamBuilds[0].fullProjectName : + env.DEFAULT_BUILD_JOB_NAME + } + } + } + stage('detect docker image + args') { + agent { + docker { + label 'Jenkins-Agent-al2-x64-c54xlarge-Docker-Host' + image 'opensearchstaging/ci-runner:centos7-x64-arm64-jdkmulti-node10.24.1-cypress6.9.1-20211028' + alwaysPull true + } + } + steps { + script { + dockerAgent = detectTestDockerAgent() + } + } + } + stage('bwc-test') { + agent { + docker { + label AGENT_LABEL + image dockerAgent.image + args dockerAgent.args + alwaysPull true + } + } + steps { + script { + def buildManifestObj = downloadBuildManifest( + url: BUILD_MANIFEST_URL, + path: BUILD_MANIFEST + ) + String buildId = buildManifestObj.getArtifactBuildId() + env.BUILD_ID = buildId + echo "BUILD_MANIFEST: ${BUILD_MANIFEST}" + echo "BUILD_ID: ${BUILD_ID}" + + runBwcTestScript( + jobName: BUILD_JOB_NAME, + buildManifest: BUILD_MANIFEST, + testManifest: "manifests/${TEST_MANIFEST}", + buildId: BUILD_ID + ) + } + } + post { + always { + script { + uploadTestResults( + buildManifestFileName: BUILD_MANIFEST, + jobName: JOB_NAME, + buildNumber: BUILD_ID + ) + } + postCleanup() + } + } + } + } + + post { + success { + node(AGENT_LABEL) { + script { + def stashed = lib.jenkins.Messages.new(this).get(['bwc-test']) + publishNotification( + icon: ':white_check_mark:', + message: 'BWC Tests Successful', + extra: stashed, + credentialsId: 'INTEG_TEST_WEBHOOK', + ) + + postCleanup() + } + } + } + failure { + node(AGENT_LABEL) { + script { + def stashed = lib.jenkins.Messages.new(this).get(['bwc-test']) + publishNotification( + icon: ':warning:', + message: 'Failed BWC Tests', + extra: stashed, + credentialsId: 'INTEG_TEST_WEBHOOK', + ) + + postCleanup() + } + } + } + } +} diff --git a/jenkins/opensearch-dashboards/distribution-build.jenkinsfile b/jenkins/opensearch-dashboards/distribution-build.jenkinsfile index 5e1b550b78..e77e791549 100644 --- a/jenkins/opensearch-dashboards/distribution-build.jenkinsfile +++ b/jenkins/opensearch-dashboards/distribution-build.jenkinsfile @@ -28,6 +28,12 @@ pipeline { defaultValue: "integ-test-opensearch-dashboards", trim: true ) + string( + name: 'BWC_TEST_JOB_NAME', + description: "Name of backwards compatibility test job that will be triggered, e.g. Playground/bwc-test-opensearch-dashboards. A non-null empty value here will skip BWC tests.", + defaultValue: "bwc-test-opensearch-dashboards", + trim: true + ) booleanParam( name: 'BUILD_DOCKER', description: 'Build docker image or not.', @@ -98,6 +104,26 @@ pipeline { absoluteUrl: integTestResults.getAbsoluteUrl() ) } + + Boolean skipBwcTests = BWC_TEST_JOB_NAME == '' + echo "${skipBwcTests ? 'Skipping BWC tests' : 'Running BWC tests'}" + if (!skipBwcTests) { + def bwcTestResults = + build job: BWC_TEST_JOB_NAME, + propagate: false, + wait: true, + parameters: [ + string(name: 'TEST_MANIFEST', value: TEST_MANIFEST), + string(name: 'BUILD_MANIFEST_URL', value: buildManifestUrl), + string(name: 'AGENT_LABEL', value: AGENT_X64) + ] + + createTestResultsMessage( + testType: "BWC Tests (x64)", + status: bwcTestResults.getResult(), + absoluteUrl: bwcTestResults.getAbsoluteUrl() + ) + } } } post { @@ -175,6 +201,26 @@ pipeline { absoluteUrl: integTestResults.getAbsoluteUrl() ) } + + Boolean skipBwcTests = BWC_TEST_JOB_NAME == '' + echo "${skipBwcTests ? 'Skipping BWC tests' : 'Running BWC tests'}" + if (!skipBwcTests) { + def bwcTestResults = + build job: BWC_TEST_JOB_NAME, + propagate: false, + wait: true, + parameters: [ + string(name: 'TEST_MANIFEST', value: TEST_MANIFEST), + string(name: 'BUILD_MANIFEST_URL', value: buildManifestUrl), + string(name: 'AGENT_LABEL', value: AGENT_ARM64) + ] + + createTestResultsMessage( + testType: "BWC Tests (arm64)", + status: bwcTestResults.getResult(), + absoluteUrl: bwcTestResults.getAbsoluteUrl() + ) + } } } post { diff --git a/jenkins/opensearch/bwc-test.jenkinsfile b/jenkins/opensearch/bwc-test.jenkinsfile new file mode 100644 index 0000000000..d6cc46c76a --- /dev/null +++ b/jenkins/opensearch/bwc-test.jenkinsfile @@ -0,0 +1,142 @@ +lib = library(identifier: "jenkins@20211118", retriever: legacySCM(scm)) + +pipeline { + agent none + environment { + BUILD_MANIFEST = "build-manifest.yml" + DEFAULT_BUILD_JOB_NAME = "distribution-build-opensearch" + } + tools { + jdk "JDK14" + maven "maven-3.8.2" + } + parameters { + string( + name: 'TEST_MANIFEST', + description: 'Test manifest under the manifests folder, e.g. 2.0.0/opensearch-2.0.0-test.yml.', + trim: true + ) + string( + name: 'BUILD_MANIFEST_URL', + description: 'The build manifest URL, e.g. https://ci.opensearch.org/ci/dbc/distribution-build-opensearch/1.2.2/98/linux/x64/builds/opensearch/manifest.yml.', + trim: true + ) + string( + name: 'AGENT_LABEL', + description: 'The agent label where the tests should be executed, e.g. Jenkins-Agent-al2-x64-c54xlarge-Docker-Host.', + trim: true + ) + } + stages { + stage('verify-parameters') { + agent { + node { + label AGENT_LABEL + } + } + steps { + script { + if (AGENT_LABEL == '') { + currentBuild.result = 'ABORTED' + error("BWC Tests failed to start. Missing parameter: AGENT_LABEL.") + } + if (!fileExists("manifests/${TEST_MANIFEST}")) { + currentBuild.result = 'ABORTED' + error("BWC Tests failed to start. Test manifest not found in manifests/${TEST_MANIFEST}.") + } + env.BUILD_JOB_NAME = currentBuild.upstreamBuilds ? + currentBuild.upstreamBuilds[0].fullProjectName : + env.DEFAULT_BUILD_JOB_NAME + } + } + } + stage('detect docker image + args') { + agent { + docker { + label 'Jenkins-Agent-al2-x64-c54xlarge-Docker-Host' + image 'opensearchstaging/ci-runner:centos7-x64-arm64-jdkmulti-node10.24.1-cypress6.9.1-20211028' + alwaysPull true + } + } + steps { + script { + dockerAgent = detectTestDockerAgent() + } + } + } + stage('bwc-test') { + agent { + docker { + label AGENT_LABEL + image dockerAgent.image + args dockerAgent.args + alwaysPull true + } + } + steps { + script { + def buildManifestObj = downloadBuildManifest( + url: BUILD_MANIFEST_URL, + path: BUILD_MANIFEST + ) + String buildId = buildManifestObj.getArtifactBuildId() + env.BUILD_ID = buildId + echo "BUILD_MANIFEST: ${BUILD_MANIFEST}" + echo "BUILD_ID: ${BUILD_ID}" + + runBwcTestScript( + jobName: BUILD_JOB_NAME, + buildManifest: BUILD_MANIFEST, + testManifest: "manifests/${TEST_MANIFEST}", + buildId: BUILD_ID + ) + } + } + post { + always { + script { + uploadTestResults( + buildManifestFileName: BUILD_MANIFEST, + jobName: JOB_NAME, + buildNumber: BUILD_ID + ) + } + postCleanup() + } + } + } + } + + post { + success { + node(AGENT_LABEL) { + script { + def stashed = lib.jenkins.Messages.new(this).get(['bwc-test']) + publishNotification( + icon: ':white_check_mark:', + message: 'BWC Tests Successful', + extra: stashed, + credentialsId: 'INTEG_TEST_WEBHOOK', + ) + + postCleanup() + } + } + } + failure { + node(AGENT_LABEL) { + script { + def stashed = lib.jenkins.Messages.new(this).get(['bwc-test']) + publishNotification( + icon: ':warning:', + message: 'Failed BWC Tests', + extra: stashed, + credentialsId: 'INTEG_TEST_WEBHOOK', + ) + + postCleanup() + } + } + } + } +} diff --git a/jenkins/opensearch/distribution-build.jenkinsfile b/jenkins/opensearch/distribution-build.jenkinsfile index 6014b19b0c..e98f1788b5 100644 --- a/jenkins/opensearch/distribution-build.jenkinsfile +++ b/jenkins/opensearch/distribution-build.jenkinsfile @@ -23,6 +23,12 @@ pipeline { defaultValue: "integ-test", trim: true ) + string( + name: 'BWC_TEST_JOB_NAME', + description: "Name of backwards compatibility test job that will be triggered, e.g. Playground/bwc-test. A non-null empty value here will skip BWC tests.", + defaultValue: "bwc-test", + trim: true + ) booleanParam( name: 'BUILD_DOCKER', description: 'Build docker image or not.', @@ -157,7 +163,27 @@ pipeline { status: integTestResults.getResult(), absoluteUrl: integTestResults.getAbsoluteUrl() ) - } + } + + Boolean skipBwcTests = BWC_TEST_JOB_NAME == '' + echo "${skipBwcTests ? 'Skipping BWC tests' : 'Running BWC tests'}" + if (!skipBwcTests) { + def bwcTestResults = + build job: BWC_TEST_JOB_NAME, + propagate: false, + wait: true, + parameters: [ + string(name: 'TEST_MANIFEST', value: TEST_MANIFEST), + string(name: 'BUILD_MANIFEST_URL', value: buildManifestUrl), + string(name: 'AGENT_LABEL', value: AGENT_X64) + ] + + createTestResultsMessage( + testType: "BWC Tests (x64)", + status: bwcTestResults.getResult(), + absoluteUrl: bwcTestResults.getAbsoluteUrl() + ) + } } } post { @@ -206,6 +232,26 @@ pipeline { absoluteUrl: integTestResults.getAbsoluteUrl() ) } + + Boolean skipBwcTests = BWC_TEST_JOB_NAME == '' + echo "${skipBwcTests ? 'Skipping BWC tests' : 'Running BWC tests'}" + if (!skipBwcTests) { + def bwcTestResults = + build job: BWC_TEST_JOB_NAME, + propagate: false, + wait: true, + parameters: [ + string(name: 'TEST_MANIFEST', value: TEST_MANIFEST), + string(name: 'BUILD_MANIFEST_URL', value: buildManifestUrl), + string(name: 'AGENT_LABEL', value: AGENT_ARM64) + ] + + createTestResultsMessage( + testType: "BWC Tests (arm64)", + status: bwcTestResults.getResult(), + absoluteUrl: bwcTestResults.getAbsoluteUrl() + ) + } } } post { diff --git a/src/test_workflow/bwc_test/bwc_test_suite.py b/src/test_workflow/bwc_test/bwc_test_suite.py index d4822b2246..293f4285e8 100644 --- a/src/test_workflow/bwc_test/bwc_test_suite.py +++ b/src/test_workflow/bwc_test/bwc_test_suite.py @@ -64,7 +64,7 @@ def execute_bwctest_sh(self, config): test_result_data = TestResultData( self.component.name, - self.test_config, + config, status, stdout, stderr, diff --git a/tests/jenkins/TestRunBwcTestScript.groovy b/tests/jenkins/TestRunBwcTestScript.groovy new file mode 100644 index 0000000000..c9f94ade89 --- /dev/null +++ b/tests/jenkins/TestRunBwcTestScript.groovy @@ -0,0 +1,41 @@ +/* + * 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 jenkins.tests.BuildPipelineTest +import org.junit.Before +import org.junit.Test + + +class TestRunBwcTestScript extends BuildPipelineTest { + + @Test + public void TestRunBwcTestScript() { + this.registerLibTester(new RunBwcTestScriptLibTester( + 'dummy_job', + 'tests/jenkins/data/opensearch-1.3.0-build.yml', + 'tests/jenkins/data/opensearch-1.3.0-test.yml', + '717' + ) + ) + + super.testPipeline("tests/jenkins/jobs/RunBwcTestScript_Jenkinsfile") + } + + @Test + public void TestRunBwcTestScript_OpenSearch_Dashboards() { + this.registerLibTester(new RunBwcTestScriptLibTester( + 'dummy_job', + 'tests/jenkins/data/opensearch-dashboards-1.2.0-build.yml', + 'tests/jenkins/data/opensearch-dashboards-1.2.0-test.yml', + '215' + ) + ) + + super.testPipeline("tests/jenkins/jobs/RunBwcTestScript_OpenSearch_Dashboards_Jenkinsfile") + } +} diff --git a/tests/jenkins/TestRunIntegTestScript.groovy b/tests/jenkins/TestRunIntegTestScript.groovy index cf8ee09bb7..b441cc40bb 100644 --- a/tests/jenkins/TestRunIntegTestScript.groovy +++ b/tests/jenkins/TestRunIntegTestScript.groovy @@ -27,7 +27,7 @@ class TestRunIntegTestScript extends BuildPipelineTest { } @Test - public void TestRunIntegTestScript_OpenSearch_Dasbhoards() { + public void TestRunIntegTestScript_OpenSearch_Dashboards() { this.registerLibTester(new RunIntegTestScriptLibTester( 'dummy_job', 'tests/jenkins/data/opensearch-dashboards-1.2.0-build.yml', diff --git a/tests/jenkins/data/opensearch-dashboards-1.2.0-test.yml b/tests/jenkins/data/opensearch-dashboards-1.2.0-test.yml index fd08a7471f..c26a0c3c09 100644 --- a/tests/jenkins/data/opensearch-dashboards-1.2.0-test.yml +++ b/tests/jenkins/data/opensearch-dashboards-1.2.0-test.yml @@ -7,3 +7,8 @@ components: test-configs: - with-security - without-security + - name: queryWorkbenchDashboards + bwc-test: + test-configs: + - with-security + - without-security diff --git a/tests/jenkins/jobs/RunBwcTestScript_Jenkinsfile b/tests/jenkins/jobs/RunBwcTestScript_Jenkinsfile new file mode 100644 index 0000000000..247819aaef --- /dev/null +++ b/tests/jenkins/jobs/RunBwcTestScript_Jenkinsfile @@ -0,0 +1,25 @@ +/* + * 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('bwc-test') { + steps { + script { + runBwcTestScript( + jobName: 'dummy_job', + buildManifest: 'tests/jenkins/data/opensearch-1.3.0-build.yml', + testManifest: 'tests/jenkins/data/opensearch-1.3.0-test.yml', + buildId: '717' + ) + } + } + } + } +} \ No newline at end of file diff --git a/tests/jenkins/jobs/RunBwcTestScript_Jenkinsfile.txt b/tests/jenkins/jobs/RunBwcTestScript_Jenkinsfile.txt new file mode 100644 index 0000000000..69b681d51c --- /dev/null +++ b/tests/jenkins/jobs/RunBwcTestScript_Jenkinsfile.txt @@ -0,0 +1,14 @@ + RunBwcTestScript_Jenkinsfile.run() + RunBwcTestScript_Jenkinsfile.pipeline(groovy.lang.Closure) + RunBwcTestScript_Jenkinsfile.echo(Executing on agent [label:none]) + RunBwcTestScript_Jenkinsfile.stage(bwc-test, groovy.lang.Closure) + RunBwcTestScript_Jenkinsfile.script(groovy.lang.Closure) + RunBwcTestScript_Jenkinsfile.runBwcTestScript({jobName=dummy_job, buildManifest=tests/jenkins/data/opensearch-1.3.0-build.yml, testManifest=tests/jenkins/data/opensearch-1.3.0-test.yml, buildId=717}) + runBwcTestScript.legacySCM(groovy.lang.Closure) + runBwcTestScript.library({identifier=jenkins@20211123, retriever=null}) + runBwcTestScript.readYaml({file=tests/jenkins/data/opensearch-1.3.0-build.yml}) + BuildManifest.asBoolean() + BuildManifest.getArtifactRootUrl(dummy_job, 717) + runBwcTestScript.echo(Artifact root URL: https://ci.opensearch.org/ci/dbc/dummy_job/1.3.0/717/linux/x64) + runBwcTestScript.echo(Paths: opensearch=https://ci.opensearch.org/ci/dbc/dummy_job/1.3.0/717/linux/x64) + runBwcTestScript.sh(./test.sh bwc-test tests/jenkins/data/opensearch-1.3.0-test.yml --paths opensearch=https://ci.opensearch.org/ci/dbc/dummy_job/1.3.0/717/linux/x64) diff --git a/tests/jenkins/jobs/RunBwcTestScript_OpenSearch_Dashboards_Jenkinsfile b/tests/jenkins/jobs/RunBwcTestScript_OpenSearch_Dashboards_Jenkinsfile new file mode 100644 index 0000000000..6990c3cb1d --- /dev/null +++ b/tests/jenkins/jobs/RunBwcTestScript_OpenSearch_Dashboards_Jenkinsfile @@ -0,0 +1,25 @@ +/* + * 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('bwc-test') { + steps { + script { + runBwcTestScript( + jobName: 'dummy_job', + buildManifest: 'tests/jenkins/data/opensearch-dashboards-1.2.0-build.yml', + testManifest: 'tests/jenkins/data/opensearch-dashboards-1.2.0-test.yml', + buildId: '215' + ) + } + } + } + } +} \ No newline at end of file diff --git a/tests/jenkins/jobs/RunBwcTestScript_OpenSearch_Dashboards_Jenkinsfile.txt b/tests/jenkins/jobs/RunBwcTestScript_OpenSearch_Dashboards_Jenkinsfile.txt new file mode 100644 index 0000000000..61ca8ed86a --- /dev/null +++ b/tests/jenkins/jobs/RunBwcTestScript_OpenSearch_Dashboards_Jenkinsfile.txt @@ -0,0 +1,14 @@ + RunBwcTestScript_OpenSearch_Dashboards_Jenkinsfile.run() + RunBwcTestScript_OpenSearch_Dashboards_Jenkinsfile.pipeline(groovy.lang.Closure) + RunBwcTestScript_OpenSearch_Dashboards_Jenkinsfile.echo(Executing on agent [label:none]) + RunBwcTestScript_OpenSearch_Dashboards_Jenkinsfile.stage(bwc-test, groovy.lang.Closure) + RunBwcTestScript_OpenSearch_Dashboards_Jenkinsfile.script(groovy.lang.Closure) + RunBwcTestScript_OpenSearch_Dashboards_Jenkinsfile.runBwcTestScript({jobName=dummy_job, buildManifest=tests/jenkins/data/opensearch-dashboards-1.2.0-build.yml, testManifest=tests/jenkins/data/opensearch-dashboards-1.2.0-test.yml, buildId=215}) + runBwcTestScript.legacySCM(groovy.lang.Closure) + runBwcTestScript.library({identifier=jenkins@20211123, retriever=null}) + runBwcTestScript.readYaml({file=tests/jenkins/data/opensearch-dashboards-1.2.0-build.yml}) + BuildManifest.asBoolean() + BuildManifest.getArtifactRootUrl(dummy_job, 215) + runBwcTestScript.echo(Artifact root URL: https://ci.opensearch.org/ci/dbc/dummy_job/1.2.0/215/linux/x64) + runBwcTestScript.echo(Paths: opensearch-dashboards=https://ci.opensearch.org/ci/dbc/dummy_job/1.2.0/215/linux/x64) + runBwcTestScript.sh(./test.sh bwc-test tests/jenkins/data/opensearch-dashboards-1.2.0-test.yml --paths opensearch-dashboards=https://ci.opensearch.org/ci/dbc/dummy_job/1.2.0/215/linux/x64) diff --git a/tests/jenkins/lib-testers/RunBwcTestScriptLibTest.groovy b/tests/jenkins/lib-testers/RunBwcTestScriptLibTest.groovy new file mode 100644 index 0000000000..5ae2fcf7a6 --- /dev/null +++ b/tests/jenkins/lib-testers/RunBwcTestScriptLibTest.groovy @@ -0,0 +1,39 @@ +import static org.hamcrest.CoreMatchers.notNullValue +import static org.hamcrest.MatcherAssert.assertThat + + +class RunBwcTestScriptLibTester extends LibFunctionTester { + + private String jobName + private String buildManifest + private String testManifest + private String buildId + + public RunBwcTestScriptLibTester(jobName, buildManifest, testManifest, buildId){ + this.jobName = jobName + this.buildManifest = buildManifest + this.testManifest = testManifest + this.buildId = buildId + } + + void configure(helper, binding) { + // N/A + } + + void parameterInvariantsAssertions(call) { + assertThat(call.args.buildManifest.first(), notNullValue()) + assertThat(call.args.testManifest.first(), notNullValue()) + assertThat(call.args.buildId.first(), notNullValue()) + } + + boolean expectedParametersMatcher(call) { + return call.args.jobName.first().toString().equals(this.jobName) + && call.args.buildManifest.first().toString().equals(this.buildManifest) + && call.args.testManifest.first().toString().equals(this.testManifest) + && call.args.buildId.first().toString().equals(this.buildId) + } + + String libFunctionName() { + return 'runBwcTestScript' + } +} diff --git a/vars/runBwcTestScript.groovy b/vars/runBwcTestScript.groovy new file mode 100644 index 0000000000..41f09623c3 --- /dev/null +++ b/vars/runBwcTestScript.groovy @@ -0,0 +1,24 @@ +void call(Map args = [:]) { + String jobName = args.jobName ?: 'distribution-build-opensearch' + lib = library(identifier: 'jenkins@20211123', retriever: legacySCM(scm)) + def buildManifest = lib.jenkins.BuildManifest.new(readYaml(file: args.buildManifest)) + String artifactRootUrl = buildManifest.getArtifactRootUrl(jobName, args.buildId) + echo "Artifact root URL: ${artifactRootUrl}" + + String paths = generatePaths(buildManifest, artifactRootUrl) + echo "Paths: ${paths}" + + sh([ + './test.sh', + 'bwc-test', + "${args.testManifest}", + "--paths ${paths}", + ].join(' ')) +} + +String generatePaths(buildManifest, artifactRootUrl) { + String name = buildManifest.build.name + return name == 'OpenSearch' ? + "opensearch=${artifactRootUrl}" : + "opensearch-dashboards=${artifactRootUrl}" +} \ No newline at end of file