forked from opensearch-project/opensearch-build
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Automate integration tests jenkins job (opensearch-project#1429)
Signed-off-by: Tyler Ohlsen <ohltyler@amazon.com>
- Loading branch information
1 parent
53a8b9d
commit c36b876
Showing
5 changed files
with
145 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" | ||
maven "maven-3.8.2" | ||
} | ||
parameters { | ||
string( | ||
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 { | ||
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 | ||
) | ||
} | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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}", | ||
].join(' ')) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters