Skip to content

Commit

Permalink
Add publishIntegTestResults
Browse files Browse the repository at this point in the history
Signed-off-by: Prudhvi Godithi <[email protected]>
  • Loading branch information
prudhvigodithi committed Jul 22, 2024
1 parent 5124b1a commit 71f17c7
Show file tree
Hide file tree
Showing 10 changed files with 191 additions and 109 deletions.
16 changes: 15 additions & 1 deletion jenkins/opensearch-dashboards/distribution-build.jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* compatible open source license.
*/

lib = library(identifier: 'jenkins@6.5.0', retriever: modernSCM([
lib = library(identifier: 'jenkins@6.7.0', retriever: modernSCM([
$class: 'GitSCMSource',
remote: 'https://github.com/opensearch-project/opensearch-build-libraries.git',
]))
Expand Down Expand Up @@ -60,6 +60,11 @@ pipeline {
defaultValue: 'linux windows',
trim: true
)
string(
name: 'RC_NUMBER',
description: 'If true results will create / update / close github issues',
defaultValue: '0'
)
string( // Note: need to update 'verify-parameters' entries if you add new distribution(s)
name: 'BUILD_DISTRIBUTION',
description: 'Build selected distribution related artifacts, choices include tar, rpm, deb, zip. Can combine multiple distributions with space in between (docker is only available on tar)',
Expand Down Expand Up @@ -948,6 +953,15 @@ pipeline {
inputManifestPath: "manifests/$INPUT_MANIFEST"
)
}
def rc = (params.RC_NUMBER.toInteger() > 0)
publishDistributionBuildResults(
failureMessages: buildMessage(search: 'Error building'),
passMessages: buildMessage(search: 'Successfully built'),
inputManifestPath: "manifests/$INPUT_MANIFEST",
rc: rc,
rcNumber: env.RC_NUMBER,
componentCategory: "OpenSearch Dashboards"
)
postCleanup()
}
}
Expand Down
24 changes: 22 additions & 2 deletions jenkins/opensearch-dashboards/integ-test.jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@
* compatible open source license.
*/

lib = library(identifier: '[email protected]', retriever: modernSCM([

lib = library(identifier: '[email protected]', retriever: modernSCM([
$class: 'GitSCMSource',
remote: 'https://github.com/opensearch-project/opensearch-build-libraries.git',
]))
Expand Down Expand Up @@ -72,6 +71,11 @@ pipeline {
description: 'If true results will create / update / close github issues',
defaultValue: false
)
string(
name: 'RC_NUMBER',
description: 'If true results will create / update / close github issues',
defaultValue: '0'
)
booleanParam(
name: 'VALIDATE_ARTIFACTS',
description: 'If true the provided artifacts are validated before triggering integ-tests else skip the validation stage',
Expand Down Expand Up @@ -359,6 +363,22 @@ pipeline {
archiveArtifacts artifacts: 'test-report.yml'
}
}
docker.withRegistry('https://public.ecr.aws/') {
docker.image(docker_images["tar"]).inside(docker_args["tar"]) {
def rc = (params.RC_NUMBER.toInteger() > 0)
publishIntegTestResults(
version: env.version,
distributionBuildNumber: env.buildId,
distributionBuildUrl: "https://build.ci.opensearch.org/blue/organizations/jenkins/${env.BUILD_JOB_NAME}/detail/${env.BUILD_JOB_NAME}/${env.buildId}/pipeline",
rc: rc,
rcNumber: env.RC_NUMBER,
platform: env.platform,
architecture: env.architecture,
distribution: env.distribution,
testReportManifestYml: "test-report.yml"
)
}
}
}
}
postCleanup()
Expand Down
18 changes: 17 additions & 1 deletion jenkins/opensearch/distribution-build.jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* compatible open source license.
*/

lib = library(identifier: 'jenkins@6.5.0', retriever: modernSCM([
lib = library(identifier: 'jenkins@6.7.0', retriever: modernSCM([
$class: 'GitSCMSource',
remote: 'https://github.com/opensearch-project/opensearch-build-libraries.git',
]))
Expand Down Expand Up @@ -59,6 +59,11 @@ pipeline {
defaultValue: 'linux macos windows',
trim: true
)
string(
name: 'RC_NUMBER',
description: 'If true results will create / update / close github issues',
defaultValue: '0'
)
choice(
name: 'BUILD_DOCKER',
description: 'Build docker image or not with options.',
Expand Down Expand Up @@ -666,6 +671,7 @@ pipeline {
expression {
params.BUILD_PLATFORM.contains('linux')
}

}
agent { label AGENT_LINUX_ARM64 }
stages {
Expand Down Expand Up @@ -892,8 +898,18 @@ pipeline {
inputManifestPath: "manifests/$INPUT_MANIFEST"
)
}
def rc = (params.RC_NUMBER.toInteger() > 0)
publishDistributionBuildResults(
failureMessages: buildMessage(search: 'Error building'),
passMessages: buildMessage(search: 'Successfully built'),
inputManifestPath: "manifests/$INPUT_MANIFEST",
rc: rc,
rcNumber: env.RC_NUMBER,
componentCategory: "OpenSearch"
)
postCleanup()
}

}
}
success {
Expand Down
27 changes: 24 additions & 3 deletions jenkins/opensearch/integ-test.jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,13 @@
* compatible open source license.
*/

lib = library(identifier: '[email protected]', retriever: modernSCM([

lib = library(identifier: '[email protected]', retriever: modernSCM([
$class: 'GitSCMSource',
remote: 'https://github.com/opensearch-project/opensearch-build-libraries.git',
]))

def docker_images = [
'tar': 'opensearchstaging/ci-runner:ci-runner-al2-opensearch-build-v1',
'tar': 'opensearchstaging/ci-runner:ci-runner-al2-opensearch-build-v1',
'rpm': 'opensearchstaging/ci-runner:ci-runner-almalinux8-systemd-base-integtest-v1',
'deb': 'opensearchstaging/ci-runner:ci-runner-ubuntu2004-systemd-base-integtest-v3',
'zip': 'opensearchstaging/ci-runner:ci-runner-windows2019-opensearch-build-v1',
Expand Down Expand Up @@ -72,6 +71,11 @@ pipeline {
description: 'If true results will create / update / close github issues',
defaultValue: false
)
string(
name: 'RC_NUMBER',
description: 'If true results will create / update / close github issues',
defaultValue: '0'
)
booleanParam(
name: 'VALIDATE_ARTIFACTS',
description: 'If true the provided artifacts are validated before triggering integ-tests else skip the validation stage',
Expand Down Expand Up @@ -147,6 +151,7 @@ pipeline {
agent { label AGENT_LABEL }
steps {
script {
echo 'Skip and test the publish integ test results'
downloadBuildManifest(
url: BUILD_MANIFEST_URL,
path: BUILD_MANIFEST
Expand Down Expand Up @@ -309,6 +314,22 @@ pipeline {
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")
archiveArtifacts artifacts: 'test-report.yml'
}
docker.withRegistry('https://public.ecr.aws/') {
docker.image(docker_images["tar"]).inside(docker_args["tar"]) {
def rc = (params.RC_NUMBER.toInteger() > 0)
publishIntegTestResults(
version: env.version,
distributionBuildNumber: env.buildId,
distributionBuildUrl: "https://build.ci.opensearch.org/blue/organizations/jenkins/${env.BUILD_JOB_NAME}/detail/${env.BUILD_JOB_NAME}/${env.buildId}/pipeline",
rc: rc,
rcNumber: env.RC_NUMBER,
platform: env.platform,
architecture: env.architecture,
distribution: env.distribution,
testReportManifestYml: "test-report.yml"
)
}
}
}
}
}
Expand Down
7 changes: 5 additions & 2 deletions tests/jenkins/TestOpenSearchDashboardsIntegTest.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@ class TestOpenSearchDashboardsIntegTest extends BuildPipelineTest {

helper.registerSharedLibrary(
library().name('jenkins')
.defaultVersion('6.5.0')
.defaultVersion('6.7.0')
.allowOverride(true)
.implicit(true)
.targetPath('vars')
.retriever(gitSource('https://github.com/opensearch-project/opensearch-build-libraries.git'))
.retriever(gitSource('https://github.com/opensearch-project//opensearch-build-libraries.git'))
.build()
)
super.setUp()
Expand Down Expand Up @@ -70,6 +70,7 @@ class TestOpenSearchDashboardsIntegTest extends BuildPipelineTest {
binding.setVariable('distribution', 'tar' )
binding.setVariable('COMPONENT_NAME', '' )
binding.getVariable('currentBuild').upstreamBuilds = [[fullProjectName: jobName]]
binding.setVariable('RC_NUMBER', '0')
def env = binding.getVariable('env')
env['DOCKER_AGENT'] = [image:'opensearchstaging/opensearchstaging/ci-runner:ci-runner-almallinux8-opensearch-dashboards-integtest-v1', args:'-e JAVA_HOME=/opt/java/openjdk-11']
env['PUBLIC_ARTIFACT_URL'] = 'DUMMY_PUBLIC_ARTIFACT_URL'
Expand Down Expand Up @@ -100,6 +101,7 @@ class TestOpenSearchDashboardsIntegTest extends BuildPipelineTest {
helper.registerAllowedMethod('unstash', [String.class], null)
}

///
@Test
void integTests_runs_for_all_components() {
super.testPipeline('jenkins/opensearch-dashboards/integ-test.jenkinsfile',
Expand All @@ -113,6 +115,7 @@ class TestOpenSearchDashboardsIntegTest extends BuildPipelineTest {
'env PATH=$PATH ./test.sh integ-test manifests/tests/jenkins/data/opensearch-dashboards-3.0.0-test.yml --component observabilityDashboards --test-run-id 215 --paths opensearch=/tmp/workspace/tar opensearch-dashboards=/tmp/workspace/tar --base-path DUMMY_PUBLIC_ARTIFACT_URL/dummy_job/3.0.0/215/linux/x64/tar '.toString()
))
assertThat(getCommandExecutions('sh', 'report.sh'), hasItems('./report.sh manifests/tests/jenkins/data/opensearch-dashboards-3.0.0-test.yml --artifact-paths opensearch=https://ci.opensearch.org/ci/dbc/distribution-build-opensearch/3.0.0/215/linux/x64/tar opensearch-dashboards=https://ci.opensearch.org/ci/dbc/distribution-build-opensearch-dashboards/3.0.0/215/linux/x64/tar --test-run-id 215 --test-type integ-test --base-path DUMMY_PUBLIC_ARTIFACT_URL/dummy_job/3.0.0/215/linux/x64/tar '))
assertCallStack().contains('{version=3.0.0, distributionBuildNumber=215, distributionBuildUrl=https://build.ci.opensearch.org/blue/organizations/jenkins/distribution-build-opensearch-dashboards/detail/distribution-build-opensearch-dashboards/215/pipeline, rc=false, rcNumber=null, platform=linux, architecture=x64, distribution=tar, testReportManifestYml=test-report.yml}')
}

@Test
Expand Down
6 changes: 4 additions & 2 deletions tests/jenkins/TestOpenSearchIntegTest.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@ class TestOpenSearchIntegTest extends BuildPipelineTest {

helper.registerSharedLibrary(
library().name('jenkins')
.defaultVersion('6.5.0')
.defaultVersion('6.7.0')
.allowOverride(true)
.implicit(true)
.targetPath('vars')
.retriever(gitSource('https://github.com/opensearch-project/opensearch-build-libraries.git'))
.retriever(gitSource('https://github.com/opensearch-project//opensearch-build-libraries.git'))
.build()
)

Expand Down Expand Up @@ -62,6 +62,7 @@ class TestOpenSearchIntegTest extends BuildPipelineTest {
binding.setVariable('RUN_DISPLAY_URL', 'https://some/url/redirect')
binding.setVariable('distribution', 'tar' )
binding.setVariable('COMPONENT_NAME', '' )
binding.setVariable('RC_NUMBER', '0')
binding.getVariable('currentBuild').upstreamBuilds = [[fullProjectName: jobName]]
helper.registerAllowedMethod("s3Download", [Map])
helper.registerAllowedMethod("withAWS", [Map, Closure], { args, closure ->
Expand Down Expand Up @@ -94,6 +95,7 @@ class TestOpenSearchIntegTest extends BuildPipelineTest {
assertThat(getCommandExecutions('sh', 'test.sh'), hasItem('env PATH=$PATH JAVA_HOME=/opt/java/openjdk-17 ./test.sh integ-test manifests/tests/jenkins/data/opensearch-3.0.0-test.yml --component k-NN --test-run-id 234 --paths opensearch=/tmp/workspace/tar --base-path DUMMY_PUBLIC_ARTIFACT_URL/dummy_job/3.0.0/9010/linux/x64/tar '))
assertThat(getCommandExecutions('sh', 'report.sh'), hasItem('./report.sh manifests/tests/jenkins/data/opensearch-3.0.0-test.yml --artifact-paths opensearch=https://ci.opensearch.org/ci/dbc/distribution-build-opensearch/3.0.0/9010/linux/x64/tar --test-run-id 234 --test-type integ-test --base-path DUMMY_PUBLIC_ARTIFACT_URL/dummy_job/3.0.0/9010/linux/x64/tar '))
assertThat(getCommandExecutions('echo', 'Testing'), hasItem('Testing components: [ml-commons, anomaly-detection, neural-search, security-analytics, security, k-NN, notifications]'))
assertCallStack().contains('{version=3.0.0, distributionBuildNumber=9010, distributionBuildUrl=https://build.ci.opensearch.org/blue/organizations/jenkins/distribution-build-opensearch/detail/distribution-build-opensearch/9010/pipeline, rc=false, rcNumber=null, platform=linux, architecture=x64, distribution=tar, testReportManifestYml=test-report.yml}')
}

@Test
Expand Down
Loading

0 comments on commit 71f17c7

Please sign in to comment.