Skip to content

Commit

Permalink
Add integ tests to OpenSearch distribution build jenkins job (#1517)
Browse files Browse the repository at this point in the history
* Hook up integ tests to distribution-build

Signed-off-by: Tyler Ohlsen <ohltyler@amazon.com>

* yamlfix test manifest file

Signed-off-by: Tyler Ohlsen <ohltyler@amazon.com>

* Remove unnecessary BuildManifest fns

Signed-off-by: Tyler Ohlsen <ohltyler@amazon.com>

* Remove runIntegTests(); refactor buildDockerImage vars as params

Signed-off-by: Tyler Ohlsen <ohltyler@amazon.com>

* Comment out notification block on dashboards dist build job

Signed-off-by: Tyler Ohlsen <ohltyler@amazon.com>

* Test out stabler integ test job

Signed-off-by: Tyler Ohlsen <ohltyler@amazon.com>

* Add test pipeline for pulling nested build info

Signed-off-by: Tyler Ohlsen <ohltyler@amazon.com>

* Remove test pipeline

Signed-off-by: Tyler Ohlsen <ohltyler@amazon.com>

* Add back notifications in OSD dist build

Signed-off-by: Tyler Ohlsen <ohltyler@amazon.com>

* Remove few extra test output lines

Signed-off-by: Tyler Ohlsen <ohltyler@amazon.com>

* Clean up buildDockerImage tests

Signed-off-by: Tyler Ohlsen <ohltyler@amazon.com>

* Update params in check-for-build cron; add icon in notifications

Signed-off-by: Tyler Ohlsen <ohltyler@amazon.com>

* Simplify notification

Signed-off-by: Tyler Ohlsen <ohltyler@amazon.com>

* Change references back to prod jenkins jobs

Signed-off-by: Tyler Ohlsen <ohltyler@amazon.com>
  • Loading branch information
ohltyler committed Feb 2, 2022
1 parent 54cc6d9 commit 6c54533
Show file tree
Hide file tree
Showing 40 changed files with 337 additions and 159 deletions.
24 changes: 15 additions & 9 deletions jenkins/check-for-build.jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@ pipeline {
triggers {
parameterizedCron '''
H/10 * * * * %INPUT_MANIFEST=1.3.0/opensearch-dashboards-1.3.0.yml;TARGET_JOB_NAME=distribution-build-opensearch-dashboards
H/10 * * * * %INPUT_MANIFEST=1.2.4/opensearch-1.2.4.yml;TARGET_JOB_NAME=distribution-build-opensearch
H/10 * * * * %INPUT_MANIFEST=1.3.0/opensearch-1.3.0.yml;TARGET_JOB_NAME=distribution-build-opensearch
H 1 * * * %INPUT_MANIFEST=1.1.1/opensearch-1.1.1.yml;TARGET_JOB_NAME=distribution-build-opensearch
H/10 * * * * %INPUT_MANIFEST=1.2.4/opensearch-1.2.4.yml;TEST_MANIFEST=1.2.4/opensearch-1.2.4-test.yml;TARGET_JOB_NAME=distribution-build-opensearch
H/10 * * * * %INPUT_MANIFEST=1.3.0/opensearch-1.3.0.yml;TEST_MANIFEST=1.3.0/opensearch-1.3.0-test.yml;TARGET_JOB_NAME=distribution-build-opensearch
H 1 * * * %INPUT_MANIFEST=1.1.1/opensearch-1.1.1.yml;TEST_MANIFEST=1.1.1/opensearch-1.1.1-test.yml;TARGET_JOB_NAME=distribution-build-opensearch
H 1 * * * %INPUT_MANIFEST=1.1.1/opensearch-dashboards-1.1.1.yml;TARGET_JOB_NAME=distribution-build-opensearch-dashboards
H 1 * * * %INPUT_MANIFEST=1.2.1/opensearch-1.2.1.yml;TARGET_JOB_NAME=distribution-build-opensearch
H 1 * * * %INPUT_MANIFEST=1.2.2/opensearch-1.2.2.yml;TARGET_JOB_NAME=distribution-build-opensearch
H 1 * * * %INPUT_MANIFEST=1.2.3/opensearch-1.2.3.yml;TARGET_JOB_NAME=distribution-build-opensearch
H 1 * * * %INPUT_MANIFEST=2.0.0/opensearch-2.0.0.yml;TARGET_JOB_NAME=distribution-build-opensearch
H 1 * * * %INPUT_MANIFEST=1.2.1/opensearch-1.2.1.yml;TEST_MANIFEST=1.2.1/opensearch-1.2.1-test.yml;TARGET_JOB_NAME=distribution-build-opensearch
H 1 * * * %INPUT_MANIFEST=1.2.2/opensearch-1.2.2.yml;TEST_MANIFEST=1.2.2/opensearch-1.2.2-test.yml;TARGET_JOB_NAME=distribution-build-opensearch
H 1 * * * %INPUT_MANIFEST=1.2.3/opensearch-1.2.3.yml;TEST_MANIFEST=1.2.3/opensearch-1.2.3-test.yml;TARGET_JOB_NAME=distribution-build-opensearch
H 1 * * * %INPUT_MANIFEST=2.0.0/opensearch-2.0.0.yml;TEST_MANIFEST=2.0.0/opensearch-2.0.0-test.yml;TARGET_JOB_NAME=distribution-build-opensearch
H 1 * * * %INPUT_MANIFEST=2.0.0/opensearch-dashboards-2.0.0.yml;TARGET_JOB_NAME=distribution-build-opensearch-dashboards
'''
}
Expand Down Expand Up @@ -58,7 +58,10 @@ pipeline {
steps {
script {
lock(resource: "CheckForBuild-${INPUT_MANIFEST}-${TARGET_JOB_NAME}", skipIfLocked: true) {
def sha = getManifestSHA(jobName: "${TARGET_JOB_NAME}")
def sha = getManifestSHA(
inputManifest: "manifests/${INPUT_MANIFEST}",
jobName: "${TARGET_JOB_NAME}"
)
if (sha.exists) {
echo "Skipping, ${sha.path} already exists."
} else {
Expand All @@ -67,7 +70,10 @@ pipeline {
string(name: 'INPUT_MANIFEST', value: "${INPUT_MANIFEST}")
], wait: true
echo "Build succeeded, uploading build SHA for that job"
buildUploadManifestSHA(jobName: "${TARGET_JOB_NAME}")
buildUploadManifestSHA(
inputManifest: "manifests/${INPUT_MANIFEST}",
jobName: "${TARGET_JOB_NAME}"
)
} catch (err) {
echo "${TARGET_JOB_NAME} failed"
}
Expand Down
23 changes: 20 additions & 3 deletions jenkins/opensearch-dashboards/distribution-build.jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,14 @@ pipeline {
}
steps {
script {
buildAssembleUpload(
def buildManifestObj = buildAssembleUpload(
inputManifest: "manifests/${INPUT_MANIFEST}",
platform: 'linux',
architecture: 'x64'
)
String artifactUrl = buildManifestObj.getArtifactUrl(JOB_NAME, BUILD_NUMBER)
env.ARTIFACT_URL_X64 = artifactUrl
echo "artifactUrl (x64): ${artifactUrl}"
}
}
post {
Expand All @@ -69,6 +73,7 @@ pipeline {
steps {
script {
buildArchive(
inputManifest: "manifests/${INPUT_MANIFEST}",
platform: 'linux',
architecture: 'arm64'
)
Expand All @@ -91,10 +96,15 @@ pipeline {
}
steps {
script {
archiveAssembleUpload(
def buildManifestObj = archiveAssembleUpload(
inputManifest: "manifests/${INPUT_MANIFEST}",
platform: 'linux',
architecture: 'arm64'
)

String artifactUrl = buildManifestObj.getArtifactUrl(JOB_NAME, BUILD_NUMBER)
env.ARTIFACT_URL_ARM64 = artifactUrl
echo "artifactUrl (arm64): ${artifactUrl}"
}
}
post {
Expand All @@ -111,7 +121,14 @@ pipeline {
steps {
node('Jenkins-Agent-al2-x64-c54xlarge-Docker-Host') {
script {
buildDockerImage()
echo "env.ARTIFACT_URL_X64: ${env.ARTIFACT_URL_X64}"
echo "env.ARTIFACT_URL_ARM64: ${env.ARTIFACT_URL_ARM64}"

buildDockerImage(
inputManifest: "manifests/${INPUT_MANIFEST}",
artifactUrlX64: env.ARTIFACT_URL_X64,
artifactUrlArm64: env.ARTIFACT_URL_ARM64
)
}
}
}
Expand Down
94 changes: 83 additions & 11 deletions jenkins/opensearch/distribution-build.jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,22 @@ lib = library(identifier: "jenkins@20211123", retriever: legacySCM(scm))

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'
}
parameters {
string(
name: 'INPUT_MANIFEST',
description: 'Input manifest under the manifests folder, e.g. 2.0.0/opensearch-2.0.0.yml.',
trim: true
)
string(
name: 'TEST_MANIFEST',
description: 'Test manifest under the manifests folder, e.g. 2.0.0/opensearch-2.0.0-test.yml.',
trim: true
)
}
stages {
stage('detect docker image + args') {
Expand All @@ -21,7 +31,7 @@ pipeline {
steps {
script {
dockerAgent = detectDockerAgent()
currentBuild.description = "$INPUT_MANIFEST"
currentBuild.description = INPUT_MANIFEST
}
}
}
Expand All @@ -43,6 +53,7 @@ pipeline {
script {
git url: 'https://github.com/opensearch-project/opensearch-build.git', branch: 'main'
buildManifest(
inputManifest: "manifests/${INPUT_MANIFEST}",
snapshot: true
)
if (fileExists("$WORKSPACE/builds/opensearch/maven")) {
Expand Down Expand Up @@ -77,6 +88,7 @@ pipeline {
script {
git url: 'https://github.com/opensearch-project/opensearch-build.git', branch: 'main'
buildManifest(
inputManifest: "manifests/${INPUT_MANIFEST}",
snapshot: true
)
echo("Uploading min snapshots to S3")
Expand All @@ -91,18 +103,44 @@ pipeline {
}
}
}
stage('build-x64') {
stage('build-and-test-x64') {
agent {
docker {
label 'Jenkins-Agent-al2-x64-c54xlarge-Docker-Host'
label AGENT_X64
image dockerAgent.image
args dockerAgent.args
alwaysPull true
}
}
steps {
script {
buildAssembleUpload()
def buildManifestObj = buildAssembleUpload(
inputManifest: "manifests/${INPUT_MANIFEST}"
)
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: "manifests/${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()}"
)
}
}
post {
Expand All @@ -111,18 +149,44 @@ pipeline {
}
}
}
stage('build-arm64') {
stage('build-and-test-arm64') {
agent {
docker {
label 'Jenkins-Agent-al2-arm64-c6g4xlarge-Docker-Host'
label AGENT_ARM64
image dockerAgent.image
args dockerAgent.args
alwaysPull true
}
}
steps {
script {
buildAssembleUpload()
def buildManifestObj = buildAssembleUpload(
inputManifest: "manifests/${INPUT_MANIFEST}"
)
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 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()}"
)
}
}
post {
Expand All @@ -137,17 +201,25 @@ pipeline {
steps {
node('Jenkins-Agent-al2-x64-c54xlarge-Docker-Host') {
script {
buildDockerImage()

echo "env.ARTIFACT_URL_X64: ${env.ARTIFACT_URL_X64}"
echo "env.ARTIFACT_URL_ARM64: ${env.ARTIFACT_URL_ARM64}"

buildDockerImage(
inputManifest: "manifests/${INPUT_MANIFEST}",
artifactUrlX64: env.ARTIFACT_URL_X64,
artifactUrlArm64: env.ARTIFACT_URL_ARM64
)
}
}
}
}
}
post {
success {
node('Jenkins-Agent-al2-x64-c54xlarge-Docker-Host') {
node(AGENT_X64) {
script {
def stashed = lib.jenkins.Messages.new(this).get(['build-x64', 'build-arm64'])
def stashed = lib.jenkins.Messages.new(this).get(['build-and-test-x64', 'build-and-test-arm64'])

publishNotification(
icon: ':white_check_mark:',
Expand All @@ -162,7 +234,7 @@ pipeline {
}
}
failure {
node('Jenkins-Agent-al2-x64-c54xlarge-Docker-Host') {
node(AGENT_X64) {
script {
publishNotification(
icon: ':warning:',
Expand Down
2 changes: 1 addition & 1 deletion jenkins/opensearch/integ-test.jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ pipeline {
environment {
AWS_ROLE_ARN = "arn:aws:iam::${AWS_ACCOUNT_PUBLIC}:role/opensearch-test"
AWS_ROLE_SESSION_NAME = "jenkins-test-session"
BUILD_MANIFEST= "build-manifest.yml"
BUILD_MANIFEST = "build-manifest.yml"
}
tools {
jdk "JDK14"
Expand Down
24 changes: 24 additions & 0 deletions src/jenkins/BuildManifest.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,12 @@ class BuildManifest implements Serializable {
return this.name.toLowerCase().replaceAll(' ', '-')
}

String getFilenameWithExtension(String platform = null, String architecture = null) {
String resolvedPlatform = platform ?: this.platform
String resolvedArchitecture = architecture ?: this.architecture
return "${this.getFilename()}-${this.version}-${resolvedPlatform}-${resolvedArchitecture}.${resolvedPlatform == 'windows' ? 'zip' : 'tar.gz'}"
}

String getPackageName() {
return [
this.getFilename(),
Expand Down Expand Up @@ -92,6 +98,24 @@ class BuildManifest implements Serializable {
].join('/')
}

public String getUrl(String publicArtifactUrl = 'https://ci.opensearch.org/ci/dbc', String jobName, String buildNumber) {
return [
this.getArtifactRootUrl(publicArtifactUrl, jobName, buildNumber),
'builds',
this.build.getFilename(),
'manifest.yml'
].join("/")
}

public String getArtifactUrl(String publicArtifactUrl = 'https://ci.opensearch.org/ci/dbc', String jobName, String buildNumber) {
return [
this.getArtifactRootUrl(publicArtifactUrl, jobName, buildNumber),
'dist',
this.build.getFilename(),
this.build.getFilenameWithExtension()
].join("/")
}

public String getArtifactArchitecture() {
return this.build.architecture
}
Expand Down
20 changes: 0 additions & 20 deletions src/jenkins/InputManifest.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,6 @@ class InputManifest {
String getFilename() {
return this.name.toLowerCase().replaceAll(' ', '-')
}

String getFilenameWithExtension(String platform = null, String architecture = null) {
String resolvedPlatform = platform ?: this.platform
String resolvedArchitecture = architecture ?: this.architecture
return "${this.getFilename()}-${this.version}-${resolvedPlatform}-${resolvedArchitecture}.${resolvedPlatform == 'windows' ? 'zip' : 'tar.gz'}"
}
}

Build build
Expand All @@ -64,20 +58,6 @@ class InputManifest {
this.ci = data.ci ? new InputManifest.Ci(data.ci) : null
}

String getPublicDistUrl(String publicArtifactUrl = 'https://ci.opensearch.org/ci/dbc', String jobName, String buildNumber, String platform = null, String architecture = null) {
return [
publicArtifactUrl,
jobName,
this.build.version,
buildNumber,
platform ?: this.build.platform,
architecture ?: this.build.architecture,
'dist',
this.build.getFilename(),
this.build.getFilenameWithExtension(platform, architecture)
].join("/")
}

String getSHAsRoot(String jobName) {
return [
jobName,
Expand Down
Loading

0 comments on commit 6c54533

Please sign in to comment.