-
Notifications
You must be signed in to change notification settings - Fork 25
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add groovy library for smoke test workflow #569
Merged
+3,830
−1
Merged
Changes from 4 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.jobName <optional> Job name that triggered the workflow. 'distribution-build-opensearh' by default. | ||
zelinh marked this conversation as resolved.
Show resolved
Hide resolved
|
||
* @param args.buildId <required> Build ID of the distribution artifacts | ||
*/ | ||
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(' ')) | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you add comments to list all the args
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added. Thanks.