Skip to content

Commit

Permalink
[Dashboards] integ-test in Jenkins
Browse files Browse the repository at this point in the history
Execute the integ-test workflow for OpenSearch Dashboards including
tests.

As opposed to OpenSearch, we need an image with the appropriate libraries
so we pass the image but it does not have the wget so the steps were broken
to access the build manifest.

Hardcoding the OpenSearch build id for now until this get resolves:
opensearch-project#1492

ARM tests will fail still until this is resolved:
opensearch-project#1381

Issue partially resolved:
opensearch-project#704

Signed-off-by: Kawika Avilla <[email protected]>
  • Loading branch information
kavilla committed Feb 18, 2022
1 parent 18c173c commit cc0166a
Show file tree
Hide file tree
Showing 13 changed files with 2,754 additions and 16 deletions.
75 changes: 64 additions & 11 deletions jenkins/opensearch-dashboards/distribution-build.jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,22 @@ lib = library(identifier: 'jenkins@20211123', retriever: legacySCM(scm))

pipeline {
agent none
environment {
AGENT_X64 = 'Jenkins-Agent-al2-x64-c54xlarge-Docker-Host'
AGENT_ARM64 = 'Jenkins-Agent-al2-arm64-c6g4xlarge-Docker-Host'
INTEG_TEST_JOB_NAME = 'integ-test-opensearch-dashboards'
}
parameters {
string(
name: 'INPUT_MANIFEST',
description: 'Input manifest under the manifests folder, e.g. 2.0.0/opensearch-dashboards-2.0.0.yml.',
trim: true
)
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
)
}
options {
copyArtifactPermission("${JOB_NAME}")
Expand All @@ -31,10 +41,10 @@ pipeline {
}
stage('build') {
parallel {
stage('build-linux-x64') {
stage('build-and-test-linux-x64') {
agent {
docker {
label 'Jenkins-Agent-al2-x64-c54xlarge-Docker-Host'
label AGENT_X64
image dockerAgent.image
args dockerAgent.args
alwaysPull true
Expand All @@ -47,9 +57,31 @@ pipeline {
platform: 'linux',
architecture: 'x64'
)
String buildManifestUrl = buildManifestObj.getUrl(JOB_NAME, BUILD_NUMBER)
String artifactUrl = buildManifestObj.getArtifactUrl(JOB_NAME, BUILD_NUMBER)
env.ARTIFACT_URL_X64 = artifactUrl
echo "buildManifestUrl (x64): ${buildManifestUrl}"
echo "artifactUrl (x64): ${artifactUrl}"
echo "agent image: ${dockerAgent.image}"

def integTestResults =
build job: INTEG_TEST_JOB_NAME,
propagate: false,
wait: true,
parameters: [
string(name: 'TEST_MANIFEST', value: "manifests/${TEST_MANIFEST}"),
string(name: 'BUILD_MANIFEST_URL', value: buildManifestUrl),
string(name: 'AGENT_LABEL', value: AGENT_X64),
string(name: 'AGENT_IMAGE', value: dockerAgent.image)
]

String status = integTestResults.getResult()
String icon = status == 'SUCCESS' ? ':white_check_mark:' : ':warning:'
lib.jenkins.Messages.new(this).add(
STAGE_NAME,
lib.jenkins.Messages.new(this).get([STAGE_NAME]) +
"\nInteg Tests (x64): ${icon} ${status} ${integTestResults.getAbsoluteUrl()}"
)
}
}
post {
Expand All @@ -58,13 +90,13 @@ pipeline {
}
}
}
stage('build-linux-arm64') {
stage('build-and-test-linux-arm64') {
agent none
stages {
stage('build-archive-linux-arm64') {
agent {
docker {
label 'Jenkins-Agent-al2-x64-c54xlarge-Docker-Host'
label AGENT_X64
image dockerAgent.image
args dockerAgent.args
alwaysPull true
Expand All @@ -85,10 +117,10 @@ pipeline {
}
}
}
stage('assemble-archive-linux-arm64') {
stage('assemble-archive-and-test-linux-arm64') {
agent {
docker {
label 'Jenkins-Agent-al2-arm64-c6g4xlarge-Docker-Host'
label AGENT_ARM64
image dockerAgent.image
args dockerAgent.args
alwaysPull true
Expand All @@ -102,9 +134,30 @@ pipeline {
architecture: 'arm64'
)

String buildManifestUrl = buildManifestObj.getUrl(JOB_NAME, BUILD_NUMBER)
String artifactUrl = buildManifestObj.getArtifactUrl(JOB_NAME, BUILD_NUMBER)
env.ARTIFACT_URL_ARM64 = artifactUrl
echo "buildManifestUrl (arm64): ${buildManifestUrl}"
echo "artifactUrl (arm64): ${artifactUrl}"

def integTestResults =
build job: INTEG_TEST_JOB_NAME,
propagate: false,
wait: true,
parameters: [
string(name: 'TEST_MANIFEST', value: "manifests/${TEST_MANIFEST}"),
string(name: 'BUILD_MANIFEST_URL', value: buildManifestUrl),
string(name: 'AGENT_LABEL', value: AGENT_ARM64),
string(name: 'AGENT_IMAGE', value: dockerAgent.image)
]

String status = integTestResults.getResult()
String icon = status == 'SUCCESS' ? ':white_check_mark:' : ':warning:'
lib.jenkins.Messages.new(this).add(
STAGE_NAME,
lib.jenkins.Messages.new(this).get([STAGE_NAME]) +
"\nInteg Tests (arm64): ${icon} ${status} ${integTestResults.getAbsoluteUrl()}"
)
}
}
post {
Expand All @@ -119,7 +172,7 @@ pipeline {
}
stage('docker build') {
steps {
node('Jenkins-Agent-al2-x64-c54xlarge-Docker-Host') {
node(AGENT_X64) {
script {
echo "env.ARTIFACT_URL_X64: ${env.ARTIFACT_URL_X64}"
echo "env.ARTIFACT_URL_ARM64: ${env.ARTIFACT_URL_ARM64}"
Expand All @@ -136,12 +189,12 @@ pipeline {
}
post {
success {
node('Jenkins-Agent-al2-x64-c54xlarge-Docker-Host') {
node(AGENT_X64) {
script {
def stashed = lib.jenkins.Messages.new(this).get([
'build-linux-x64',
'build-and-test-linux-x64',
'build-archive-linux-arm64',
'assemble-archive-linux-arm64'
'assemble-archive-and-test-linux-arm64'
])

publishNotification(
Expand All @@ -157,7 +210,7 @@ pipeline {
}
}
failure {
node('Jenkins-Agent-al2-x64-c54xlarge-Docker-Host') {
node(AGENT_X64) {
script {
publishNotification(
icon: ':warning:',
Expand Down
132 changes: 132 additions & 0 deletions jenkins/opensearch-dashboards/integ-test.jenkinsfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
lib = library(identifier: "jenkins@20211118", retriever: legacySCM(scm))

pipeline {
agent none
environment {
AWS_ROLE_ARN = "arn:aws:iam::${AWS_ACCOUNT_PUBLIC}:role/opensearch-test"
AWS_ROLE_SESSION_NAME = "jenkins-test-session"
BUILD_MANIFEST = "build-manifest.yml"
INTEG_TEST_JOB_NAME = 'integ-test-opensearch-dashboards'
}
parameters {
string(
defaultValue: '',
name: 'TEST_MANIFEST',
description: 'Test manifest under the manifests folder, e.g. manifests/2.0.0/opensearch-dashboards-2.0.0-test.yml.',
trim: true
)
string(
defaultValue: '',
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(
defaultValue: '',
name: 'AGENT_LABEL',
description: 'The agent label where the tests should be executed, e.g. Jenkins-Agent-al2-x64-c54xlarge-Docker-Host.',
trim: true
)
string(
defaultValue: '',
name: 'AGENT_IMAGE',
description: 'The agent label where the tests should be executed, e.g. opensearchstaging/ci-runner:centos7-x64-arm64-jdkmulti-node10.24.1-cypress6.9.1-20211028.',
trim: true
)
}
stages {
stage('download-manifest') {
agent {
node {
label "${AGENT_LABEL}"
}
}
steps {
script {
def buildManifestObj = downloadBuildManifest(
url: BUILD_MANIFEST_URL,
path: BUILD_MANIFEST
)
String buildId = buildManifestObj.getArtifactBuildId()
env.BUILD_ID = buildId

stash name: BUILD_MANIFEST, includes: BUILD_MANIFEST
}
}
}
stage('integ-test') {
agent {
docker {
label "${AGENT_LABEL}"
image "${AGENT_IMAGE}"
alwaysPull true
}
}
steps {
script {
unstash BUILD_MANIFEST
echo "BUILD_MANIFEST: ${BUILD_MANIFEST}"
echo "BUILD_ID: ${BUILD_ID}"

runIntegTestScript(
jobName: "${JOB_NAME}",
buildManifest: "${BUILD_MANIFEST}",
testManifest: "${TEST_MANIFEST}",
buildId: "${BUILD_ID}"
)
}
}
post {
always {
script {
uploadTestResults(
buildManifestFileName: "${BUILD_MANIFEST}",
jobName: "${INTEG_TEST_JOB_NAME}",
buildNumber: "${BUILD_ID}"
)
}
cleanWs disableDeferredWipeout: true, deleteDirs: true
}
}
}
}

post {
success {
node('Jenkins-Agent-al2-x64-m5xlarge') {
script {
def stashed = lib.jenkins.Messages.new(this).get(['integ-test'])
publishNotification(
icon: ':white_check_mark:',
message: 'Integration Tests Successful',
extra: stashed,
credentialsId: 'INTEG_TEST_WEBHOOK',
)

cleanWs(
disableDeferredWipeout: true,
deleteDirs: true
)
}
}
}
failure {
node('Jenkins-Agent-al2-x64-m5xlarge') {
script {
def stashed = lib.jenkins.Messages.new(this).get(['integ-test'])
publishNotification(
icon: ':warning:',
message: 'Failed Integration Tests',
extra: stashed,
credentialsId: 'INTEG_TEST_WEBHOOK',
)

cleanWs(
disableDeferredWipeout: true,
deleteDirs: true
)
}
}
}
}
}
2 changes: 1 addition & 1 deletion manifests/1.2.0/opensearch-dashboards-1.2.0-test.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
---
schema-version: '1.0'
name: OpenSearch Dashboards
components:
- name: functionalTestDashboards
integ-test:
test-configs:
- with-security
- without-security
schema-version: '1.0'
3 changes: 1 addition & 2 deletions manifests/2.0.0/opensearch-dashboards-2.0.0-test.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
---
schema-version: '1.0'
name: OpenSearch Dashboards
components:
- name: OpenSearch-Dashboards
Expand All @@ -8,6 +9,4 @@ components:
- name: functionalTestDashboards
integ-test:
test-configs:
- with-security
- without-security
schema-version: '1.0'
25 changes: 25 additions & 0 deletions tests/jenkins/TestRunIntegTestScript.groovy
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/*
* SPDX-License-Identifier: Apache-2.0
*
* The OpenSearch Contributors require contributions made to
* this file be licensed under the Apache-2.0 license or a
* compatible open source license.
*/

import jenkins.tests.BuildPipelineTest
import org.junit.Before
import org.junit.Test


class TestRunIntegTestScript extends BuildPipelineTest {

@Test
public void TestRunIntegTestScript() {
super.testPipeline("tests/jenkins/jobs/RunIntegTestScript_Jenkinsfile")
}

@Test
public void TestRunIntegTestScript_OpenSearch_Dasbhoards() {
super.testPipeline("tests/jenkins/jobs/RunIntegTestScript_OpenSearch_Dashboards_Jenkinsfile")
}
}
Loading

0 comments on commit cc0166a

Please sign in to comment.