Skip to content

Commit 610023b

Browse files
authored
Upload smoke tests results to S3 and generate test-reports (#5509)
Signed-off-by: Zelin Hao <[email protected]>
1 parent 93296ec commit 610023b

File tree

4 files changed

+174
-16
lines changed

4 files changed

+174
-16
lines changed

jenkins/opensearch/smoke-test.jenkinsfile

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* compatible open source license.
88
*/
99

10-
lib = library(identifier: 'jenkins@8.1.1', retriever: modernSCM([
10+
lib = library(identifier: 'jenkins@9.1.2', retriever: modernSCM([
1111
$class: 'GitSCMSource',
1212
remote: 'https://github.com/opensearch-project/opensearch-build-libraries.git',
1313
]))
@@ -53,6 +53,11 @@ pipeline {
5353
description: 'The build manifest URL for OpenSearch, e.g. "https://ci.opensearch.org/ci/dbc/distribution-build-opensearch/2.19.0/10545/linux/x64/tar/builds/opensearch/manifest.yml".',
5454
trim: true
5555
)
56+
string(
57+
name: 'RC_NUMBER',
58+
description: 'The RC build count. Default is 0 which means its not an RC build.',
59+
defaultValue: '0'
60+
)
5661
}
5762
stages {
5863
stage('verify-parameters') {
@@ -131,13 +136,34 @@ pipeline {
131136
throw new Exception("Error running Smoke test", e)
132137
} finally {
133138
echo "Completed running smoke tests."
139+
uploadTestResults(
140+
buildManifestFileName: BUILD_MANIFEST,
141+
jobName: env.JOB_NAME
142+
)
134143
postCleanup()
135144
}
136145
}
137146
}
138147
post {
139148
always {
140-
postCleanup()
149+
script {
150+
checkout scm
151+
sleep 10
152+
downloadBuildManifest(
153+
url: BUILD_MANIFEST_URL,
154+
path: BUILD_MANIFEST
155+
)
156+
createUploadTestReportManifest(
157+
testManifest: "manifests/${TEST_MANIFEST}",
158+
buildManifest: BUILD_MANIFEST,
159+
testRunID: "${env.BUILD_NUMBER}",
160+
testType: 'smoke-test',
161+
rcNumber: params.RC_NUMBER
162+
)
163+
echo("Download report manifest from https://ci.opensearch.org/ci/dbc/smoke-test/${env.version}/${env.buildId}/${env.platform}/${env.architecture}/${env.distribution}/test-results/${env.BUILD_NUMBER}/smoke-test/test-report.yml")
164+
archiveArtifacts artifacts: 'test-report.yml'
165+
postCleanup()
166+
}
141167
}
142168
}
143169
}

tests/jenkins/TestSmokeTest.groovy

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ class TestSmokeTest extends BuildPipelineTest {
2323

2424
helper.registerSharedLibrary(
2525
library().name('jenkins')
26-
.defaultVersion('8.1.1')
26+
.defaultVersion('9.1.2')
2727
.allowOverride(true)
2828
.implicit(true)
2929
.targetPath('vars')
@@ -35,12 +35,31 @@ class TestSmokeTest extends BuildPipelineTest {
3535

3636
def jobName = "dummy_job"
3737
def agentLabel = "Jenkins-Agent-AL2-X64-C54xlarge-Docker-Host"
38+
def bucketName = 'job-s3-bucket-name'
3839

3940
binding.setVariable('env', ['BUILD_NUMBER': '234', 'PUBLIC_ARTIFACT_URL': 'DUMMY_PUBLIC_ARTIFACT_URL', 'JOB_NAME': 'dummy_job', 'DOCKER_AGENT':[image:'opensearchstaging/ci-runner:ci-runner-centos7-v1', args:'-e JAVA_HOME=/opt/java/openjdk-11']])
4041
binding.setVariable('BUILD_JOB_NAME', 'dummy_job')
4142
binding.setVariable('AGENT_LABEL', agentLabel)
4243
binding.setVariable('BUILD_NUMBER', '234')
43-
44+
binding.setVariable('PUBLIC_ARTIFACT_URL', 'DUMMY_PUBLIC_ARTIFACT_URL')
45+
binding.setVariable('STAGE_NAME', 'DUMMY_STAGE_NAME')
46+
binding.setVariable('JOB_NAME', 'dummy_job')
47+
binding.setVariable('BUILD_URL', 'htth://BUILD_URL_dummy.com')
48+
binding.setVariable('WEBHOOK_URL', 'htth://WEBHOOK_URL_dummy.com')
49+
binding.setVariable('AGENT_LABEL', agentLabel)
50+
binding.setVariable('BUILD_NUMBER', '234')
51+
binding.setVariable('ARTIFACT_BUCKET_NAME', bucketName)
52+
binding.setVariable('RUN_DISPLAY_URL', 'https://some/url/redirect')
53+
binding.setVariable('COMPONENT_NAME', '' )
54+
binding.setVariable('RC_NUMBER', '0')
55+
binding.getVariable('currentBuild').upstreamBuilds = [[fullProjectName: jobName]]
56+
helper.registerAllowedMethod("s3Download", [Map])
57+
helper.registerAllowedMethod("withAWS", [Map, Closure], { args, closure ->
58+
closure.delegate = delegate
59+
return helper.callClosure(closure)
60+
})
61+
helper.registerAllowedMethod("s3Upload", [Map])
62+
helper.registerAllowedMethod('findFiles', [Map.class], null)
4463
helper.registerAllowedMethod('unstash', [String.class], null)
4564
}
4665

@@ -68,6 +87,9 @@ class TestSmokeTest extends BuildPipelineTest {
6887
super.testPipeline('jenkins/opensearch/smoke-test.jenkinsfile',
6988
'tests/jenkins/jenkinsjob-regression-files/opensearch/smoke-test.jenkinsfile')
7089
assertThat(getCommandExecutions('sh', 'test.sh'), hasItem(' ./test.sh smoke-test manifests/tests/jenkins/data/opensearch-2.19.0-test.yml --test-run-id 234 --paths opensearch=https://ci.opensearch.org/ci/dbc/dummy_job/2.19.0/10545/linux/x64/tar '))
90+
assertThat(getCommandExecutions('s3Upload', ''), hasItem('{file=test-results, bucket=ARTIFACT_BUCKET_NAME, path=dummy_job/2.19.0/10545/linux/x64/tar/test-results}'))
91+
assertThat(getCommandExecutions('sh', 'report.sh'), hasItem('./report.sh manifests/tests/jenkins/data/opensearch-2.19.0-test.yml --artifact-paths opensearch=https://ci.opensearch.org/ci/dbc/distribution-build-opensearch/2.19.0/10545/linux/x64/tar --test-run-id 234 --test-type smoke-test --base-path DUMMY_PUBLIC_ARTIFACT_URL/dummy_job/2.19.0/10545/linux/x64/tar --release-candidate 0 '))
92+
7193
}
7294

7395
@Test
@@ -94,6 +116,8 @@ class TestSmokeTest extends BuildPipelineTest {
94116
super.testPipeline('jenkins/opensearch/smoke-test.jenkinsfile',
95117
'tests/jenkins/jenkinsjob-regression-files/opensearch/smoke-test-rpm.jenkinsfile')
96118
assertThat(getCommandExecutions('sh', 'test.sh'), hasItem('su `id -un 1000` -c \" ./test.sh smoke-test manifests/tests/jenkins/data/opensearch-2.19.0-test.yml --test-run-id 234 --paths opensearch=https://ci.opensearch.org/ci/dbc/dummy_job/2.19.0/10691/linux/arm64/rpm \"'))
119+
assertThat(getCommandExecutions('s3Upload', ''), hasItem('{file=/tmp/workspace/test-report.yml, bucket=ARTIFACT_BUCKET_NAME, path=dummy_job/2.19.0/10691/linux/arm64/rpm/test-results/234/smoke-test/test-report.yml}'))
120+
assertThat(getCommandExecutions('sh', 'report.sh'), hasItem('./report.sh manifests/tests/jenkins/data/opensearch-2.19.0-test.yml --artifact-paths opensearch=https://ci.opensearch.org/ci/dbc/distribution-build-opensearch/2.19.0/10691/linux/arm64/rpm --test-run-id 234 --test-type smoke-test --base-path DUMMY_PUBLIC_ARTIFACT_URL/dummy_job/2.19.0/10691/linux/arm64/rpm --release-candidate 0 '))
97121
}
98122

99123
@Test

tests/jenkins/jenkinsjob-regression-files/opensearch/smoke-test-rpm.jenkinsfile.txt

Lines changed: 60 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
smoke-test.run()
22
smoke-test.modernSCM({$class=GitSCMSource, remote=https://github.com/opensearch-project/opensearch-build-libraries.git})
3-
smoke-test.library({identifier=jenkins@8.1.1, retriever=null})
3+
smoke-test.library({identifier=jenkins@9.1.2, retriever=null})
44
smoke-test.pipeline(groovy.lang.Closure)
55
smoke-test.credentials(jenkins-artifact-bucket-name)
66
smoke-test.timeout({time=2, unit=HOURS})
@@ -11,7 +11,7 @@
1111
smoke-test.fileExists(manifests/tests/jenkins/data/opensearch-2.19.0-test.yml)
1212
smoke-test.downloadBuildManifest({url=https://ci.opensearch.org/ci/dbc/distribution-build-opensearch/2.19.0/10691/linux/arm64/rpm/builds/opensearch/manifest.yml, path=tests/jenkins/data/opensearch-2.19.0-build-rpm.yml})
1313
downloadBuildManifest.legacySCM(groovy.lang.Closure)
14-
downloadBuildManifest.library({identifier=jenkins@8.1.1, retriever=null})
14+
downloadBuildManifest.library({identifier=jenkins@9.1.2, retriever=null})
1515
downloadBuildManifest.sh(mkdir -p $(dirname "tests/jenkins/data/opensearch-2.19.0-build-rpm.yml"))
1616
downloadBuildManifest.sh(touch tests/jenkins/data/opensearch-2.19.0-build-rpm.yml)
1717
downloadBuildManifest.sh(curl -sSL --retry 5 https://ci.opensearch.org/ci/dbc/distribution-build-opensearch/2.19.0/10691/linux/arm64/rpm/builds/opensearch/manifest.yml --output tests/jenkins/data/opensearch-2.19.0-build-rpm.yml)
@@ -33,7 +33,7 @@
3333
smoke-test.checkout(groovy.lang.Closure)
3434
smoke-test.downloadBuildManifest({url=https://ci.opensearch.org/ci/dbc/distribution-build-opensearch/2.19.0/10691/linux/arm64/rpm/builds/opensearch/manifest.yml, path=tests/jenkins/data/opensearch-2.19.0-build-rpm.yml})
3535
downloadBuildManifest.legacySCM(groovy.lang.Closure)
36-
downloadBuildManifest.library({identifier=jenkins@8.1.1, retriever=null})
36+
downloadBuildManifest.library({identifier=jenkins@9.1.2, retriever=null})
3737
downloadBuildManifest.sh(mkdir -p $(dirname "tests/jenkins/data/opensearch-2.19.0-build-rpm.yml"))
3838
downloadBuildManifest.sh(touch tests/jenkins/data/opensearch-2.19.0-build-rpm.yml)
3939
downloadBuildManifest.sh(curl -sSL --retry 5 https://ci.opensearch.org/ci/dbc/distribution-build-opensearch/2.19.0/10691/linux/arm64/rpm/builds/opensearch/manifest.yml --output tests/jenkins/data/opensearch-2.19.0-build-rpm.yml)
@@ -46,7 +46,7 @@
4646
smoke-test.sh(rm -rf test-results)
4747
smoke-test.runSmokeTestScript({jobName=dummy_job, buildManifest=tests/jenkins/data/opensearch-2.19.0-build-rpm.yml, testManifest=manifests/tests/jenkins/data/opensearch-2.19.0-test.yml, buildId=10691, switchUserNonRoot=true})
4848
runSmokeTestScript.legacySCM(groovy.lang.Closure)
49-
runSmokeTestScript.library({identifier=jenkins@8.1.1, retriever=null})
49+
runSmokeTestScript.library({identifier=jenkins@9.1.2, retriever=null})
5050
runSmokeTestScript.readYaml({file=tests/jenkins/data/opensearch-2.19.0-build-rpm.yml})
5151
BuildManifest.asBoolean()
5252
BuildManifest.getArtifactRootUrl(dummy_job, 10691)
@@ -55,10 +55,64 @@
5555
runSmokeTestScript.echo(Paths: opensearch=https://ci.opensearch.org/ci/dbc/dummy_job/2.19.0/10691/linux/arm64/rpm)
5656
runSmokeTestScript.sh(su `id -un 1000` -c " ./test.sh smoke-test manifests/tests/jenkins/data/opensearch-2.19.0-test.yml --test-run-id 234 --paths opensearch=https://ci.opensearch.org/ci/dbc/dummy_job/2.19.0/10691/linux/arm64/rpm ")
5757
smoke-test.echo(Completed running smoke tests.)
58+
smoke-test.uploadTestResults({buildManifestFileName=tests/jenkins/data/opensearch-2.19.0-build-rpm.yml, jobName=dummy_job})
59+
uploadTestResults.legacySCM(groovy.lang.Closure)
60+
uploadTestResults.library({[email protected], retriever=null})
61+
uploadTestResults.readYaml({file=tests/jenkins/data/opensearch-2.19.0-build-rpm.yml})
62+
BuildManifest.asBoolean()
63+
uploadTestResults.echo(Build Id: 10691)
64+
BuildManifest.getArtifactRoot(dummy_job, 10691)
65+
uploadTestResults.string({credentialsId=jenkins-artifact-bucket-name, variable=ARTIFACT_BUCKET_NAME})
66+
uploadTestResults.string({credentialsId=jenkins-aws-account-public, variable=AWS_ACCOUNT_PUBLIC})
67+
uploadTestResults.withCredentials([ARTIFACT_BUCKET_NAME, AWS_ACCOUNT_PUBLIC], groovy.lang.Closure)
68+
uploadTestResults.echo(Uploading to s3://ARTIFACT_BUCKET_NAME/dummy_job/2.19.0/10691/linux/arm64/rpm)
69+
uploadTestResults.withAWS({role=opensearch-test, roleAccount=AWS_ACCOUNT_PUBLIC, duration=900, roleSessionName=jenkins-session}, groovy.lang.Closure)
70+
uploadTestResults.s3Upload({file=test-results, bucket=ARTIFACT_BUCKET_NAME, path=dummy_job/2.19.0/10691/linux/arm64/rpm/test-results})
71+
BuildManifest.getArtifactRootUrl(DUMMY_PUBLIC_ARTIFACT_URL, dummy_job)
72+
Messages.asBoolean()
73+
Messages.add(DUMMY_STAGE_NAME, https://ci.opensearch.org/ci/dbc/DUMMY_PUBLIC_ARTIFACT_URL/2.19.0/dummy_job/linux/arm64/rpm/test-results/)
74+
uploadTestResults.writeFile({file=messages/DUMMY_STAGE_NAME.msg, text=https://ci.opensearch.org/ci/dbc/DUMMY_PUBLIC_ARTIFACT_URL/2.19.0/dummy_job/linux/arm64/rpm/test-results/})
75+
uploadTestResults.stash({includes=messages/*, name=messages-DUMMY_STAGE_NAME})
5876
smoke-test.postCleanup()
5977
postCleanup.cleanWs({disableDeferredWipeout=true, deleteDirs=true})
60-
smoke-test.postCleanup()
61-
postCleanup.cleanWs({disableDeferredWipeout=true, deleteDirs=true})
78+
smoke-test.script(groovy.lang.Closure)
79+
smoke-test.checkout(groovy.lang.Closure)
80+
smoke-test.downloadBuildManifest({url=https://ci.opensearch.org/ci/dbc/distribution-build-opensearch/2.19.0/10691/linux/arm64/rpm/builds/opensearch/manifest.yml, path=tests/jenkins/data/opensearch-2.19.0-build-rpm.yml})
81+
downloadBuildManifest.legacySCM(groovy.lang.Closure)
82+
downloadBuildManifest.library({[email protected], retriever=null})
83+
downloadBuildManifest.sh(mkdir -p $(dirname "tests/jenkins/data/opensearch-2.19.0-build-rpm.yml"))
84+
downloadBuildManifest.sh(touch tests/jenkins/data/opensearch-2.19.0-build-rpm.yml)
85+
downloadBuildManifest.sh(curl -sSL --retry 5 https://ci.opensearch.org/ci/dbc/distribution-build-opensearch/2.19.0/10691/linux/arm64/rpm/builds/opensearch/manifest.yml --output tests/jenkins/data/opensearch-2.19.0-build-rpm.yml)
86+
downloadBuildManifest.readYaml({file=tests/jenkins/data/opensearch-2.19.0-build-rpm.yml})
87+
BuildManifest.asBoolean()
88+
smoke-test.createUploadTestReportManifest({testManifest=manifests/tests/jenkins/data/opensearch-2.19.0-test.yml, buildManifest=tests/jenkins/data/opensearch-2.19.0-build-rpm.yml, testRunID=234, testType=smoke-test, rcNumber=0})
89+
createUploadTestReportManifest.legacySCM(groovy.lang.Closure)
90+
createUploadTestReportManifest.library({[email protected], retriever=null})
91+
createUploadTestReportManifest.readYaml({file=manifests/tests/jenkins/data/opensearch-2.19.0-test.yml})
92+
TestManifest.asBoolean()
93+
createUploadTestReportManifest.readYaml({file=tests/jenkins/data/opensearch-2.19.0-build-rpm.yml})
94+
BuildManifest.asBoolean()
95+
BuildManifest.getDistribution()
96+
createUploadTestReportManifest.echo(Start Reporting workflow for test type: rpm)
97+
BuildManifest.getArtifactRootUrl(distribution-build-opensearch, 10691)
98+
createUploadTestReportManifest.echo(Artifact root URL: https://ci.opensearch.org/ci/dbc/distribution-build-opensearch/2.19.0/10691/linux/arm64/rpm)
99+
createUploadTestReportManifest.echo(Paths: opensearch=https://ci.opensearch.org/ci/dbc/distribution-build-opensearch/2.19.0/10691/linux/arm64/rpm)
100+
createUploadTestReportManifest.echo(Base Path DUMMY_PUBLIC_ARTIFACT_URL/dummy_job/2.19.0/10691/linux/arm64/rpm)
101+
createUploadTestReportManifest.echo(Component: null)
102+
createUploadTestReportManifest.echo(Run command: ./report.sh manifests/tests/jenkins/data/opensearch-2.19.0-test.yml --artifact-paths opensearch=https://ci.opensearch.org/ci/dbc/distribution-build-opensearch/2.19.0/10691/linux/arm64/rpm --test-run-id 234 --test-type smoke-test --base-path DUMMY_PUBLIC_ARTIFACT_URL/dummy_job/2.19.0/10691/linux/arm64/rpm --release-candidate 0 )
103+
createUploadTestReportManifest.sh(./report.sh manifests/tests/jenkins/data/opensearch-2.19.0-test.yml --artifact-paths opensearch=https://ci.opensearch.org/ci/dbc/distribution-build-opensearch/2.19.0/10691/linux/arm64/rpm --test-run-id 234 --test-type smoke-test --base-path DUMMY_PUBLIC_ARTIFACT_URL/dummy_job/2.19.0/10691/linux/arm64/rpm --release-candidate 0 )
104+
createUploadTestReportManifest.echo(Build Id: 10691)
105+
BuildManifest.getArtifactRoot(dummy_job, 10691)
106+
createUploadTestReportManifest.string({credentialsId=jenkins-artifact-bucket-name, variable=ARTIFACT_BUCKET_NAME})
107+
createUploadTestReportManifest.string({credentialsId=jenkins-aws-account-public, variable=AWS_ACCOUNT_PUBLIC})
108+
createUploadTestReportManifest.withCredentials([ARTIFACT_BUCKET_NAME, AWS_ACCOUNT_PUBLIC], groovy.lang.Closure)
109+
createUploadTestReportManifest.echo(Uploading to s3://dummy_job/2.19.0/10691/linux/arm64/rpm/test-results/234/smoke-test/test-report.yml)
110+
createUploadTestReportManifest.withAWS({role=opensearch-test, roleAccount=AWS_ACCOUNT_PUBLIC, duration=900, roleSessionName=jenkins-session}, groovy.lang.Closure)
111+
createUploadTestReportManifest.s3Upload({file=/tmp/workspace/test-report.yml, bucket=ARTIFACT_BUCKET_NAME, path=dummy_job/2.19.0/10691/linux/arm64/rpm/test-results/234/smoke-test/test-report.yml})
112+
smoke-test.echo(Download report manifest from https://ci.opensearch.org/ci/dbc/smoke-test/2.19.0/10691/linux/arm64/rpm/test-results/234/smoke-test/test-report.yml)
113+
smoke-test.archiveArtifacts({artifacts=test-report.yml})
114+
smoke-test.postCleanup()
115+
postCleanup.cleanWs({disableDeferredWipeout=true, deleteDirs=true})
62116
smoke-test.node(Jenkins-Agent-AL2-X64-C54xlarge-Docker-Host, groovy.lang.Closure)
63117
smoke-test.script(groovy.lang.Closure)
64118
smoke-test.postCleanup()

0 commit comments

Comments
 (0)