-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add groovy library for smoke test workflow (#569)
Signed-off-by: Zelin Hao <[email protected]>
- Loading branch information
Showing
8 changed files
with
3,830 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,151 @@ | ||
--- | ||
schema-version: '1.0' | ||
name: OpenSearch | ||
ci: | ||
image: | ||
name: opensearchstaging/ci-runner:ci-runner-al2-opensearch-build-v1 | ||
args: -e JAVA_HOME=/opt/java/openjdk-21 | ||
components: | ||
- 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 | ||
- name: anomaly-detection | ||
integ-test: | ||
build-dependencies: | ||
- job-scheduler | ||
test-configs: | ||
- with-security | ||
- without-security | ||
bwc-test: | ||
test-configs: | ||
- with-security | ||
- name: flow-framework | ||
integ-test: | ||
test-configs: | ||
- with-security | ||
- without-security | ||
- name: asynchronous-search | ||
integ-test: | ||
test-configs: | ||
- with-security | ||
- without-security | ||
bwc-test: | ||
test-configs: | ||
- with-security | ||
- name: cross-cluster-replication | ||
integ-test: | ||
topology: | ||
- cluster_name: leader | ||
data_nodes: 2 | ||
- cluster_name: follower | ||
data_nodes: 2 | ||
test-configs: | ||
- with-security | ||
- without-security | ||
- name: geospatial | ||
integ-test: | ||
test-configs: | ||
- with-security | ||
- without-security | ||
- 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 | ||
- name: k-NN | ||
integ-test: | ||
test-configs: | ||
- with-security | ||
- without-security | ||
- name: ml-commons | ||
integ-test: | ||
test-configs: | ||
- with-security | ||
- without-security | ||
- name: neural-search | ||
integ-test: | ||
test-configs: | ||
- with-security | ||
- without-security | ||
- name: notifications | ||
working-directory: notifications | ||
integ-test: | ||
test-configs: | ||
- with-security | ||
- without-security | ||
bwc-test: | ||
test-configs: | ||
- with-security | ||
- name: opensearch-observability | ||
integ-test: | ||
test-configs: | ||
- with-security | ||
- without-security | ||
bwc-test: | ||
test-configs: | ||
- with-security | ||
- name: opensearch-reports | ||
integ-test: | ||
test-configs: | ||
- with-security | ||
- without-security | ||
- name: security | ||
integ-test: | ||
test-configs: | ||
- with-security | ||
- name: security-analytics | ||
integ-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 | ||
plugins.query.datasources.encryption.masterkey: 4fc8fee6a3fd7d6ca01772e5 | ||
bwc-test: | ||
test-configs: | ||
- with-security | ||
- name: custom-codecs | ||
integ-test: | ||
test-configs: | ||
- with-security | ||
- without-security | ||
- name: skills | ||
integ-test: | ||
test-configs: | ||
- with-security | ||
- without-security | ||
- name: query-insights | ||
integ-test: | ||
test-configs: | ||
- with-security | ||
- without-security | ||
- name: opensearch-system-templates | ||
integ-test: | ||
test-configs: | ||
- with-security | ||
- without-security | ||
additional-cluster-configs: | ||
opensearch.experimental.feature.application_templates.enabled: true | ||
cluster.application_templates.enabled: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
/* | ||
* 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 jenkins.tests.BuildPipelineTest | ||
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 TestRunSmokeTestScript extends BuildPipelineTest { | ||
|
||
@Test | ||
public void TestRunSmokeTestScript() { | ||
this.registerLibTester(new RunSmokeTestScriptLibTester( | ||
'dummy_job', | ||
'tests/data/opensearch-2.18.0-build.yml', | ||
'tests/data/opensearch-2.18.0-test.yml', | ||
'1234' | ||
) | ||
) | ||
|
||
binding.setVariable('env', ['BUILD_NUMBER': '9876']) | ||
super.testPipeline("tests/jenkins/jobs/RunSmokeTestScript_Jenkinsfile") | ||
assertThat(getShellCommands('sh', './test.sh'), hasItems('./test.sh smoke-test tests/data/opensearch-2.18.0-test.yml --test-run-id 9876 --paths opensearch=https://ci.opensearch.org/ci/dbc/dummy_job/2.18.0/1234/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 | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
/* | ||
* 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('smoke-test') { | ||
steps { | ||
script { | ||
runSmokeTestScript( | ||
jobName: 'dummy_job', | ||
buildManifest: 'tests/data/opensearch-2.18.0-build.yml', | ||
testManifest: 'tests/data/opensearch-2.18.0-test.yml', | ||
buildId: '1234' | ||
) | ||
} | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
RunSmokeTestScript_Jenkinsfile.run() | ||
RunSmokeTestScript_Jenkinsfile.pipeline(groovy.lang.Closure) | ||
RunSmokeTestScript_Jenkinsfile.echo(Executing on agent [label:none]) | ||
RunSmokeTestScript_Jenkinsfile.stage(smoke-test, groovy.lang.Closure) | ||
RunSmokeTestScript_Jenkinsfile.script(groovy.lang.Closure) | ||
RunSmokeTestScript_Jenkinsfile.runSmokeTestScript({jobName=dummy_job, buildManifest=tests/data/opensearch-2.18.0-build.yml, testManifest=tests/data/opensearch-2.18.0-test.yml, buildId=1234}) | ||
runSmokeTestScript.legacySCM(groovy.lang.Closure) | ||
runSmokeTestScript.library({identifier=jenkins@main, retriever=null}) | ||
runSmokeTestScript.readYaml({file=tests/data/opensearch-2.18.0-build.yml}) | ||
BuildManifest.asBoolean() | ||
BuildManifest.getArtifactRootUrl(dummy_job, 1234) | ||
runSmokeTestScript.echo(Artifact root URL: https://ci.opensearch.org/ci/dbc/dummy_job/2.18.0/1234/linux/x64/tar) | ||
runSmokeTestScript.echo(Paths: opensearch=https://ci.opensearch.org/ci/dbc/dummy_job/2.18.0/1234/linux/x64/tar) | ||
runSmokeTestScript.sh(./test.sh smoke-test tests/data/opensearch-2.18.0-test.yml --test-run-id 9876 --paths opensearch=https://ci.opensearch.org/ci/dbc/dummy_job/2.18.0/1234/linux/x64/tar) |
47 changes: 47 additions & 0 deletions
47
tests/jenkins/lib-testers/RunSmokeTestScriptLibTester.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
/* | ||
* 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 RunSmokeTestScriptLibTester extends LibFunctionTester { | ||
|
||
private String jobName | ||
private String buildManifest | ||
private String testManifest | ||
private String buildId | ||
|
||
public RunSmokeTestScriptLibTester(jobName, buildManifest, testManifest, buildId){ | ||
this.jobName = jobName | ||
this.buildManifest = buildManifest | ||
this.testManifest = testManifest | ||
this.buildId = buildId | ||
} | ||
|
||
void configure(helper, binding) { | ||
binding.setVariable('env', ['BUILD_NUMBER': '9876']) | ||
} | ||
|
||
void parameterInvariantsAssertions(call) { | ||
assertThat(call.args.buildManifest.first().toString(), notNullValue()) | ||
assertThat(call.args.testManifest.first().toString(), notNullValue()) | ||
assertThat(call.args.buildId.first().toString(), 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 'runSmokeTestScript' | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
/* | ||
* 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 execute the smoke test workflow | ||
* | ||
* @param args A map of the following parameters | ||
* @param args.testManifest <required> Test manifest file location | ||
* @param args.buildManifest <required> Build manifest file location | ||
* @param args.buildId <required> Build ID of the distribution artifacts | ||
* @param args.jobName <optional> Job name that triggered the workflow. 'distribution-build-opensearh' by default. | ||
*/ | ||
void call(Map args = [:]) { | ||
String jobName = args.jobName ?: 'distribution-build-opensearch' | ||
lib = library(identifier: 'jenkins@main', 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 = "opensearch=${artifactRootUrl}" | ||
echo "Paths: ${paths}" | ||
|
||
sh([ | ||
'./test.sh', | ||
'smoke-test', | ||
"${args.testManifest}", | ||
"--test-run-id ${env.BUILD_NUMBER}", | ||
"--paths ${paths}", | ||
].join(' ')) | ||
} |