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

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

Closed
wants to merge 3 commits into from
Closed
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
102 changes: 64 additions & 38 deletions jenkins/opensearch-dashboards/distribution-build.jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ 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'
DEFAULT_INTEG_TEST_JOB_NAME = 'integ-test-opensearch-dashboards'
}
parameters {
string(
Expand All @@ -23,8 +23,33 @@ 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.",
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('verify-parameters') {
steps {
script {
env.INTEG_TEST_JOB_NAME = INTEG_TEST_JOB_NAME != '' ?
Copy link
Member

Choose a reason for hiding this comment

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

Do we need the check here since INTEG_TEST_JOB_NAME always has the default value which is the same as the DEFAULT_INTEG_TEST_JOB_NAME if not assigned?

Copy link
Member Author

Choose a reason for hiding this comment

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

This is probably me being too protective but technically someone can kick off a build and empty out the string for INTEG_TEST_JOB_NAME. I can remove this if we do not want to handle those situations.

Copy link
Member

Choose a reason for hiding this comment

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

Had some offline discussion with @kavilla, this makes sense to me that we could leave the parameter empty with this stage of check. These situation could happen for example when we pass the params from cron jobs. This shouldn't be a blocker for me.

INTEG_TEST_JOB_NAME :
DEFAULT_INTEG_TEST_JOB_NAME
}
}
}
stage('detect docker image + args') {
agent {
docker {
Expand Down Expand Up @@ -65,22 +90,19 @@ pipeline {
echo "artifactUrl (x64): ${artifactUrl}"

def integTestResults =
build job: INTEG_TEST_JOB_NAME,
build job: env.INTEG_TEST_JOB_NAME,
Copy link
Member

Choose a reason for hiding this comment

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

I think according to @abhinavGupta16, use env prefix may cause some issues with our tester. Could you help confirm it? @abhinavGupta16

Copy link
Member Author

Choose a reason for hiding this comment

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

Here I wanted to ensure the right variable is used. If we go the route not worrying about the empty string case (which would require someone manually triggering the build and clearing it) then I will remove theDEFAULT and only use the param and remove the env prefix.

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)
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()
)
}
}
Expand Down Expand Up @@ -141,22 +163,19 @@ pipeline {
echo "artifactUrl (arm64): ${artifactUrl}"

def integTestResults =
build job: INTEG_TEST_JOB_NAME,
build job: env.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)
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()
)
}
}
Expand All @@ -171,6 +190,10 @@ pipeline {
}
}
stage('docker build') {
when {
beforeAgent true
equals expected: true, actual: BUILD_DOCKER
}
steps {
node(AGENT_X64) {
script {
Expand All @@ -191,19 +214,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 +236,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
38 changes: 28 additions & 10 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 All @@ -66,7 +84,7 @@ pipeline {
echo "BUILD_ID: ${BUILD_ID}"

runIntegTestScript(
jobName: BUILD_JOB_NAME,
jobName: env.BUILD_JOB_NAME,
buildManifest: BUILD_MANIFEST,
testManifest: "manifests/${TEST_MANIFEST}",
buildId: BUILD_ID
Expand Down
87 changes: 58 additions & 29 deletions jenkins/opensearch/distribution-build.jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ pipeline {
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'
DEFAULT_INTEG_TEST_JOB_NAME = 'integ-test'
}
parameters {
string(
Expand All @@ -18,8 +18,33 @@ pipeline {
description: 'Test manifest under the manifests folder, e.g. 2.0.0/opensearch-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.",
defaultValue: "integ-test",
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('verify-parameters') {
Copy link
Member

Choose a reason for hiding this comment

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

Same as above. I don't think this stage is necessary.

steps {
script {
env.INTEG_TEST_JOB_NAME = INTEG_TEST_JOB_NAME != '' ?
INTEG_TEST_JOB_NAME :
DEFAULT_INTEG_TEST_JOB_NAME
}
}
}
stage('detect docker image + args') {
agent {
docker {
Expand Down Expand Up @@ -125,7 +150,7 @@ pipeline {
echo "artifactUrl (x64): ${artifactUrl}"

def integTestResults =
build job: INTEG_TEST_JOB_NAME,
build job: env.INTEG_TEST_JOB_NAME,
propagate: false,
wait: true,
parameters: [
Expand All @@ -134,12 +159,10 @@ pipeline {
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()
)
}
}
Expand Down Expand Up @@ -171,7 +194,7 @@ pipeline {
echo "artifactUrl (arm64): ${artifactUrl}"

def integTestResults =
build job: INTEG_TEST_JOB_NAME,
build job: env.INTEG_TEST_JOB_NAME,
propagate: false,
wait: true,
parameters: [
Expand All @@ -180,12 +203,10 @@ pipeline {
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()
)
}
}
Expand All @@ -198,6 +219,10 @@ pipeline {
}
}
stage('docker build') {
when {
beforeAgent: true
equals expected: true, actual: BUILD_DOCKER
}
steps {
node('Jenkins-Agent-al2-x64-c54xlarge-Docker-Host') {
script {
Expand All @@ -219,15 +244,17 @@ pipeline {
success {
node(AGENT_X64) {
script {
def stashed = lib.jenkins.Messages.new(this).get(['build-and-test-x64', 'build-and-test-arm64'])
if (params.PUBLISH_NOTIFICATION) {
def stashed = lib.jenkins.Messages.new(this).get(['build-and-test-x64', 'build-and-test-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 @@ -236,12 +263,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
Loading