Skip to content

Commit

Permalink
[Tests][BWC] add BWC tests to Jenkins
Browse files Browse the repository at this point in the history
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 <kavilla414@gmail.com>
  • Loading branch information
kavilla committed Mar 22, 2022
1 parent 4ada5c4 commit c0c923d
Show file tree
Hide file tree
Showing 14 changed files with 565 additions and 3 deletions.
141 changes: 141 additions & 0 deletions jenkins/opensearch-dashboards/bwc-test.jenkinsfile
Original file line number Diff line number Diff line change
@@ -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()
}
}
}
}
}
46 changes: 46 additions & 0 deletions jenkins/opensearch-dashboards/distribution-build.jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -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.',
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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 {
Expand Down
142 changes: 142 additions & 0 deletions jenkins/opensearch/bwc-test.jenkinsfile
Original file line number Diff line number Diff line change
@@ -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()
}
}
}
}
}
Loading

0 comments on commit c0c923d

Please sign in to comment.