-
Notifications
You must be signed in to change notification settings - Fork 273
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Tests][BWC] add BWC tests to Jenkins + tests (#1795)
* [Tests][BWC] add BWC tests to Jenkins For OpenSearch and OpenSearch Dashboards. Also fix a bug with the test config showing incorrectly. JDK defined in tools section was overwriting the arg value for docker. Also, updated to include integration tests test. Issue resolved: #705 Signed-off-by: Kawika Avilla <kavilla414@gmail.com>
- Loading branch information
Showing
28 changed files
with
1,156 additions
and
16 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,143 @@ | ||
lib = library(identifier: "jenkins@20211118", retriever: legacySCM(scm)) | ||
|
||
pipeline { | ||
options { | ||
timeout(time: 3, unit: 'HOURS') | ||
} | ||
agent none | ||
environment { | ||
BUILD_MANIFEST = "build-manifest.yml" | ||
DEFAULT_BUILD_JOB_NAME = "distribution-build-opensearch-dashboards" | ||
} | ||
parameters { | ||
string( | ||
name: 'TEST_MANIFEST', | ||
description: 'Test manifest under the manifests folder, e.g. 2.0.0/opensearch-dashboards-2.0.0-test.yml.', | ||
trim: true | ||
) | ||
string( | ||
name: 'BUILD_MANIFEST_URL', | ||
description: 'The build manifest URL, e.g. https://ci.opensearch.org/ci/dbc/distribution-build-opensearch-dashboards/2.0.0/98/linux/x64/builds/opensearch-dashboards/manifest.yml.', | ||
trim: true | ||
) | ||
string( | ||
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('verify-parameters') { | ||
agent { | ||
node { | ||
label AGENT_LABEL | ||
} | ||
} | ||
steps { | ||
script { | ||
if (AGENT_LABEL == '') { | ||
currentBuild.result = 'ABORTED' | ||
error("BWC Tests failed to start. Missing parameter: AGENT_LABEL.") | ||
} | ||
if (!fileExists("manifests/${TEST_MANIFEST}")) { | ||
currentBuild.result = 'ABORTED' | ||
error("BWC 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 { | ||
DOCKER_AGENT = detectTestDockerAgent() | ||
} | ||
} | ||
} | ||
stage('bwc-test') { | ||
agent { | ||
docker { | ||
label AGENT_LABEL | ||
image DOCKER_AGENT.image | ||
args DOCKER_AGENT.args | ||
alwaysPull true | ||
} | ||
} | ||
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}" | ||
|
||
runBwcTestScript( | ||
jobName: BUILD_JOB_NAME, | ||
buildManifest: BUILD_MANIFEST, | ||
testManifest: "manifests/${TEST_MANIFEST}", | ||
buildId: BUILD_ID | ||
) | ||
} | ||
} | ||
post { | ||
always { | ||
script { | ||
uploadTestResults( | ||
buildManifestFileName: BUILD_MANIFEST, | ||
jobName: JOB_NAME, | ||
buildNumber: BUILD_ID | ||
) | ||
} | ||
postCleanup() | ||
} | ||
} | ||
} | ||
} | ||
|
||
post { | ||
success { | ||
node(AGENT_LABEL) { | ||
script { | ||
def stashed = lib.jenkins.Messages.new(this).get(['bwc-test']) | ||
publishNotification( | ||
icon: ':white_check_mark:', | ||
message: 'BWC Tests Successful', | ||
extra: stashed, | ||
credentialsId: 'INTEG_TEST_WEBHOOK', | ||
manifest: TEST_MANIFEST, | ||
) | ||
|
||
postCleanup() | ||
} | ||
} | ||
} | ||
failure { | ||
node(AGENT_LABEL) { | ||
script { | ||
def stashed = lib.jenkins.Messages.new(this).get(['bwc-test']) | ||
publishNotification( | ||
icon: ':warning:', | ||
message: 'Failed BWC Tests', | ||
extra: stashed, | ||
credentialsId: 'INTEG_TEST_WEBHOOK', | ||
manifest: TEST_MANIFEST, | ||
) | ||
|
||
postCleanup() | ||
} | ||
} | ||
} | ||
} | ||
} |
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
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,146 @@ | ||
lib = library(identifier: "jenkins@20211118", retriever: legacySCM(scm)) | ||
|
||
pipeline { | ||
options { | ||
timeout(time: 3, unit: 'HOURS') | ||
} | ||
agent none | ||
environment { | ||
BUILD_MANIFEST = "build-manifest.yml" | ||
DEFAULT_BUILD_JOB_NAME = "distribution-build-opensearch" | ||
} | ||
tools { | ||
maven "maven-3.8.2" | ||
} | ||
parameters { | ||
string( | ||
name: 'TEST_MANIFEST', | ||
description: 'Test manifest under the manifests folder, e.g. 2.0.0/opensearch-2.0.0-test.yml.', | ||
trim: true | ||
) | ||
string( | ||
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( | ||
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('verify-parameters') { | ||
agent { | ||
node { | ||
label AGENT_LABEL | ||
} | ||
} | ||
steps { | ||
script { | ||
if (AGENT_LABEL == '') { | ||
currentBuild.result = 'ABORTED' | ||
error("BWC Tests failed to start. Missing parameter: AGENT_LABEL.") | ||
} | ||
if (!fileExists("manifests/${TEST_MANIFEST}")) { | ||
currentBuild.result = 'ABORTED' | ||
error("BWC 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 { | ||
DOCKER_AGENT = detectTestDockerAgent() | ||
} | ||
} | ||
} | ||
stage('bwc-test') { | ||
agent { | ||
docker { | ||
label AGENT_LABEL | ||
image DOCKER_AGENT.image | ||
args DOCKER_AGENT.args | ||
alwaysPull true | ||
} | ||
} | ||
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}" | ||
|
||
runBwcTestScript( | ||
jobName: BUILD_JOB_NAME, | ||
buildManifest: BUILD_MANIFEST, | ||
testManifest: "manifests/${TEST_MANIFEST}", | ||
buildId: BUILD_ID | ||
) | ||
} | ||
} | ||
post { | ||
always { | ||
script { | ||
uploadTestResults( | ||
buildManifestFileName: BUILD_MANIFEST, | ||
jobName: JOB_NAME, | ||
buildNumber: BUILD_ID | ||
) | ||
} | ||
postCleanup() | ||
} | ||
} | ||
} | ||
} | ||
|
||
post { | ||
success { | ||
node(AGENT_LABEL) { | ||
script { | ||
def stashed = lib.jenkins.Messages.new(this).get(['bwc-test']) | ||
publishNotification( | ||
icon: ':white_check_mark:', | ||
message: 'BWC Tests Successful', | ||
extra: stashed, | ||
credentialsId: 'INTEG_TEST_WEBHOOK', | ||
manifest: TEST_MANIFEST, | ||
) | ||
|
||
postCleanup() | ||
} | ||
} | ||
} | ||
failure { | ||
node(AGENT_LABEL) { | ||
script { | ||
def stashed = lib.jenkins.Messages.new(this).get(['bwc-test']) | ||
publishNotification( | ||
icon: ':warning:', | ||
message: 'Failed BWC Tests', | ||
extra: stashed, | ||
credentialsId: 'INTEG_TEST_WEBHOOK', | ||
manifest: TEST_MANIFEST, | ||
) | ||
|
||
postCleanup() | ||
} | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.