Skip to content

Commit

Permalink
[Dashboards] integ-test in Jenkins
Browse files Browse the repository at this point in the history
Execute the integ-test workflow for OpenSearch Dashboards including
tests.

As opposed to OpenSearch, we need an image with the appropriate libraries
so we pass the image but it does not have the wget so the steps were broken
to access the build manifest.

Hardcoding the OpenSearch build id for now until this get resolves:
opensearch-project#1492

ARM tests will fail still until this is resolved:
opensearch-project#1381

Issue partially resolved:
opensearch-project#704

Signed-off-by: Kawika Avilla <kavilla414@gmail.com>
  • Loading branch information
kavilla committed Feb 24, 2022
1 parent 18c173c commit 170d581
Show file tree
Hide file tree
Showing 15 changed files with 2,838 additions and 43 deletions.
81 changes: 66 additions & 15 deletions jenkins/opensearch-dashboards/distribution-build.jenkinsfile
Original file line number Diff line number Diff line change
@@ -1,17 +1,28 @@
lib = library(identifier: 'jenkins@20211123', retriever: legacySCM(scm))

pipeline {
options {
timeout(time: 3, unit: 'HOURS')
copyArtifactPermission("${JOB_NAME}")
buildDiscarder(logRotator(artifactNumToKeepStr: '1'))
}
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'
}
parameters {
string(
name: 'INPUT_MANIFEST',
description: 'Input manifest under the manifests folder, e.g. 2.0.0/opensearch-dashboards-2.0.0.yml.',
trim: true
)
}
options {
copyArtifactPermission("${JOB_NAME}")
buildDiscarder(logRotator(artifactNumToKeepStr: '1'))
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
)
}
stages {
stage('detect docker image + args') {
Expand All @@ -31,10 +42,10 @@ pipeline {
}
stage('build') {
parallel {
stage('build-linux-x64') {
stage('build-and-test-linux-x64') {
agent {
docker {
label 'Jenkins-Agent-al2-x64-c54xlarge-Docker-Host'
label AGENT_X64
image dockerAgent.image
args dockerAgent.args
alwaysPull true
Expand All @@ -47,9 +58,31 @@ pipeline {
platform: 'linux',
architecture: 'x64'
)
String buildManifestUrl = buildManifestObj.getUrl(JOB_NAME, BUILD_NUMBER)
String artifactUrl = buildManifestObj.getArtifactUrl(JOB_NAME, BUILD_NUMBER)
env.ARTIFACT_URL_X64 = artifactUrl
echo "buildManifestUrl (x64): ${buildManifestUrl}"
echo "artifactUrl (x64): ${artifactUrl}"
echo "agent image: ${dockerAgent.image}"

def integTestResults =
build job: INTEG_TEST_JOB_NAME,
propagate: false,
wait: true,
parameters: [
string(name: 'TEST_MANIFEST', value: "manifests/${TEST_MANIFEST}"),
string(name: 'BUILD_MANIFEST_URL', value: buildManifestUrl),
string(name: 'AGENT_LABEL', value: AGENT_X64),
string(name: 'AGENT_IMAGE', value: dockerAgent.image)
]

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()}"
)
}
}
post {
Expand All @@ -58,13 +91,13 @@ pipeline {
}
}
}
stage('build-linux-arm64') {
stage('build-and-test-linux-arm64') {
agent none
stages {
stage('build-archive-linux-arm64') {
agent {
docker {
label 'Jenkins-Agent-al2-x64-c54xlarge-Docker-Host'
label AGENT_X64
image dockerAgent.image
args dockerAgent.args
alwaysPull true
Expand All @@ -85,10 +118,10 @@ pipeline {
}
}
}
stage('assemble-archive-linux-arm64') {
stage('assemble-archive-and-test-linux-arm64') {
agent {
docker {
label 'Jenkins-Agent-al2-arm64-c6g4xlarge-Docker-Host'
label AGENT_ARM64
image dockerAgent.image
args dockerAgent.args
alwaysPull true
Expand All @@ -102,9 +135,27 @@ pipeline {
architecture: 'arm64'
)

String buildManifestUrl = buildManifestObj.getUrl(JOB_NAME, BUILD_NUMBER)
String artifactUrl = buildManifestObj.getArtifactUrl(JOB_NAME, BUILD_NUMBER)
env.ARTIFACT_URL_ARM64 = artifactUrl
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: "manifests/${TEST_MANIFEST}"),
string(name: 'BUILD_MANIFEST_URL', value: buildManifestUrl),
string(name: 'AGENT_LABEL', value: AGENT_ARM64),
string(name: 'AGENT_IMAGE', value: dockerAgent.image)
]

// TODO: consume results once ARM64 works
// https://github.com/opensearch-project/opensearch-build/issues/1381
String status = integTestResults.getResult()
echo "${status}"
}
}
post {
Expand All @@ -119,7 +170,7 @@ pipeline {
}
stage('docker build') {
steps {
node('Jenkins-Agent-al2-x64-c54xlarge-Docker-Host') {
node(AGENT_X64) {
script {
echo "env.ARTIFACT_URL_X64: ${env.ARTIFACT_URL_X64}"
echo "env.ARTIFACT_URL_ARM64: ${env.ARTIFACT_URL_ARM64}"
Expand All @@ -136,12 +187,12 @@ pipeline {
}
post {
success {
node('Jenkins-Agent-al2-x64-c54xlarge-Docker-Host') {
node(AGENT_X64) {
script {
def stashed = lib.jenkins.Messages.new(this).get([
'build-linux-x64',
'build-and-test-linux-x64',
'build-archive-linux-arm64',
'assemble-archive-linux-arm64'
'assemble-archive-and-test-linux-arm64'
])

publishNotification(
Expand All @@ -157,7 +208,7 @@ pipeline {
}
}
failure {
node('Jenkins-Agent-al2-x64-c54xlarge-Docker-Host') {
node(AGENT_X64) {
script {
publishNotification(
icon: ':warning:',
Expand Down
137 changes: 137 additions & 0 deletions jenkins/opensearch-dashboards/integ-test.jenkinsfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
lib = library(identifier: "jenkins@20211118", retriever: legacySCM(scm))

pipeline {
options {
timeout(time: 3, unit: 'HOURS')
}
agent none
environment {
BUILD_MANIFEST = "build-manifest.yml"
BUILD_JOB_NAME = 'distribution-build-opensearch-dashboards'
}
parameters {
string(
name: 'TEST_MANIFEST',
description: 'Test manifest under the manifests folder, e.g. manifests/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
)
string(
name: 'AGENT_IMAGE',
description: 'The agent label 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') {
steps {
script {
if (AGENT_LABEL == '') {
currentBuild.result = 'ABORTED'
error("Integration Tests failed to start. Missing parameter: AGENT_LABEL.")
}
if (AGENT_IMAGE == '') {
currentBuild.result = 'ABORTED'
error("Integration Tests failed to start. Missing parameter: AGENT_IMAGE.")
}
}
}
}
stage('download-manifest') {
agent {
node {
label AGENT_LABEL
}
}
steps {
script {
def buildManifestObj = downloadBuildManifest(
url: BUILD_MANIFEST_URL,
path: BUILD_MANIFEST
)
String buildId = buildManifestObj.getArtifactBuildId()
env.BUILD_ID = buildId

stash name: BUILD_MANIFEST, includes: BUILD_MANIFEST
}
}
}
stage('integ-test') {
agent {
docker {
label AGENT_LABEL
image AGENT_IMAGE
alwaysPull true
}
}
steps {
script {
unstash BUILD_MANIFEST
echo "BUILD_MANIFEST: ${BUILD_MANIFEST}"
echo "BUILD_ID: ${BUILD_ID}"

runIntegTestScript(
jobName: BUILD_JOB_NAME,
buildManifest: BUILD_MANIFEST,
testManifest: 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(['integ-test'])
publishNotification(
icon: ':white_check_mark:',
message: 'Integration Tests Successful',
extra: stashed,
credentialsId: 'INTEG_TEST_WEBHOOK',
)

postCleanup()
}
}
}
failure {
node(AGENT_LABEL) {
script {
def stashed = lib.jenkins.Messages.new(this).get(['integ-test'])
publishNotification(
icon: ':warning:',
message: 'Failed Integration Tests',
extra: stashed,
credentialsId: 'INTEG_TEST_WEBHOOK',
)

postCleanup()
}
}
}
}
}
Loading

0 comments on commit 170d581

Please sign in to comment.