Skip to content

Commit

Permalink
Run integtest for components present in test manifest (#4349)
Browse files Browse the repository at this point in the history
Signed-off-by: Sayali Gaikawad <[email protected]>
  • Loading branch information
gaiksaya authored Jan 18, 2024
1 parent 81dcc81 commit 24deb66
Show file tree
Hide file tree
Showing 4 changed files with 3,485 additions and 122 deletions.
70 changes: 34 additions & 36 deletions jenkins/opensearch/integ-test.jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,30 +7,30 @@
* compatible open source license.
*/

lib = library(identifier: 'jenkins@5.11.1', retriever: modernSCM([
lib = library(identifier: 'jenkins@6.1.0', retriever: modernSCM([

$class: 'GitSCMSource',
remote: 'https://github.com/opensearch-project/opensearch-build-libraries.git',
]))

def docker_images = [
"tar": "opensearchstaging/ci-runner:ci-runner-centos7-opensearch-build-v3",
"rpm": "opensearchstaging/ci-runner:ci-runner-rockylinux8-systemd-base-integtest-v3",
"deb": "opensearchstaging/ci-runner:ci-runner-ubuntu2004-systemd-base-integtest-v3",
"zip": "opensearchstaging/ci-runner:ci-runner-windows2019-servercore-opensearch-build-v1",
'tar': 'opensearchstaging/ci-runner:ci-runner-centos7-opensearch-build-v3',
'rpm': 'opensearchstaging/ci-runner:ci-runner-rockylinux8-systemd-base-integtest-v3',
'deb': 'opensearchstaging/ci-runner:ci-runner-ubuntu2004-systemd-base-integtest-v3',
'zip': 'opensearchstaging/ci-runner:ci-runner-windows2019-servercore-opensearch-build-v1',
]

def docker_args = [
"tar": "-u 1000",
"rpm": "--entrypoint=/usr/lib/systemd/systemd -u root --privileged -v /sys/fs/cgroup:/sys/fs/cgroup:rw --cgroupns=host",
"deb": "--entrypoint=/usr/lib/systemd/systemd -u root --privileged -v /sys/fs/cgroup:/sys/fs/cgroup:rw --cgroupns=host",
"zip": "-u ContainerAdministrator",
'tar': '-u 1000',
'rpm': '--entrypoint=/usr/lib/systemd/systemd -u root --privileged -v /sys/fs/cgroup:/sys/fs/cgroup:rw --cgroupns=host',
'deb': '--entrypoint=/usr/lib/systemd/systemd -u root --privileged -v /sys/fs/cgroup:/sys/fs/cgroup:rw --cgroupns=host',
'zip': '-u ContainerAdministrator',
]

def agent_nodes = [
"linux_x64": "Jenkins-Agent-AL2023-X64-C54xlarge-Docker-Host",
"linux_arm64": "Jenkins-Agent-AL2023-Arm64-C6g4xlarge-Docker-Host",
"windows_x64": "Jenkins-Agent-Windows2019-X64-C54xlarge-Docker-Host",
'linux_x64': 'Jenkins-Agent-AL2023-X64-C54xlarge-Docker-Host',
'linux_arm64': 'Jenkins-Agent-AL2023-Arm64-C6g4xlarge-Docker-Host',
'windows_x64': 'Jenkins-Agent-Windows2019-X64-C54xlarge-Docker-Host',
]

pipeline {
Expand All @@ -40,8 +40,8 @@ pipeline {
}
agent none
environment {
BUILD_MANIFEST = "build-manifest.yml"
BUILD_JOB_NAME = "distribution-build-opensearch"
BUILD_MANIFEST = 'build-manifest.yml'
BUILD_JOB_NAME = 'distribution-build-opensearch'
ARTIFACT_BUCKET_NAME = credentials('jenkins-artifact-bucket-name')
}
triggers {
Expand Down Expand Up @@ -74,7 +74,7 @@ pipeline {
}
stages {
stage('verify-parameters') {
agent { label agent_nodes["linux_x64"]}
agent { label agent_nodes['linux_x64'] }
steps {
script {
if (TEST_MANIFEST == '' || !fileExists("manifests/${TEST_MANIFEST}")) {
Expand All @@ -84,28 +84,22 @@ pipeline {

if (BUILD_MANIFEST_URL == '') {
currentBuild.result = 'ABORTED'
error("Integration Tests failed to start. Build manifest url was not provided.")
error('Integration Tests failed to start. Build manifest url was not provided.')
}

downloadBuildManifest(
url: BUILD_MANIFEST_URL,
path: BUILD_MANIFEST
)

def buildManifestObj = lib.jenkins.BuildManifest.new(readYaml(file: BUILD_MANIFEST))
def componentList = COMPONENT_NAME ? COMPONENT_NAME.trim().split(" ") as List : buildManifestObj.getNames()
env.architecture = buildManifestObj.getArtifactArchitecture()
env.platform = buildManifestObj.getArtifactPlatform()
env.buildId = buildManifestObj.getArtifactBuildId()
env.distribution = buildManifestObj.getDistribution()
env.version = buildManifestObj.build.version
env.platform = buildManifestObj.build.platform
env.artifactPath = buildManifestObj.getArtifactRoot(BUILD_JOB_NAME, buildId)
env.AGENT_LABEL = agent_nodes["${env.platform}_${architecture}"]
env.updateGithubIssues = UPDATE_GITHUB_ISSUES && env.distribution == 'tar'

echo "Version: ${version}, Agent: ${AGENT_LABEL}, BuildId: ${buildId}, Distribution: ${distribution}, Components: ${componentList}"
currentBuild.description = "$TEST_MANIFEST, $version, $architecture, $platform, $buildId, $distribution, $componentList"
}
}
post {
Expand All @@ -120,28 +114,33 @@ pipeline {
agent { label AGENT_LABEL }
steps {
script {

downloadBuildManifest(
url: BUILD_MANIFEST_URL,
path: BUILD_MANIFEST
)

def buildManifestObj = lib.jenkins.BuildManifest.new(readYaml(file: BUILD_MANIFEST))
def componentDefaultList = buildManifestObj.getNames()
def componentList = COMPONENT_NAME ? COMPONENT_NAME.trim().split(" ") as List : componentDefaultList
def testManifestObj = lib.jenkins.TestManifest.new(readYaml(file: "manifests/${TEST_MANIFEST}"))
def componentDefaultList = testManifestObj.getComponentNames()
def componentsInBuildManifest = buildManifestObj.getNames()
def componentList = COMPONENT_NAME ? COMPONENT_NAME.trim().split(' ') as List : componentDefaultList
String switch_user_non_root = (distribution.equals('rpm') || distribution.equals('deb')) ? 'true' : 'false'
echo "switch_user_non_root: ${switch_user_non_root}"
echo "componentList: ${componentList}"

for (component_check in componentList) {
if (!componentDefaultList.contains(component_check)) {
error("${component_check} is not in build manifest: ${componentDefaultList}, exit 1")
error("${component_check} is not present in the test manifest: ${TEST_MANIFEST}")
}
if (!componentsInBuildManifest.contains(component_check)) {
echo "Skipping tests for ${component_check} as is not present in the provided build manifest."
componentList -= component_check
}
}
echo "Testing components: ${componentList}"
currentBuild.description = "$TEST_MANIFEST, $version, $architecture, $platform, $buildId, $distribution, $componentList"

if (env.platform != 'windows') {
echo "Not on Windows, stash repository+artifacts"
echo "Downloading from S3: ${artifactPath}"
echo "Downloading from ${artifactPath} and stashing both artifacts and repository"
downloadFromS3(
assumedRoleName: 'opensearch-bundle',
roleAccountNumberCred: 'jenkins-aws-account-public',
Expand All @@ -153,12 +152,12 @@ pipeline {
sh("rm -rf $WORKSPACE/$distribution && mv -v $WORKSPACE/artifacts/${artifactPath} $WORKSPACE")
}
else {
echo "On Windows Platform, stash repository only"
echo 'Skipping artifacts downloads since platform is Windows and only stashing the repository'
}

// Stash the current working directory files, aka opensearch-build repo
// Unstash later in each triggered stage to run integTest
stash includes: "**", name: "integtest-opensearch-$BUILD_NUMBER"
stash includes: '**', name: "integtest-opensearch-$BUILD_NUMBER"

componentTests = [:]

Expand All @@ -171,7 +170,7 @@ pipeline {
def wait_seconds = local_component_index * 20

echo "Add Component: ${local_component}"
componentTests["Run Integtest ${local_component}"] = {
componentTests["Testing ${local_component}"] = {
// Using scripted pipelines to trigger dynamic parallel stages
timeout(time: 2, unit: 'HOURS') {
node(AGENT_LABEL) {
Expand All @@ -186,8 +185,7 @@ pipeline {
sh("echo ${local_component} with index ${local_component_index} will sleep ${wait_seconds} seconds to reduce load && sleep ${wait_seconds}")
unstash "integtest-opensearch-$BUILD_NUMBER"
if (env.platform == 'windows') {
echo "On Windows Platform, unstash repository and download the artifacts"
echo "Downloading from S3: ${artifactPath}"
echo "Unstashing the repository and downloading the artifacts from S3: ${artifactPath}"
downloadFromS3(
assumedRoleName: 'opensearch-bundle',
roleAccountNumberCred: 'jenkins-aws-account-public',
Expand All @@ -199,7 +197,7 @@ pipeline {
sh("rm -rf $WORKSPACE/$distribution && mv -v $WORKSPACE/artifacts/${artifactPath} $WORKSPACE")
}
else {
echo "Not on Windows, unstash repository+artifacts"
echo 'Unstashing both artifacts and repository'
}

sh('rm -rf test-results')
Expand Down Expand Up @@ -267,7 +265,7 @@ pipeline {
testManifest: "manifests/${TEST_MANIFEST}",
buildManifest: BUILD_MANIFEST,
testRunID: "${env.BUILD_NUMBER}",
testType: "integ-test",
testType: 'integ-test',
componentName: "${COMPONENT_NAME}",
)
echo("Download report manifest from https://ci.opensearch.org/ci/dbc/integ-test/${env.version}/${env.buildId}/${env.platform}/${env.architecture}/${env.distribution}/test-results/${env.BUILD_NUMBER}/integ-test/test-report.yml")
Expand Down
Loading

0 comments on commit 24deb66

Please sign in to comment.