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

Automate integration tests jenkins job #1429

Merged
merged 21 commits into from
Jan 18, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
2d53373
Add integ test pipeline
ohltyler Jan 3, 2022
6865e8b
Simplify params in runIntegTests() and integ-test workflow
ohltyler Jan 6, 2022
421e7cc
Move build manifest info logic into fn; remove inputManifest in runIn…
ohltyler Jan 7, 2022
cbddca9
Update test outputs
ohltyler Jan 7, 2022
dea687d
Move manifest url logic in BuildManifest; add TEST_MANIFEST param; va…
ohltyler Jan 10, 2022
2256ba8
Revert some changes for later PRs; address some comments
ohltyler Jan 11, 2022
5d4563f
Add AGENT_LABEL param; clean up some of integ-test.jenkinsfile from P…
ohltyler Jan 11, 2022
6d8a4e0
Revert changes that will be in separate PRs
ohltyler Jan 12, 2022
1d98cff
Remove leftover test file not part of this PR
ohltyler Jan 12, 2022
c6770fa
Fail integ-test job if tests fail
ohltyler Jan 12, 2022
cfeb3c1
Add build vars in stage env to use in post block
ohltyler Jan 12, 2022
7ce0462
Change return type of getBuildManifestInfo()
ohltyler Jan 12, 2022
386794e
Remove debugging lines; rebase with BuildManifest.groovy changes
ohltyler Jan 12, 2022
f327a42
Remove duplicate fns in BuildManifest
ohltyler Jan 12, 2022
7880db4
Comment out post block
ohltyler Jan 13, 2022
093f121
Add post block back; change param description to build manifest inste…
ohltyler Jan 13, 2022
5b1c751
Add publishNotification() back
ohltyler Jan 13, 2022
a10f8e6
Increase number of tries for cluster to come up in integ_test
ohltyler Jan 14, 2022
beaf4ba
Revert timeout increase for integ_test
ohltyler Jan 14, 2022
c60435a
Change getBuildManifestInfo() to simpler downloadBuildManifest()
ohltyler Jan 18, 2022
e292c13
Update description; fix path in downloadBuildManifest()
ohltyler Jan 18, 2022
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
112 changes: 112 additions & 0 deletions jenkins/opensearch/integ-test.jenkinsfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
lib = library(identifier: "jenkins@20211118", retriever: legacySCM(scm))

pipeline {
agent none
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"
}
tools {
jdk "JDK14"
ohltyler marked this conversation as resolved.
Show resolved Hide resolved
maven "maven-3.8.2"
}
parameters {
string(
ohltyler marked this conversation as resolved.
Show resolved Hide resolved
defaultValue: '',
name: 'TEST_MANIFEST',
description: 'Test manifest under the manifests folder, e.g. manifests/2.0.0/opensearch-2.0.0-test.yml.',
trim: true
)
string(
defaultValue: '',
name: 'BUILD_MANIFEST_URL',
description: 'The build manifest URL, e.g. https://ci.opensearch.org/ci/dbc/distribution-build-opensearch/1.2.2/98/linux/x64/builds/opensearch/manifest.yml.',
trim: true
)
string(
defaultValue: '',
name: 'AGENT_LABEL',
description: 'The agent label where the tests should be executed, e.g. Jenkins-Agent-al2-x64-c54xlarge-Docker-Host.',
trim: true
)
}
stages {
stage('integ-test') {
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
echo "BUILD_MANIFEST: ${BUILD_MANIFEST}"
echo "BUILD_ID: ${BUILD_ID}"

runIntegTestScript(
buildManifest: "${BUILD_MANIFEST}",
testManifest: "${TEST_MANIFEST}",
buildId: "${BUILD_ID}"
)
}
}
post {
always {
peternied marked this conversation as resolved.
Show resolved Hide resolved
script {
uploadTestResults(
buildManifestFileName: "${BUILD_MANIFEST}",
jobName: 'integ-test',
buildNumber: "${BUILD_ID}"
)
}
cleanWs disableDeferredWipeout: true, deleteDirs: true
}
}
}
}

post {
success {
node('Jenkins-Agent-al2-x64-m5xlarge') {
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',
)

cleanWs(
disableDeferredWipeout: true,
deleteDirs: true
)
}
}
}
failure {
node('Jenkins-Agent-al2-x64-m5xlarge') {
script {
def stashed = lib.jenkins.Messages.new(this).get(['integ-test'])
publishNotification(
icon: ':warning:',
message: 'Failed Integration Tests',
extra: stashed,
credentialsId: 'INTEG_TEST_WEBHOOK',
)

cleanWs(
disableDeferredWipeout: true,
deleteDirs: true
)
}
}
}
}
}
10 changes: 10 additions & 0 deletions src/jenkins/BuildManifest.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,14 @@ package jenkins

class BuildManifest implements Serializable {
class Build implements Serializable {
String id
String name
String version
String platform
String architecture

Build(Map data) {
this.id = data.id
this.name = data.name
this.version = data.version
this.platform = data.platform
Expand Down Expand Up @@ -90,6 +92,14 @@ class BuildManifest implements Serializable {
].join('/')
}

public String getArtifactArchitecture() {
return this.build.architecture
}

public String getArtifactBuildId() {
return this.build.id
}

public String getMinArtifact() {
components.get(build.name.replace(' ','-'))?.artifacts?.get("dist")?.first()
}
Expand Down
7 changes: 7 additions & 0 deletions vars/downloadBuildManifest.groovy
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
def call(Map args = [:]) {
def lib = library(identifier: "jenkins@20211123", retriever: legacySCM(scm))

sh "wget ${args.url} -O ${args.path}"
def buildManifestObj = lib.jenkins.BuildManifest.new(readYaml(file: args.path))
return buildManifestObj
}
14 changes: 14 additions & 0 deletions vars/runIntegTestScript.groovy
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
void call(Map args = [:]) {
String jobName = args.jobName ?: 'distribution-build-opensearch'
lib = library(identifier: 'jenkins@20211123', retriever: legacySCM(scm))
def buildManifest = lib.jenkins.BuildManifest.new(readYaml(file: args.buildManifest))
String artifactRootUrl = buildManifest.getArtifactRootUrl(jobName, args.buildId)
echo "Artifact root URL: ${artifactRootUrl}"

sh([
'./test.sh',
'integ-test',
"${args.testManifest}",
"--paths opensearch=${artifactRootUrl}",
ohltyler marked this conversation as resolved.
Show resolved Hide resolved
].join(' '))
}
5 changes: 2 additions & 3 deletions vars/uploadTestResults.groovy
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
void call(Map args = [:]) {
def lib = library(identifier: "jenkins@20211123", retriever: legacySCM(scm))

def manifestFilename = args.manifest ?: "manifest.yml"
def buildManifest = lib.jenkins.BuildManifest.new(readYaml(file: manifestFilename))

def buildManifest = lib.jenkins.BuildManifest.new(readYaml(file: args.buildManifestFileName))

def artifactPath = buildManifest.getArtifactRoot(args.jobName, args.buildNumber)
echo "Uploading to s3://${ARTIFACT_BUCKET_NAME}/${artifactPath}"
Expand Down