Skip to content

Commit c0c923d

Browse files
committed
[Tests][BWC] add BWC tests to Jenkins
For OpenSearch and OpenSearch Dashboards. Also fix a bug with the test config showing incorrectly. Issue resolved: opensearch-project#705 Signed-off-by: Kawika Avilla <[email protected]>
1 parent 4ada5c4 commit c0c923d

14 files changed

+565
-3
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,141 @@
1+
lib = library(identifier: "jenkins@20211118", retriever: legacySCM(scm))
2+
3+
pipeline {
4+
options {
5+
timeout(time: 3, unit: 'HOURS')
6+
}
7+
agent none
8+
environment {
9+
BUILD_MANIFEST = "build-manifest.yml"
10+
DEFAULT_BUILD_JOB_NAME = "distribution-build-opensearch-dashboards"
11+
}
12+
parameters {
13+
string(
14+
name: 'TEST_MANIFEST',
15+
description: 'Test manifest under the manifests folder, e.g. 2.0.0/opensearch-dashboards-2.0.0-test.yml.',
16+
trim: true
17+
)
18+
string(
19+
name: 'BUILD_MANIFEST_URL',
20+
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.',
21+
trim: true
22+
)
23+
string(
24+
name: 'AGENT_LABEL',
25+
description: 'The agent label where the tests should be executed, e.g. Jenkins-Agent-al2-x64-c54xlarge-Docker-Host.',
26+
trim: true
27+
)
28+
}
29+
stages {
30+
stage('verify-parameters') {
31+
agent {
32+
node {
33+
label AGENT_LABEL
34+
}
35+
}
36+
steps {
37+
script {
38+
if (AGENT_LABEL == '') {
39+
currentBuild.result = 'ABORTED'
40+
error("BWC Tests failed to start. Missing parameter: AGENT_LABEL.")
41+
}
42+
if (!fileExists("manifests/${TEST_MANIFEST}")) {
43+
currentBuild.result = 'ABORTED'
44+
error("BWC Tests failed to start. Test manifest not found in manifests/${TEST_MANIFEST}.")
45+
}
46+
env.BUILD_JOB_NAME = currentBuild.upstreamBuilds ?
47+
currentBuild.upstreamBuilds[0].fullProjectName :
48+
env.DEFAULT_BUILD_JOB_NAME
49+
}
50+
}
51+
}
52+
stage('detect docker image + args') {
53+
agent {
54+
docker {
55+
label 'Jenkins-Agent-al2-x64-c54xlarge-Docker-Host'
56+
image 'opensearchstaging/ci-runner:centos7-x64-arm64-jdkmulti-node10.24.1-cypress6.9.1-20211028'
57+
alwaysPull true
58+
}
59+
}
60+
steps {
61+
script {
62+
dockerAgent = detectTestDockerAgent()
63+
}
64+
}
65+
}
66+
stage('bwc-test') {
67+
agent {
68+
docker {
69+
label AGENT_LABEL
70+
image dockerAgent.image
71+
args dockerAgent.args
72+
alwaysPull true
73+
}
74+
}
75+
steps {
76+
script {
77+
def buildManifestObj = downloadBuildManifest(
78+
url: BUILD_MANIFEST_URL,
79+
path: BUILD_MANIFEST
80+
)
81+
String buildId = buildManifestObj.getArtifactBuildId()
82+
env.BUILD_ID = buildId
83+
echo "BUILD_MANIFEST: ${BUILD_MANIFEST}"
84+
echo "BUILD_ID: ${BUILD_ID}"
85+
86+
runBwcTestScript(
87+
jobName: BUILD_JOB_NAME,
88+
buildManifest: BUILD_MANIFEST,
89+
testManifest: "manifests/${TEST_MANIFEST}",
90+
buildId: BUILD_ID
91+
)
92+
}
93+
}
94+
post {
95+
always {
96+
script {
97+
uploadTestResults(
98+
buildManifestFileName: BUILD_MANIFEST,
99+
jobName: JOB_NAME,
100+
buildNumber: BUILD_ID
101+
)
102+
}
103+
postCleanup()
104+
}
105+
}
106+
}
107+
}
108+
109+
post {
110+
success {
111+
node(AGENT_LABEL) {
112+
script {
113+
def stashed = lib.jenkins.Messages.new(this).get(['bwc-test'])
114+
publishNotification(
115+
icon: ':white_check_mark:',
116+
message: 'BWC Tests Successful',
117+
extra: stashed,
118+
credentialsId: 'INTEG_TEST_WEBHOOK',
119+
)
120+
121+
postCleanup()
122+
}
123+
}
124+
}
125+
failure {
126+
node(AGENT_LABEL) {
127+
script {
128+
def stashed = lib.jenkins.Messages.new(this).get(['bwc-test'])
129+
publishNotification(
130+
icon: ':warning:',
131+
message: 'Failed BWC Tests',
132+
extra: stashed,
133+
credentialsId: 'INTEG_TEST_WEBHOOK',
134+
)
135+
136+
postCleanup()
137+
}
138+
}
139+
}
140+
}
141+
}

jenkins/opensearch-dashboards/distribution-build.jenkinsfile

+46
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,12 @@ pipeline {
2828
defaultValue: "integ-test-opensearch-dashboards",
2929
trim: true
3030
)
31+
string(
32+
name: 'BWC_TEST_JOB_NAME',
33+
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.",
34+
defaultValue: "bwc-test-opensearch-dashboards",
35+
trim: true
36+
)
3137
booleanParam(
3238
name: 'BUILD_DOCKER',
3339
description: 'Build docker image or not.',
@@ -98,6 +104,26 @@ pipeline {
98104
absoluteUrl: integTestResults.getAbsoluteUrl()
99105
)
100106
}
107+
108+
Boolean skipBwcTests = BWC_TEST_JOB_NAME == ''
109+
echo "${skipBwcTests ? 'Skipping BWC tests' : 'Running BWC tests'}"
110+
if (!skipBwcTests) {
111+
def bwcTestResults =
112+
build job: BWC_TEST_JOB_NAME,
113+
propagate: false,
114+
wait: true,
115+
parameters: [
116+
string(name: 'TEST_MANIFEST', value: TEST_MANIFEST),
117+
string(name: 'BUILD_MANIFEST_URL', value: buildManifestUrl),
118+
string(name: 'AGENT_LABEL', value: AGENT_X64)
119+
]
120+
121+
createTestResultsMessage(
122+
testType: "BWC Tests (x64)",
123+
status: bwcTestResults.getResult(),
124+
absoluteUrl: bwcTestResults.getAbsoluteUrl()
125+
)
126+
}
101127
}
102128
}
103129
post {
@@ -175,6 +201,26 @@ pipeline {
175201
absoluteUrl: integTestResults.getAbsoluteUrl()
176202
)
177203
}
204+
205+
Boolean skipBwcTests = BWC_TEST_JOB_NAME == ''
206+
echo "${skipBwcTests ? 'Skipping BWC tests' : 'Running BWC tests'}"
207+
if (!skipBwcTests) {
208+
def bwcTestResults =
209+
build job: BWC_TEST_JOB_NAME,
210+
propagate: false,
211+
wait: true,
212+
parameters: [
213+
string(name: 'TEST_MANIFEST', value: TEST_MANIFEST),
214+
string(name: 'BUILD_MANIFEST_URL', value: buildManifestUrl),
215+
string(name: 'AGENT_LABEL', value: AGENT_ARM64)
216+
]
217+
218+
createTestResultsMessage(
219+
testType: "BWC Tests (arm64)",
220+
status: bwcTestResults.getResult(),
221+
absoluteUrl: bwcTestResults.getAbsoluteUrl()
222+
)
223+
}
178224
}
179225
}
180226
post {
+142
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,142 @@
1+
lib = library(identifier: "jenkins@20211118", retriever: legacySCM(scm))
2+
3+
pipeline {
4+
agent none
5+
environment {
6+
BUILD_MANIFEST = "build-manifest.yml"
7+
DEFAULT_BUILD_JOB_NAME = "distribution-build-opensearch"
8+
}
9+
tools {
10+
jdk "JDK14"
11+
maven "maven-3.8.2"
12+
}
13+
parameters {
14+
string(
15+
name: 'TEST_MANIFEST',
16+
description: 'Test manifest under the manifests folder, e.g. 2.0.0/opensearch-2.0.0-test.yml.',
17+
trim: true
18+
)
19+
string(
20+
name: 'BUILD_MANIFEST_URL',
21+
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.',
22+
trim: true
23+
)
24+
string(
25+
name: 'AGENT_LABEL',
26+
description: 'The agent label where the tests should be executed, e.g. Jenkins-Agent-al2-x64-c54xlarge-Docker-Host.',
27+
trim: true
28+
)
29+
}
30+
stages {
31+
stage('verify-parameters') {
32+
agent {
33+
node {
34+
label AGENT_LABEL
35+
}
36+
}
37+
steps {
38+
script {
39+
if (AGENT_LABEL == '') {
40+
currentBuild.result = 'ABORTED'
41+
error("BWC Tests failed to start. Missing parameter: AGENT_LABEL.")
42+
}
43+
if (!fileExists("manifests/${TEST_MANIFEST}")) {
44+
currentBuild.result = 'ABORTED'
45+
error("BWC Tests failed to start. Test manifest not found in manifests/${TEST_MANIFEST}.")
46+
}
47+
env.BUILD_JOB_NAME = currentBuild.upstreamBuilds ?
48+
currentBuild.upstreamBuilds[0].fullProjectName :
49+
env.DEFAULT_BUILD_JOB_NAME
50+
}
51+
}
52+
}
53+
stage('detect docker image + args') {
54+
agent {
55+
docker {
56+
label 'Jenkins-Agent-al2-x64-c54xlarge-Docker-Host'
57+
image 'opensearchstaging/ci-runner:centos7-x64-arm64-jdkmulti-node10.24.1-cypress6.9.1-20211028'
58+
alwaysPull true
59+
}
60+
}
61+
steps {
62+
script {
63+
dockerAgent = detectTestDockerAgent()
64+
}
65+
}
66+
}
67+
stage('bwc-test') {
68+
agent {
69+
docker {
70+
label AGENT_LABEL
71+
image dockerAgent.image
72+
args dockerAgent.args
73+
alwaysPull true
74+
}
75+
}
76+
steps {
77+
script {
78+
def buildManifestObj = downloadBuildManifest(
79+
url: BUILD_MANIFEST_URL,
80+
path: BUILD_MANIFEST
81+
)
82+
String buildId = buildManifestObj.getArtifactBuildId()
83+
env.BUILD_ID = buildId
84+
echo "BUILD_MANIFEST: ${BUILD_MANIFEST}"
85+
echo "BUILD_ID: ${BUILD_ID}"
86+
87+
runBwcTestScript(
88+
jobName: BUILD_JOB_NAME,
89+
buildManifest: BUILD_MANIFEST,
90+
testManifest: "manifests/${TEST_MANIFEST}",
91+
buildId: BUILD_ID
92+
)
93+
}
94+
}
95+
post {
96+
always {
97+
script {
98+
uploadTestResults(
99+
buildManifestFileName: BUILD_MANIFEST,
100+
jobName: JOB_NAME,
101+
buildNumber: BUILD_ID
102+
)
103+
}
104+
postCleanup()
105+
}
106+
}
107+
}
108+
}
109+
110+
post {
111+
success {
112+
node(AGENT_LABEL) {
113+
script {
114+
def stashed = lib.jenkins.Messages.new(this).get(['bwc-test'])
115+
publishNotification(
116+
icon: ':white_check_mark:',
117+
message: 'BWC Tests Successful',
118+
extra: stashed,
119+
credentialsId: 'INTEG_TEST_WEBHOOK',
120+
)
121+
122+
postCleanup()
123+
}
124+
}
125+
}
126+
failure {
127+
node(AGENT_LABEL) {
128+
script {
129+
def stashed = lib.jenkins.Messages.new(this).get(['bwc-test'])
130+
publishNotification(
131+
icon: ':warning:',
132+
message: 'Failed BWC Tests',
133+
extra: stashed,
134+
credentialsId: 'INTEG_TEST_WEBHOOK',
135+
)
136+
137+
postCleanup()
138+
}
139+
}
140+
}
141+
}
142+
}

0 commit comments

Comments
 (0)