Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a validation stage before triggering the Integration tests for OS and OSD #4481

Merged
merged 3 commits into from
Feb 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 35 additions & 1 deletion jenkins/opensearch-dashboards/integ-test.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.3.0', retriever: modernSCM([
lib = library(identifier: 'jenkins@6.3.2', retriever: modernSCM([

$class: 'GitSCMSource',
remote: 'https://github.com/opensearch-project/opensearch-build-libraries.git',
Expand Down Expand Up @@ -72,6 +72,11 @@ pipeline {
description: 'If true results will create / update / close github issues',
defaultValue: false
)
booleanParam(
name: 'VALIDATE_ARTIFACTS',
description: 'If true the provided artifacts are validated before triggering integ-tests else skip the validation stage',
defaultValue: true
)
}
stages {
stage('verify-parameters') {
Expand Down Expand Up @@ -132,6 +137,35 @@ pipeline {
}
}
}
stage('validate-artifacts') {
when {
expression {
params.VALIDATE_ARTIFACTS == true
}
}
agent { label agent_nodes['linux_x64'] }
steps {
script {
build job: 'distribution-validation',
propagate: true,
wait: true,
parameters: [
string(name: 'VERSION', value: "${env.version}"),
string(name: 'DISTRIBUTION', value: "${env.distribution}"),
string(name: 'ARCHITECTURE', value: "${env.architecture}"),
string(name: 'OS_BUILD_NUMBER', value: "${env.buildIdOpenSearch}"),
string(name: 'OSD_BUILD_NUMBER', value: "${env.buildId}"),
string(name: 'PROJECTS', value: "Both"),
string(name: 'ARTIFACT_TYPE', value: "staging")
]
}
}
post {
always {
postCleanup()
}
}
}
stage('integ-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
Expand Down
35 changes: 34 additions & 1 deletion jenkins/opensearch/integ-test.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.3.0', retriever: modernSCM([
lib = library(identifier: 'jenkins@6.3.2', retriever: modernSCM([

$class: 'GitSCMSource',
remote: 'https://github.com/opensearch-project/opensearch-build-libraries.git',
Expand Down Expand Up @@ -72,6 +72,11 @@ pipeline {
description: 'If true results will create / update / close github issues',
defaultValue: false
)
booleanParam(
name: 'VALIDATE_ARTIFACTS',
description: 'If true the provided artifacts are validated before triggering integ-tests else skip the validation stage',
defaultValue: true
)
}
stages {
stage('verify-parameters') {
Expand Down Expand Up @@ -108,6 +113,34 @@ pipeline {
}
}
}
stage('validate-artifacts') {
when {
expression {
params.VALIDATE_ARTIFACTS == true
}
}
agent { label agent_nodes['linux_x64'] }
steps {
script {
build job: 'distribution-validation',
propagate: true,
wait: true,
parameters: [
string(name: 'VERSION', value: "${env.version}"),
string(name: 'DISTRIBUTION', value: "${env.distribution}"),
string(name: 'ARCHITECTURE', value: "${env.architecture}"),
string(name: 'OS_BUILD_NUMBER', value: "${env.buildId}"),
string(name: 'PROJECTS', value: "opensearch"),
string(name: 'ARTIFACT_TYPE', value: "staging")
]
}
}
post {
always {
postCleanup()
}
}
}
stage('integ-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
Expand Down
11 changes: 10 additions & 1 deletion tests/jenkins/TestOpenSearchDashboardsIntegTest.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class TestOpenSearchDashboardsIntegTest extends BuildPipelineTest {

helper.registerSharedLibrary(
library().name('jenkins')
.defaultVersion('6.3.0')
.defaultVersion('6.3.2')
.allowOverride(true)
.implicit(true)
.targetPath('vars')
Expand Down Expand Up @@ -104,6 +104,7 @@ class TestOpenSearchDashboardsIntegTest extends BuildPipelineTest {
void integTests_runs_for_all_components() {
super.testPipeline('jenkins/opensearch-dashboards/integ-test.jenkinsfile',
'tests/jenkins/jenkinsjob-regression-files/opensearch-dashboards/integ-test.jenkinsfile')
assert getCommandExecutions('stage', 'validate-artifacts').size() == 1
assertThat(getCommandExecutions('sh', 'test.sh'), hasItems(
'env PATH=$PATH ./test.sh integ-test manifests/tests/jenkins/data/opensearch-dashboards-3.0.0-test.yml --component ganttChartDashboards --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(),
'env PATH=$PATH ./test.sh integ-test manifests/tests/jenkins/data/opensearch-dashboards-3.0.0-test.yml --component anomalyDetectionDashboards --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(),
Expand Down Expand Up @@ -236,6 +237,14 @@ class TestOpenSearchDashboardsIntegTest extends BuildPipelineTest {
assertThat(getCommandExecutions('sh', 'gh issue'), hasItem('{script=gh issue edit 99 -R https://github.com/opensearch-project/dashboards-observability.git --add-label \"linux:tar:x64\", returnStdout=true}'))
}

@Test
void whenValidationIsNotChecked() {
addParam('VALIDATE_ARTIFACTS', false)
super.testPipeline('jenkins/opensearch-dashboards/integ-test.jenkinsfile',
'tests/jenkins/jenkinsjob-regression-files/opensearch-dashboards/integ-test-without-validation.jenkinsfile')
assert getCommandExecutions('stage', 'validate-artifacts').size() == 0
}

def getCommandExecutions(methodName, command) {
def shCommands = helper.callStack.findAll {
call ->
Expand Down
11 changes: 10 additions & 1 deletion tests/jenkins/TestOpenSearchIntegTest.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class TestOpenSearchIntegTest extends BuildPipelineTest {

helper.registerSharedLibrary(
library().name('jenkins')
.defaultVersion('6.3.0')
.defaultVersion('6.3.2')
.allowOverride(true)
.implicit(true)
.targetPath('vars')
Expand Down Expand Up @@ -90,6 +90,7 @@ class TestOpenSearchIntegTest extends BuildPipelineTest {
addParam('UPDATE_GITHUB_ISSUES', true)
super.testPipeline('jenkins/opensearch/integ-test.jenkinsfile',
'tests/jenkins/jenkinsjob-regression-files/opensearch/integ-test.jenkinsfile')
assert getCommandExecutions('stage', 'validate-artifacts').size() == 1
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]'))
Expand Down Expand Up @@ -213,6 +214,14 @@ class TestOpenSearchIntegTest extends BuildPipelineTest {
assertThat(getCommandExecutions('sh', 'gh issue'), hasItem('{script=gh issue edit 99 -R https://github.com/opensearch-project/k-NN.git --add-label \"linux:tar:x64\", returnStdout=true}'))
}

@Test
void whenValidationIsNotChecked() {
addParam('VALIDATE_ARTIFACTS', false)
super.testPipeline('jenkins/opensearch/integ-test.jenkinsfile',
'tests/jenkins/jenkinsjob-regression-files/opensearch/integ-test-without-validation.jenkinsfile')
assert getCommandExecutions('stage', 'validate-artifacts').size() == 0
}

def getCommandExecutions(methodName, command) {
def shCommands = helper.callStack.findAll {
call ->
Expand Down
Loading
Loading