Skip to content

Commit

Permalink
Refractor pipeline agent and docker
Browse files Browse the repository at this point in the history
Signed-off-by: Zelin Hao <[email protected]>
  • Loading branch information
zelinh committed Jan 8, 2025
1 parent 91b3dc3 commit b961790
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 61 deletions.
66 changes: 34 additions & 32 deletions jenkins/opensearch/smoke-test.jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ def agent_nodes = [
pipeline {
options {
timeout(time: 2, unit: 'HOURS')
buildDiscarder(logRotator(daysToKeepStr: '60'))
}
agent none
environment {
Expand Down Expand Up @@ -91,44 +90,47 @@ pipeline {
}
}
stage('smoke-test') {
// Need to run this directly on agent node here in order to trigger stages with docker container and avoid docker within docker situation
// Can only be run in runner that is at least 50GB per container
agent { label AGENT_LABEL }
options {
timeout(time: 1, unit: 'HOURS')
}
agent {
docker {
label AGENT_LABEL
image docker_images[env.distribution]
args docker_args[env.distribution]
registryUrl 'https://public.ecr.aws/'
alwaysPull true
}
}
steps {
script {
currentBuild.description = "$TEST_MANIFEST, $version, $architecture, $platform, $buildId, $distribution"

timeout(time: 1, unit: 'HOURS') {
docker.withRegistry('https://public.ecr.aws/') {
docker.image(docker_images["$distribution"]).inside(docker_args["$distribution"]) {
try {
stage("Smoke_tests") {
checkout scm
sleep 10
downloadBuildManifest(
url: BUILD_MANIFEST_URL,
path: BUILD_MANIFEST
)
try {
stage("Smoke_tests") {
checkout scm
sleep 10
downloadBuildManifest(
url: BUILD_MANIFEST_URL,
path: BUILD_MANIFEST
)

def buildManifestObj = lib.jenkins.BuildManifest.new(readYaml(file: BUILD_MANIFEST))
def testManifestObj = lib.jenkins.TestManifest.new(readYaml(file: "manifests/${TEST_MANIFEST}"))
def buildManifestObj = lib.jenkins.BuildManifest.new(readYaml(file: BUILD_MANIFEST))
def testManifestObj = lib.jenkins.TestManifest.new(readYaml(file: "manifests/${TEST_MANIFEST}"))

sh('rm -rf test-results')
runSmokeTestScript(
jobName: "$BUILD_JOB_NAME",
buildManifest: "$BUILD_MANIFEST",
testManifest: "manifests/${TEST_MANIFEST}",
buildId: "${buildId}"
)
}
} catch (e) {
throw new Exception("Error running Smoke test", e)
} finally {
echo "Completed running smoke tests."
postCleanup()
}
}
sh('rm -rf test-results')
runSmokeTestScript(
jobName: "$BUILD_JOB_NAME",
buildManifest: "$BUILD_MANIFEST",
testManifest: "manifests/${TEST_MANIFEST}",
buildId: "${buildId}"
)
}
} catch (e) {
throw new Exception("Error running Smoke test", e)
} finally {
echo "Completed running smoke tests."
postCleanup()
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
smoke-test.pipeline(groovy.lang.Closure)
smoke-test.credentials(jenkins-artifact-bucket-name)
smoke-test.timeout({time=2, unit=HOURS})
smoke-test.logRotator({daysToKeepStr=60})
smoke-test.buildDiscarder(null)
smoke-test.echo(Executing on agent [label:none])
smoke-test.stage(verify-parameters, groovy.lang.Closure)
smoke-test.echo(Executing on agent [label:Jenkins-Agent-AL2023-X64-M54xlarge-Docker-Host])
Expand All @@ -27,36 +25,36 @@
BuildManifest.getArtifactRoot(dummy_job, 10545)
smoke-test.postCleanup()
postCleanup.cleanWs({disableDeferredWipeout=true, deleteDirs=true})
smoke-test.timeout({time=1, unit=HOURS})
smoke-test.stage(smoke-test, groovy.lang.Closure)
smoke-test.echo(Executing on agent [label:Jenkins-Agent-AL2-X64-C54xlarge-Docker-Host])
smoke-test.echo(Executing on agent [docker:[alwaysPull:true, containerPerStageRoot:false, label:Jenkins-Agent-AL2-X64-C54xlarge-Docker-Host, reuseNode:false, registryUrl:https://public.ecr.aws/, stages:[:]]])
smoke-test.script(groovy.lang.Closure)
smoke-test.timeout({time=1, unit=HOURS}, groovy.lang.Closure)
smoke-test.checkout(groovy.lang.Closure)
smoke-test.downloadBuildManifest({url=https://ci.opensearch.org/ci/dbc/distribution-build-opensearch/2.19.0/10545/linux/x64/tar/builds/opensearch/manifest.yml, path=tests/jenkins/data/opensearch-2.19.0-build.yml})
downloadBuildManifest.legacySCM(groovy.lang.Closure)
downloadBuildManifest.library({identifier=jenkins@main, retriever=null})
downloadBuildManifest.sh(mkdir -p $(dirname "tests/jenkins/data/opensearch-2.19.0-build.yml"))
downloadBuildManifest.sh(touch tests/jenkins/data/opensearch-2.19.0-build.yml)
downloadBuildManifest.sh(curl -sSL --retry 5 https://ci.opensearch.org/ci/dbc/distribution-build-opensearch/2.19.0/10545/linux/x64/tar/builds/opensearch/manifest.yml --output tests/jenkins/data/opensearch-2.19.0-build.yml)
downloadBuildManifest.readYaml({file=tests/jenkins/data/opensearch-2.19.0-build.yml})
BuildManifest.asBoolean()
smoke-test.readYaml({file=tests/jenkins/data/opensearch-2.19.0-build.yml})
smoke-test.checkout(groovy.lang.Closure)
smoke-test.downloadBuildManifest({url=https://ci.opensearch.org/ci/dbc/distribution-build-opensearch/2.19.0/10545/linux/x64/tar/builds/opensearch/manifest.yml, path=tests/jenkins/data/opensearch-2.19.0-build.yml})
downloadBuildManifest.legacySCM(groovy.lang.Closure)
downloadBuildManifest.library({identifier=jenkins@main, retriever=null})
downloadBuildManifest.sh(mkdir -p $(dirname "tests/jenkins/data/opensearch-2.19.0-build.yml"))
downloadBuildManifest.sh(touch tests/jenkins/data/opensearch-2.19.0-build.yml)
downloadBuildManifest.sh(curl -sSL --retry 5 https://ci.opensearch.org/ci/dbc/distribution-build-opensearch/2.19.0/10545/linux/x64/tar/builds/opensearch/manifest.yml --output tests/jenkins/data/opensearch-2.19.0-build.yml)
downloadBuildManifest.readYaml({file=tests/jenkins/data/opensearch-2.19.0-build.yml})
BuildManifest.asBoolean()
smoke-test.readYaml({file=tests/jenkins/data/opensearch-2.19.0-build.yml})
BuildManifest.asBoolean()
smoke-test.readYaml({file=manifests/tests/jenkins/data/opensearch-2.19.0-test.yml})
TestManifest.asBoolean()
smoke-test.sh(rm -rf test-results)
smoke-test.runSmokeTestScript({jobName=dummy_job, buildManifest=tests/jenkins/data/opensearch-2.19.0-build.yml, testManifest=manifests/tests/jenkins/data/opensearch-2.19.0-test.yml, buildId=10545})
runSmokeTestScript.legacySCM(groovy.lang.Closure)
runSmokeTestScript.library({identifier=jenkins@main, retriever=null})
runSmokeTestScript.readYaml({file=tests/jenkins/data/opensearch-2.19.0-build.yml})
BuildManifest.asBoolean()
smoke-test.readYaml({file=manifests/tests/jenkins/data/opensearch-2.19.0-test.yml})
TestManifest.asBoolean()
smoke-test.sh(rm -rf test-results)
smoke-test.runSmokeTestScript({jobName=dummy_job, buildManifest=tests/jenkins/data/opensearch-2.19.0-build.yml, testManifest=manifests/tests/jenkins/data/opensearch-2.19.0-test.yml, buildId=10545})
runSmokeTestScript.legacySCM(groovy.lang.Closure)
runSmokeTestScript.library({identifier=jenkins@main, retriever=null})
runSmokeTestScript.readYaml({file=tests/jenkins/data/opensearch-2.19.0-build.yml})
BuildManifest.asBoolean()
BuildManifest.getArtifactRootUrl(dummy_job, 10545)
runSmokeTestScript.echo(Artifact root URL: https://ci.opensearch.org/ci/dbc/dummy_job/2.19.0/10545/linux/x64/tar)
runSmokeTestScript.echo(Paths: opensearch=https://ci.opensearch.org/ci/dbc/dummy_job/2.19.0/10545/linux/x64/tar)
runSmokeTestScript.sh(./test.sh smoke-test manifests/tests/jenkins/data/opensearch-2.19.0-test.yml --test-run-id 234 --paths opensearch=https://ci.opensearch.org/ci/dbc/dummy_job/2.19.0/10545/linux/x64/tar)
smoke-test.echo(Completed running smoke tests.)
smoke-test.postCleanup()
postCleanup.cleanWs({disableDeferredWipeout=true, deleteDirs=true})
BuildManifest.getArtifactRootUrl(dummy_job, 10545)
runSmokeTestScript.echo(Artifact root URL: https://ci.opensearch.org/ci/dbc/dummy_job/2.19.0/10545/linux/x64/tar)
runSmokeTestScript.echo(Paths: opensearch=https://ci.opensearch.org/ci/dbc/dummy_job/2.19.0/10545/linux/x64/tar)
runSmokeTestScript.sh(./test.sh smoke-test manifests/tests/jenkins/data/opensearch-2.19.0-test.yml --test-run-id 234 --paths opensearch=https://ci.opensearch.org/ci/dbc/dummy_job/2.19.0/10545/linux/x64/tar)
smoke-test.echo(Completed running smoke tests.)
smoke-test.postCleanup()
postCleanup.cleanWs({disableDeferredWipeout=true, deleteDirs=true})
smoke-test.postCleanup()
postCleanup.cleanWs({disableDeferredWipeout=true, deleteDirs=true})
smoke-test.node(Jenkins-Agent-AL2-X64-C54xlarge-Docker-Host, groovy.lang.Closure)
Expand Down

0 comments on commit b961790

Please sign in to comment.