Skip to content

Commit

Permalink
[Build][Test] OS and OSD improvements plus support for Playground (op…
Browse files Browse the repository at this point in the history
…ensearch-project#1785)

* [Build][Test] OS and OSD improvements plus support for Playground

While using a child folder 'Playground' in Jenkins I had to do a number of
changes to support a successful test run. I also included the ability to
skip publishing the notification not to spam channels from builds from
for example `Playground`. Also ability to skip building docker because
from what I could tell it was publishing docker images from `Playground`
pipelines as well.

If the user attempts to pass an empty string it will skip the integ tests.

Finally, some cleanup to integ tests to use the input manifest to container image.
Also, make integ tests run in docker container for OpenSearch. Use libtester for 
detectTestDockerAgent
 
Issues Resolved
* opensearch-project#1688
* opensearch-project#1687
* opensearch-project#1686
* opensearch-project#1758

Signed-off-by: Kawika Avilla <[email protected]>
  • Loading branch information
kavilla authored Mar 21, 2022
1 parent 9cf9039 commit 79ecfb9
Show file tree
Hide file tree
Showing 16 changed files with 395 additions and 130 deletions.
132 changes: 78 additions & 54 deletions jenkins/opensearch-dashboards/distribution-build.jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@ pipeline {
agent none
environment {
AGENT_X64 = 'Jenkins-Agent-al2-x64-c54xlarge-Docker-Host'
AGENT_ARM64 = 'Jenkins-Agent-al2-arm64-c6g4xlarge-Docker-Host'
INTEG_TEST_JOB_NAME = 'integ-test-opensearch-dashboards'
AGENT_ARM64 = 'Jenkins-Agent-al2-arm64-c6g4xlarge-Docker-Host'
}
parameters {
string(
Expand All @@ -23,6 +22,22 @@ pipeline {
description: 'Test manifest under the manifests folder, e.g. 2.0.0/opensearch-dashboards-2.0.0-test.yml.',
trim: true
)
string(
name: 'INTEG_TEST_JOB_NAME',
description: "Name of integration test job that will be triggered, e.g. Playground/integ-test-opensearch-dashboards. A non-null empty value here will skip integration tests.",
defaultValue: "integ-test-opensearch-dashboards",
trim: true
)
booleanParam(
name: 'BUILD_DOCKER',
description: 'Build docker image or not.',
defaultValue: true
)
booleanParam(
name: 'PUBLISH_NOTIFICATION',
description: 'Publish the status of this build job or not.',
defaultValue: true
)
}
stages {
stage('detect docker image + args') {
Expand Down Expand Up @@ -64,24 +79,25 @@ pipeline {
echo "buildManifestUrl (x64): ${buildManifestUrl}"
echo "artifactUrl (x64): ${artifactUrl}"

def integTestResults =
build job: INTEG_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),
string(name: 'CONTAINER_IMAGE', value: getTestDocker(testManifest: "manifests/${TEST_MANIFEST}")?.image ?: dockerAgent.image)
]
Boolean skipIntegTests = INTEG_TEST_JOB_NAME == ''
echo "${skipIntegTests ? 'Skipping integration tests' : 'Running integration tests'}"
if (!skipIntegTests) {
def integTestResults =
build job: INTEG_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)
]

String status = integTestResults.getResult()
String icon = status == 'SUCCESS' ? ':white_check_mark:' : ':warning:'
lib.jenkins.Messages.new(this).add(
STAGE_NAME,
lib.jenkins.Messages.new(this).get([STAGE_NAME]) +
"\nInteg Tests (x64): ${icon} ${status} ${integTestResults.getAbsoluteUrl()}"
)
createTestResultsMessage(
testType: "Integ Tests (x64)",
status: integTestResults.getResult(),
absoluteUrl: integTestResults.getAbsoluteUrl()
)
}
}
}
post {
Expand Down Expand Up @@ -140,24 +156,25 @@ pipeline {
echo "buildManifestUrl (arm64): ${buildManifestUrl}"
echo "artifactUrl (arm64): ${artifactUrl}"

def integTestResults =
build job: INTEG_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),
string(name: 'CONTAINER_IMAGE', value: getTestDocker(testManifest: "manifests/${TEST_MANIFEST}")?.image ?: dockerAgent.image)
]
Boolean skipIntegTests = INTEG_TEST_JOB_NAME == ''
echo "${skipIntegTests ? 'Skipping integration tests' : 'Running integration tests'}"
if (!skipIntegTests) {
def integTestResults =
build job: INTEG_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)
]

String status = integTestResults.getResult()
String icon = status == 'SUCCESS' ? ':white_check_mark:' : ':warning:'
lib.jenkins.Messages.new(this).add(
STAGE_NAME,
lib.jenkins.Messages.new(this).get([STAGE_NAME]) +
"\nInteg Tests (arm64): ${icon} ${status} ${integTestResults.getAbsoluteUrl()}"
)
createTestResultsMessage(
testType: "Integ Tests (arm64)",
status: integTestResults.getResult(),
absoluteUrl: integTestResults.getAbsoluteUrl()
)
}
}
}
post {
Expand All @@ -171,6 +188,10 @@ pipeline {
}
}
stage('docker build') {
when {
beforeAgent true
equals expected: true, actual: BUILD_DOCKER
}
steps {
node(AGENT_X64) {
script {
Expand All @@ -191,19 +212,20 @@ pipeline {
success {
node(AGENT_X64) {
script {
def stashed = lib.jenkins.Messages.new(this).get([
'build-and-test-linux-x64',
'build-archive-linux-arm64',
'assemble-archive-and-test-linux-arm64'
])
if (params.PUBLISH_NOTIFICATION) {
def stashed = lib.jenkins.Messages.new(this).get([
'build-and-test-linux-x64',
'assemble-archive-and-test-linux-arm64'
])

publishNotification(
icon: ':white_check_mark:',
message: 'Successful Build',
extra: stashed,
credentialsId: 'BUILD_NOTICE_WEBHOOK',
manifest: "${INPUT_MANIFEST}"
)
publishNotification(
icon: ':white_check_mark:',
message: 'Successful Build',
extra: stashed,
credentialsId: 'BUILD_NOTICE_WEBHOOK',
manifest: "${INPUT_MANIFEST}"
)
}

postCleanup()
}
Expand All @@ -212,12 +234,14 @@ pipeline {
failure {
node(AGENT_X64) {
script {
publishNotification(
icon: ':warning:',
message: 'Failed Build',
credentialsId: 'BUILD_NOTICE_WEBHOOK',
manifest: "${INPUT_MANIFEST}"
)
if (params.PUBLISH_NOTIFICATION) {
publishNotification(
icon: ':warning:',
message: 'Failed Build',
credentialsId: 'BUILD_NOTICE_WEBHOOK',
manifest: "${INPUT_MANIFEST}"
)
}

postCleanup()
}
Expand Down
36 changes: 27 additions & 9 deletions jenkins/opensearch-dashboards/integ-test.jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ pipeline {
agent none
environment {
BUILD_MANIFEST = "build-manifest.yml"
BUILD_JOB_NAME = 'distribution-build-opensearch-dashboards'
DEFAULT_BUILD_JOB_NAME = "distribution-build-opensearch-dashboards"
}
parameters {
string(
Expand All @@ -25,32 +25,50 @@ pipeline {
description: 'The agent label where the tests should be executed, e.g. Jenkins-Agent-al2-x64-c54xlarge-Docker-Host.',
trim: true
)
string(
name: 'CONTAINER_IMAGE',
description: 'The container image running on the agent where the tests should be executed, e.g. opensearchstaging/ci-runner:centos7-x64-arm64-jdkmulti-node10.24.1-cypress6.9.1-20211028.',
trim: true
)
}
stages {
stage('verify-parameters') {
agent {
node {
label AGENT_LABEL
}
}
steps {
script {
if (AGENT_LABEL == '') {
currentBuild.result = 'ABORTED'
error("Integration Tests failed to start. Missing parameter: AGENT_LABEL.")
}
if (CONTAINER_IMAGE == '') {
if (!fileExists("manifests/${TEST_MANIFEST}")) {
currentBuild.result = 'ABORTED'
error("Integration Tests failed to start. Missing parameter: CONTAINER_IMAGE.")
error("Integration 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('integ-test') {
agent {
docker {
label AGENT_LABEL
image CONTAINER_IMAGE
image dockerAgent.image
args dockerAgent.args
alwaysPull true
}
}
Expand Down
Loading

0 comments on commit 79ecfb9

Please sign in to comment.