Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Dashboards] integ-test in Jenkins #1653

Merged
merged 5 commits into from
Mar 2, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
80 changes: 65 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_BASE_NAME}")
buildDiscarder(logRotator(artifactNumToKeepStr: '1'))
}
agent none
environment {
kavilla marked this conversation as resolved.
Show resolved Hide resolved
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,30 @@ 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}"

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: 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 +90,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 +117,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 +134,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: TEST_MANIFEST),
string(name: 'BUILD_MANIFEST_URL', value: buildManifestUrl),
string(name: 'AGENT_LABEL', value: AGENT_ARM64),
string(name: 'CONTAINER_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 +169,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 +186,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 +207,7 @@ pipeline {
}
}
failure {
node('Jenkins-Agent-al2-x64-c54xlarge-Docker-Host') {
node(AGENT_X64) {
script {
publishNotification(
icon: ':warning:',
Expand Down
123 changes: 123 additions & 0 deletions jenkins/opensearch-dashboards/integ-test.jenkinsfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
lib = library(identifier: "jenkins@20211118", retriever: legacySCM(scm))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We'll need to add this job to #1468 once PR is merged, so we can add test cases for this when libTesters are ready


kavilla marked this conversation as resolved.
Show resolved Hide resolved
pipeline {
options {
timeout(time: 3, unit: 'HOURS')
gaiksaya marked this conversation as resolved.
Show resolved Hide resolved
}
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. 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: '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
)
}
kavilla marked this conversation as resolved.
Show resolved Hide resolved
stages {
stage('verify-parameters') {
steps {
script {
if (AGENT_LABEL == '') {
currentBuild.result = 'ABORTED'
error("Integration Tests failed to start. Missing parameter: AGENT_LABEL.")
}
if (CONTAINER_IMAGE == '') {
currentBuild.result = 'ABORTED'
error("Integration Tests failed to start. Missing parameter: CONTAINER_IMAGE.")
}
kavilla marked this conversation as resolved.
Show resolved Hide resolved
}
}
}
stage('integ-test') {
agent {
docker {
label AGENT_LABEL
image CONTAINER_IMAGE
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}"

runIntegTestScript(
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(['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()
}
}
}
}
}
4 changes: 2 additions & 2 deletions jenkins/opensearch/distribution-build.jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ pipeline {
propagate: false,
wait: true,
parameters: [
string(name: 'TEST_MANIFEST', value: "manifests/${TEST_MANIFEST}"),
string(name: 'TEST_MANIFEST', value: TEST_MANIFEST),
string(name: 'BUILD_MANIFEST_URL', value: buildManifestUrl),
string(name: 'AGENT_LABEL', value: AGENT_X64)
]
Expand Down Expand Up @@ -175,7 +175,7 @@ pipeline {
propagate: false,
wait: true,
parameters: [
string(name: 'TEST_MANIFEST', value: "manifests/${TEST_MANIFEST}"),
string(name: 'TEST_MANIFEST', value: TEST_MANIFEST),
string(name: 'BUILD_MANIFEST_URL', value: buildManifestUrl),
string(name: 'AGENT_LABEL', value: AGENT_ARM64)
]
Expand Down
Loading