Skip to content

Commit

Permalink
Add Jenkins pipelines for pre-release and nightly testing (#15426)
Browse files Browse the repository at this point in the history
Signed-off-by: Dmytro Nochevnov <[email protected]>
  • Loading branch information
dmytro-ndp authored Dec 16, 2019
1 parent 1bd9ce0 commit 2c756e6
Show file tree
Hide file tree
Showing 4 changed files with 424 additions and 17 deletions.
105 changes: 105 additions & 0 deletions tests/.infra/crw-ci/master/k8s/Jenkinsfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
pipeline {
agent { label 'rhel7-8gb' }

options {
timestamps()
timeout(time: 2, unit: 'HOURS')
buildDiscarder(logRotator(artifactDaysToKeepStr: '',
artifactNumToKeepStr: '', daysToKeepStr: '60', numToKeepStr: '30'))
}

// build each 3 hours
triggers { cron("H H/3 * * *") }

parameters {
string(name: 'emails',
defaultValue: '[email protected]',
description: 'Comma-separated list of emails to send results')
}

stages {
stage("Run E2E tests against master branch") {
parallel {
stage('Run Happy path tests') {
steps {
build job: 'basic-MultiUser-Che-check-e2e-tests-against-k8s',
parameters: [
string(name: 'cheImageRepo',
value: 'maxura/che-server'),

string(name: 'cheImageTag',
value: 'master'),

booleanParam(name: 'buildChe',
value: true),

string(name: 'ghprbSourceBranch',
value: 'master'),

string(name: 'ghprbPullId',
value: ''),

string(name: 'e2eTestToRun',
value: 'test-happy-path'),

string(name: 'testWorkspaceDevfileUrl',
value: 'https://raw.githubusercontent.com/eclipse/che/master/tests/e2e/files/happy-path/happy-path-workspace.yaml'),

text(name: 'customResourceFileContent',
value: ''),

booleanParam(name: 'createTestWorkspace',
value: true)
]
}
}

stage('Run Vert.x tests') {
steps {
build job: 'basic-MultiUser-Che-check-e2e-tests-against-k8s',
parameters: [
string(name: 'cheImageRepo',
value: 'maxura/che-server'),

string(name: 'cheImageTag',
value: 'master'),

booleanParam(name: 'buildChe',
value: true),

string(name: 'ghprbSourceBranch',
value: 'master'),

string(name: 'ghprbPullId',
value: ''),

string(name: 'e2eTestToRun',
value: 'test-java-vertx'),

string(name: 'testWorkspaceDevfileUrl',
value: ''),

text(name: 'customResourceFileContent',
value: ''),

booleanParam(name: 'createTestWorkspace',
value: false)
]
}
}
}
}
}

post {
failure {
script {
if (emails != "") {
mail to: emails,
subject: "Jenkins Job $currentBuild.fullDisplayName has failed.",
body: "Build $currentBuild.absoluteUrl has failed."
}
}
}
}
}
104 changes: 104 additions & 0 deletions tests/.infra/crw-ci/nightly/k8s/Jenkinsfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
pipeline {
agent { label 'rhel7-8gb' }

options {
timestamps()
timeout(time: 2, unit: 'HOURS')
buildDiscarder(logRotator(artifactDaysToKeepStr: '',
artifactNumToKeepStr: '', daysToKeepStr: '60', numToKeepStr: '30'))
}

triggers { cron("@midnight") }

parameters {
string(name: 'emails',
defaultValue: '[email protected]',
description: 'Comma-separated list of emails to send results')
}

stages {
stage("Run E2E tests") {
parallel {
stage('Run Happy path tests against nightly build') {
steps {
build job: 'basic-MultiUser-Che-check-e2e-tests-against-k8s',
parameters: [
string(name: 'cheImageRepo',
value: 'eclipse/che-server'),

string(name: 'cheImageTag',
value: 'nightly'),

booleanParam(name: 'buildChe',
value: false),

string(name: 'ghprbSourceBranch',
value: 'master'),

string(name: 'ghprbPullId',
value: ''),

string(name: 'e2eTestToRun',
value: 'test-happy-path'),

string(name: 'testWorkspaceDevfileUrl',
value: 'https://raw.githubusercontent.com/eclipse/che/master/tests/e2e/files/happy-path/happy-path-workspace.yaml'),

text(name: 'customResourceFileContent',
value: ''),

booleanParam(name: 'createTestWorkspace',
value: true)
]
}
}

stage('Run Vert.x tests against nightly build') {
steps {
build job: 'basic-MultiUser-Che-check-e2e-tests-against-k8s',
parameters: [
string(name: 'cheImageRepo',
value: 'eclipse/che-server'),

string(name: 'cheImageTag',
value: 'nightly'),

booleanParam(name: 'buildChe',
value: false),

string(name: 'ghprbSourceBranch',
value: 'master'),

string(name: 'ghprbPullId',
value: ''),

string(name: 'e2eTestToRun',
value: 'test-java-vertx'),

string(name: 'testWorkspaceDevfileUrl',
value: ''),

text(name: 'customResourceFileContent',
value: ''),

booleanParam(name: 'createTestWorkspace',
value: false)
]
}
}
}
}
}

post {
failure {
script {
if (emails != "") {
mail to: emails,
subject: "Jenkins Job $currentBuild.fullDisplayName has failed.",
body: "Build $currentBuild.absoluteUrl has failed."
}
}
}
}
}
58 changes: 41 additions & 17 deletions tests/.infra/crw-ci/pr-check/k8s/Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ pipeline {

options {
timestamps()
timeout(time: 60, unit: 'MINUTES')
timeout(time: 1, unit: 'HOURS')
buildDiscarder(logRotator(artifactDaysToKeepStr: '',
artifactNumToKeepStr: '', daysToKeepStr: '60', numToKeepStr: '100'))
}
Expand All @@ -15,10 +15,13 @@ pipeline {
JENKINS_BUILD = "true"

DEVFILE_PATH = "${WORKSPACE}/test-workspace-devfile.yaml"
CUSTOM_RESOURCE_FILE_PATH = "${WORKSPACE}/custom-resource.yaml"

SUCCESS_THRESHOLD = 5

LOGS_AND_CONFIGS="${WORKSPACE}/logs-and-configs"
LOGS_AND_CONFIGS ="${WORKSPACE}/logs-and-configs"

mutableCheImageTag = ""
}

parameters {
Expand All @@ -42,17 +45,36 @@ pipeline {
defaultValue: "",
description: 'URL of devfile of test workspace')

text(name: 'customResourceFileContent',
defaultValue: "",
description: 'Content of custom-resource.yaml')

booleanParam(name: 'createTestWorkspace',
defaultValue: true,
description: 'Should create test workspace')

string(name: 'ghprbSourceBranch',
defaultValue: "master")
}

stages {
stage("Setup environment") {
steps {
script {
if (cheImageTag == null || cheImageTag == '') {
cheImageTag = ghprbPullId
mutableCheImageTag = ghprbPullId
} else {
mutableCheImageTag = cheImageTag
}

if (customResourceFileContent == null || customResourceFileContent == '') {
sh """
wget https://raw.githubusercontent.com/eclipse/che-operator/master/deploy/crds/org_v1_che_cr.yaml \\
-O $CUSTOM_RESOURCE_FILE_PATH
"""

} else {
writeFile file: CUSTOM_RESOURCE_FILE_PATH, text: customResourceFileContent
}
}
}
Expand Down Expand Up @@ -107,10 +129,13 @@ pipeline {

stage("Build Che including upstream projects") {
when {
expression { buildChe }
expression { return buildChe.toString() == 'true' }
}

steps {
echo "buildChe = $params.buildChe"
echo "createTestWorkspace = $params.createTestWorkspace"

echo "Build branch ${ghprbSourceBranch} of upstream projects"
sh """
project_list=(
Expand Down Expand Up @@ -140,33 +165,31 @@ pipeline {

stage("Build and push che-server image") {
when {
expression { buildChe }
expression { return buildChe.toString() == 'true' }
}

steps {
withCredentials([string(credentialsId: 'ed71c034-60bc-4fb1-bfdf-9570209076b5', variable: 'maxura_docker_password')]) {
sh """
${WORKSPACE}/dockerfiles/che/build.sh --dockerfile:Dockerfile
docker tag eclipse/che-server:nightly docker.io/${cheImageRepo}:${cheImageTag}
docker tag eclipse/che-server:nightly docker.io/${cheImageRepo}:${mutableCheImageTag}
docker login -u maxura -p ${maxura_docker_password}
docker push docker.io/${cheImageRepo}:${cheImageTag}
docker push docker.io/${cheImageRepo}:${mutableCheImageTag}
"""
}
}
}

stage("Start Che") {
steps {
echo "Download and patch Che custom-resource.yaml"
echo "Patch Che custom-resource.yaml"
sh """
wget https://raw.githubusercontent.com/eclipse/che-operator/master/deploy/crds/org_v1_che_cr.yaml
sed -i "s|cheImage: ''|cheImage: '${cheImageRepo}'|" ${WORKSPACE}/org_v1_che_cr.yaml
sed -i "s|cheImageTag: 'nightly'|cheImageTag: '${cheImageTag}'|" ${WORKSPACE}/org_v1_che_cr.yaml
sed -i "s|cheImage: ''|cheImage: '${cheImageRepo}'|" $CUSTOM_RESOURCE_FILE_PATH
sed -i "s|cheImageTag: 'nightly'|cheImageTag: '${mutableCheImageTag}'|" $CUSTOM_RESOURCE_FILE_PATH
sed -i "s|cheLogLevel: INFO|cheLogLevel: DEBUG|" ${WORKSPACE}/org_v1_che_cr.yaml
sed -i "s|cheLogLevel: INFO|cheLogLevel: DEBUG|" $CUSTOM_RESOURCE_FILE_PATH
sed -i "s|ingressDomain: '192.168.99.101.nip.io'|ingressDomain: '\$(minikube ip).nip.io'|" ${WORKSPACE}/org_v1_che_cr.yaml
sed -i "s|ingressDomain: '192.168.99.101.nip.io'|ingressDomain: '\$(minikube ip).nip.io'|" $CUSTOM_RESOURCE_FILE_PATH
"""

echo "Install Che"
Expand All @@ -176,7 +199,7 @@ pipeline {
--installer=operator \\
--listr-renderer=verbose \\
--platform=minikube \\
--che-operator-cr-yaml=${WORKSPACE}/org_v1_che_cr.yaml
--che-operator-cr-yaml=$CUSTOM_RESOURCE_FILE_PATH
"""

script {
Expand Down Expand Up @@ -218,7 +241,7 @@ pipeline {

stage("Create test workspace") {
when {
expression { createTestWorkspace }
expression { return createTestWorkspace.toString() == 'true' }
}

steps {
Expand Down Expand Up @@ -276,7 +299,7 @@ pipeline {

post {
failure {
echo "Create screencast from $WORKSPACE/e2e/report/executionScreencast files."
echo "Create screencast from $WORKSPACE/tests/e2e/report/executionScreencast files."
sh """
command -v ffmpeg >/dev/null 2>&1 && if ls $WORKSPACE/tests/e2e/report/executionScreencast/*.png 1> /dev/null 2>&1; then
cd $WORKSPACE/tests/e2e/report/executionScreencast
Expand All @@ -300,6 +323,7 @@ pipeline {
cp ${WORKSPACE}/org_v1_che_cr.yaml $LOGS_AND_CONFIGS/che-config || true
cp ${DEVFILE_PATH} $LOGS_AND_CONFIGS || true
cp ${CUSTOM_RESOURCE_FILE_PATH} $LOGS_AND_CONFIGS || true
kubectl get checluster --namespace=che -o yaml > $LOGS_AND_CONFIGS/che-config/checluster.yaml || true
kubectl get configmaps --namespace=che che -o yaml > $LOGS_AND_CONFIGS/che-config/configmap.yaml || true
Expand Down
Loading

0 comments on commit 2c756e6

Please sign in to comment.