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

Add integ tests to OpenSearch distribution build jenkins job #1517

Merged
merged 14 commits into from
Feb 2, 2022
Merged
Show file tree
Hide file tree
Changes from 13 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
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
95 changes: 84 additions & 11 deletions jenkins/opensearch/distribution-build.jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,23 @@ 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'
// TODO: change to integ-test when updated in Jenkins
INTEG_TEST_JOB_NAME = 'Playground/ohltyler-integ-test-stable'
}
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 +32,7 @@ pipeline {
steps {
script {
dockerAgent = detectDockerAgent()
currentBuild.description = "$INPUT_MANIFEST"
currentBuild.description = INPUT_MANIFEST
}
}
}
Expand All @@ -43,6 +54,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 @@ -75,6 +87,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 @@ -87,18 +100,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 @@ -107,18 +146,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 @@ -133,17 +198,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 @@ -158,7 +231,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