From 3c7f761079f7e7c22e70fe5c666f2cf39716c82a Mon Sep 17 00:00:00 2001 From: Dmytro Nochevnov Date: Tue, 6 Aug 2019 08:41:04 +0300 Subject: [PATCH 01/12] Add Jenkinsfile to run E2E Happy path tests Signed-off-by: Dmytro Nochevnov --- e2e/jenkins/crw-ci/k8s/pr-check/Jenkinsfile | 229 ++++++++++++++++++++ 1 file changed, 229 insertions(+) create mode 100644 e2e/jenkins/crw-ci/k8s/pr-check/Jenkinsfile diff --git a/e2e/jenkins/crw-ci/k8s/pr-check/Jenkinsfile b/e2e/jenkins/crw-ci/k8s/pr-check/Jenkinsfile new file mode 100644 index 00000000000..bdc69099ff5 --- /dev/null +++ b/e2e/jenkins/crw-ci/k8s/pr-check/Jenkinsfile @@ -0,0 +1,229 @@ +#!groovy + +pipeline { + agent { label 'codenvy-slave9' } + + options { + timestamps() + buildDiscarder(logRotator(artifactDaysToKeepStr: '', + artifactNumToKeepStr: '', daysToKeepStr: '60', numToKeepStr: '100')) + } + + // triggers { cron("@midnight") } + + environment { + PATH = "/tmp:/qa/tools/opt/apache-maven-3.5.4/bin:$PATH" + JENKINS_BUILD = "true" + + DEVFILE_URL = "${WORKSPACE}/e2e/files/happy-path/happy-path-workspace.yaml" + SUCCESS_THRESHOLD = 5 + + CHE_IMAGE_REPO = "maxura/che-server" + CHE_IMAGE_TAG = "${ghprbPullId}" + } + + stages { + stage("Prepare codebase") { + failFast true + + parallel { + stage("Cleanup") { + steps { + script() { + sh "env" + + sh """ + sudo rm -rf ${WORKSPACE}/e2e/report/* + /usr/local/bin/minikube delete + """ + } + } + } + + stage("Get sources") { + steps { + checkout([$class : 'GitSCM', + branches : [[name: "*/${ghprbSourceBranch}"]], + doGenerateSubmoduleConfigurations: false, + extensions : [[$class : 'RelativeTargetDirectory', + relativeTargetDir: 'che']], + userRemoteConfigs : [[url: "https://github.com/${ghprbGhRepository}.git"]]]) + } + } + } + } + + stage("Prepare to start Che on K8S") { + failFast true + + parallel { + stage("Download chectl") { + steps { + script { + sh """ + wget --no-verbose https://github.com/che-incubator/chectl/releases/latest/download/chectl-linux + sudo mv chectl-linux /usr/local/bin/chectl + sudo chmod +x /usr/local/bin/chectl +""" + } + } + } + + stage("Start Kubernetes") { + steps { + script { + sh """ + /usr/local/bin/minikube start \\ + --vm-driver=none \\ + --cpus 4 \\ + --memory 12288 \\ + --logtostderr + + sudo chmod g+r -R /home/codenvy/.minikube + sudo chmod g+r -R /home/codenvy/.kube + sudo chmod g+r /var/lib/kubeadm.yaml +""" + } + } + } + + stage("Build Che") { + steps { + script { + sh "mvn clean install -f ${WORKSPACE}/che/pom.xml" + } + } + } + } + } + + stage("Push Che artifacts") { + steps { + withCredentials([string(credentialsId: 'ed71c034-60bc-4fb1-bfdf-9570209076b5', variable: 'maxura_docker_password')]) { + script { + sh """ + ${WORKSPACE}/che/dockerfiles/che/build.sh --organization:maxura --tag:${CHE_IMAGE_TAG} --dockerfile:Dockerfile + docker tag ${CHE_IMAGE_REPO}:${CHE_IMAGE_TAG} docker.io/${CHE_IMAGE_REPO}:${CHE_IMAGE_TAG} + docker login -u maxura -p ${maxura_docker_password} + docker push docker.io/${CHE_IMAGE_REPO}:${CHE_IMAGE_TAG} +""" + } + + } + } + } + + stage("Start Che") { + steps { + script { + sh """ + /usr/local/bin/chectl server:start \\ + --k8spodreadytimeout=180000 \\ + -t=${WORKSPACE}/deploy/ \\ + --listr-renderer=verbose \\ + --cheimage=${CHE_IMAGE_REPO}:${CHE_IMAGE_TAG} +""" + + // wait che-server to be available + sh """ + CHE_URL=\$(kubectl get ingress che-ingress -n=che -o=jsonpath={'.spec.rules[0].host'}) + + COUNTER=0; + SUCCESS_RATE_COUNTER=0; + while true; do + if [ \$COUNTER -gt 180 ]; then + echo "Unable to get stable route. Exiting" + exit 1 + fi + + ((COUNTER+=1)) + + + STATUS_CODE=\$(curl -sL -w "%{http_code}" -I \${CHE_URL} -o /dev/null; true) || true # added true to not fail the script completely. + + echo "Try \${COUNTER}. Status code: \${STATUS_CODE}" + if [ "\$STATUS_CODE" == "200" ]; then + ((SUCCESS_RATE_COUNTER+=1)) + fi + sleep 1; + + if [ \$SUCCESS_RATE_COUNTER == \$SUCCESS_THRESHOLD ]; then + echo "Route is stable enough. Continuing running tests" + break + fi + done +""" + } + } + } + + stage("Create ws from devfile") { + steps { + script { + sh """ + /usr/local/bin/chectl workspace:start --devfile=$DEVFILE_URL + kubectl get configmaps --namespace=che che -o yaml +""" + } + } + } + + stage("Run Happy path tests against Che on Kubernetes") { + steps { + script { + // TODO switch to eclipse/che-e2e image +// sh """ +// CHE_HOST=\$(kubectl get ingress che-ingress -n=che -o=jsonpath={'.spec.rules[0].host'}) +// CHE_URL=http://\${CHE_HOST} +// docker run --shm-size=256m --net=host --ipc=host \\ +// -e TS_SELENIUM_HEADLESS='true' \\ +// -e TS_SELENIUM_DEFAULT_TIMEOUT=300000 \\ +// -e TS_SELENIUM_LOAD_PAGE_TIMEOUT=240000 \\ +// -e TS_SELENIUM_WORKSPACE_STATUS_POLLING=20000 \\ +// -e TS_SELENIUM_BASE_URL=\${CHE_URL} \\ +// -v ${WORKSPACE}/che/e2e:/root/local_tests:Z \\ +// eclipse/che-e2e:nightly +//""" + + sh """ + CHE_HOST=\$(kubectl get ingress che-ingress -n=che -o=jsonpath={'.spec.rules[0].host'}) + CHE_URL=http://\${CHE_HOST} + docker run --net=host --ipc=host \\ + -e TS_SELENIUM_HEADLESS='true' \\ + -e TS_SELENIUM_DEFAULT_TIMEOUT=300000 \\ + -e TS_SELENIUM_LOAD_PAGE_TIMEOUT=240000 \\ + -e TS_SELENIUM_BASE_URL=\${CHE_URL} \\ + -e TS_SELENIUM_WORKSPACE_STATUS_POLLING=20000 \\ + -w /home/che/e2e \\ + -v $WORKSPACE:/home:Z \\ + cypress/browsers:node8.9.3-chrome73 bash -c "npm install && npm run test-happy-path" +""" + } + } + } + } + + post { + always { + script { + // it's impossible to use 'when' in the global post block + if (currentBuild.currentResult != 'ABORTED') { + // stop_minikube + sh """ + /usr/local/bin/minikube stop || true +""" + + sh """ +sudo umount \$(mount | grep "kubelet" | awk '{if(NR>0) print \$3}') || true +sudo rm -rf `sudo find /tmp -name 'hostpath-provisioner' 2>/dev/null` || true + +docker volume rm \$(docker volume ls -q -f dangling=true) || true +""" + } + } + + archiveArtifacts allowEmptyArchive: true, artifacts: "${WORKSPACE}/che/e2e/report/**" + } + } + +} From b6f4098a3c6f046991829640324b503a732c035e Mon Sep 17 00:00:00 2001 From: Dmytro Nochevnov Date: Wed, 7 Aug 2019 20:12:35 +0300 Subject: [PATCH 02/12] Apply PR review notices Signed-off-by: Dmytro Nochevnov --- e2e/jenkins/crw-ci/k8s/pr-check/Jenkinsfile | 55 +++++++++------------ 1 file changed, 24 insertions(+), 31 deletions(-) diff --git a/e2e/jenkins/crw-ci/k8s/pr-check/Jenkinsfile b/e2e/jenkins/crw-ci/k8s/pr-check/Jenkinsfile index bdc69099ff5..7a7670c2ab1 100644 --- a/e2e/jenkins/crw-ci/k8s/pr-check/Jenkinsfile +++ b/e2e/jenkins/crw-ci/k8s/pr-check/Jenkinsfile @@ -9,13 +9,11 @@ pipeline { artifactNumToKeepStr: '', daysToKeepStr: '60', numToKeepStr: '100')) } - // triggers { cron("@midnight") } - environment { PATH = "/tmp:/qa/tools/opt/apache-maven-3.5.4/bin:$PATH" JENKINS_BUILD = "true" - DEVFILE_URL = "${WORKSPACE}/e2e/files/happy-path/happy-path-workspace.yaml" + DEVFILE_URL = "${WORKSPACE}/che/e2e/files/happy-path/happy-path-workspace.yaml" SUCCESS_THRESHOLD = 5 CHE_IMAGE_REPO = "maxura/che-server" @@ -30,12 +28,9 @@ pipeline { stage("Cleanup") { steps { script() { - sh "env" + cleanWs notFailBuild: true - sh """ - sudo rm -rf ${WORKSPACE}/e2e/report/* - /usr/local/bin/minikube delete - """ + sh "/usr/local/bin/minikube delete" } } } @@ -61,9 +56,8 @@ pipeline { steps { script { sh """ - wget --no-verbose https://github.com/che-incubator/chectl/releases/latest/download/chectl-linux - sudo mv chectl-linux /usr/local/bin/chectl - sudo chmod +x /usr/local/bin/chectl + wget --no-verbose https://github.com/che-incubator/chectl/releases/latest/download/chectl-linux -O ${WORKSPACE}/chectl + sudo chmod +x ${WORKSPACE}/chectl """ } } @@ -97,7 +91,7 @@ pipeline { } } - stage("Push Che artifacts") { + stage("Push Che artifacts to docker.io") { steps { withCredentials([string(credentialsId: 'ed71c034-60bc-4fb1-bfdf-9570209076b5', variable: 'maxura_docker_password')]) { script { @@ -113,15 +107,15 @@ pipeline { } } - stage("Start Che") { + stage("Start Single Che") { steps { script { sh """ - /usr/local/bin/chectl server:start \\ - --k8spodreadytimeout=180000 \\ - -t=${WORKSPACE}/deploy/ \\ - --listr-renderer=verbose \\ - --cheimage=${CHE_IMAGE_REPO}:${CHE_IMAGE_TAG} + ${WORKSPACE}/chectl server:start \\ + --k8spodreadytimeout=180000 \\ + -t=${WORKSPACE}/che/deploy/ \\ + --listr-renderer=verbose \\ + --cheimage=${CHE_IMAGE_REPO}:${CHE_IMAGE_TAG} """ // wait che-server to be available @@ -157,18 +151,15 @@ pipeline { } } - stage("Create ws from devfile") { + stage("Create test workspace") { steps { script { - sh """ - /usr/local/bin/chectl workspace:start --devfile=$DEVFILE_URL - kubectl get configmaps --namespace=che che -o yaml -""" + sh "/usr/local/bin/chectl workspace:start --devfile=$DEVFILE_URL" } } } - stage("Run Happy path tests against Che on Kubernetes") { + stage("Run E2E Happy path tests") { steps { script { // TODO switch to eclipse/che-e2e image @@ -208,22 +199,24 @@ pipeline { script { // it's impossible to use 'when' in the global post block if (currentBuild.currentResult != 'ABORTED') { - // stop_minikube sh """ + kubectl get configmaps --namespace=che che -o yaml || true + /usr/local/bin/minikube stop || true -""" - sh """ -sudo umount \$(mount | grep "kubelet" | awk '{if(NR>0) print \$3}') || true -sudo rm -rf `sudo find /tmp -name 'hostpath-provisioner' 2>/dev/null` || true + sudo umount \$(mount | grep "kubelet" | awk '{if(NR>0) print \$3}') || true + sudo rm -rf `sudo find /tmp -name 'hostpath-provisioner' 2>/dev/null` || true -docker volume rm \$(docker volume ls -q -f dangling=true) || true + docker volume rm \$(docker volume ls -q -f dangling=true) || true """ } + + archiveArtifacts allowEmptyArchive: true, artifacts: "${WORKSPACE}/che/e2e/report/**" } - archiveArtifacts allowEmptyArchive: true, artifacts: "${WORKSPACE}/che/e2e/report/**" + cleanWs notFailBuild: true } + } } From f7b8183a8185767e8e2c7ffdddc4fa3fc3769ee6 Mon Sep 17 00:00:00 2001 From: Dmytro Nochevnov Date: Wed, 7 Aug 2019 20:29:07 +0300 Subject: [PATCH 03/12] Apply PR review notices Signed-off-by: Dmytro Nochevnov --- e2e/jenkins/crw-ci/k8s/pr-check/Jenkinsfile | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/e2e/jenkins/crw-ci/k8s/pr-check/Jenkinsfile b/e2e/jenkins/crw-ci/k8s/pr-check/Jenkinsfile index 7a7670c2ab1..ba5c40f8c3b 100644 --- a/e2e/jenkins/crw-ci/k8s/pr-check/Jenkinsfile +++ b/e2e/jenkins/crw-ci/k8s/pr-check/Jenkinsfile @@ -197,8 +197,6 @@ pipeline { post { always { script { - // it's impossible to use 'when' in the global post block - if (currentBuild.currentResult != 'ABORTED') { sh """ kubectl get configmaps --namespace=che che -o yaml || true @@ -209,11 +207,9 @@ pipeline { docker volume rm \$(docker volume ls -q -f dangling=true) || true """ - } - - archiveArtifacts allowEmptyArchive: true, artifacts: "${WORKSPACE}/che/e2e/report/**" } + archiveArtifacts allowEmptyArchive: true, artifacts: "${WORKSPACE}/che/e2e/report/**" cleanWs notFailBuild: true } From 32826304dbfa36feb8a3bc6a56e8b0e0c31c82f1 Mon Sep 17 00:00:00 2001 From: Dmytro Nochevnov Date: Thu, 8 Aug 2019 01:36:05 +0300 Subject: [PATCH 04/12] Add build timeout Signed-off-by: Dmytro Nochevnov --- e2e/jenkins/crw-ci/k8s/pr-check/Jenkinsfile | 1 + 1 file changed, 1 insertion(+) diff --git a/e2e/jenkins/crw-ci/k8s/pr-check/Jenkinsfile b/e2e/jenkins/crw-ci/k8s/pr-check/Jenkinsfile index ba5c40f8c3b..2feae7fbc66 100644 --- a/e2e/jenkins/crw-ci/k8s/pr-check/Jenkinsfile +++ b/e2e/jenkins/crw-ci/k8s/pr-check/Jenkinsfile @@ -5,6 +5,7 @@ pipeline { options { timestamps() + timeout(time: 40, unit: 'MINUTES') buildDiscarder(logRotator(artifactDaysToKeepStr: '', artifactNumToKeepStr: '', daysToKeepStr: '60', numToKeepStr: '100')) } From 60df5d68e60c7c436895d21599059dcb240f6ab4 Mon Sep 17 00:00:00 2001 From: Dmytro Nochevnov Date: Thu, 8 Aug 2019 09:59:30 +0300 Subject: [PATCH 05/12] Don't clean ws at start Signed-off-by: Dmytro Nochevnov --- e2e/jenkins/crw-ci/k8s/pr-check/Jenkinsfile | 2 -- 1 file changed, 2 deletions(-) diff --git a/e2e/jenkins/crw-ci/k8s/pr-check/Jenkinsfile b/e2e/jenkins/crw-ci/k8s/pr-check/Jenkinsfile index 2feae7fbc66..37881757f7b 100644 --- a/e2e/jenkins/crw-ci/k8s/pr-check/Jenkinsfile +++ b/e2e/jenkins/crw-ci/k8s/pr-check/Jenkinsfile @@ -29,8 +29,6 @@ pipeline { stage("Cleanup") { steps { script() { - cleanWs notFailBuild: true - sh "/usr/local/bin/minikube delete" } } From 5e1a5f15844a2c1200a46ee6f3078c95555e7b91 Mon Sep 17 00:00:00 2001 From: Dmytro Nochevnov Date: Thu, 8 Aug 2019 12:24:00 +0300 Subject: [PATCH 06/12] Rely on Jenkinsfile in PR source Signed-off-by: Dmytro Nochevnov --- e2e/jenkins/crw-ci/k8s/pr-check/Jenkinsfile | 37 ++++++--------------- 1 file changed, 10 insertions(+), 27 deletions(-) diff --git a/e2e/jenkins/crw-ci/k8s/pr-check/Jenkinsfile b/e2e/jenkins/crw-ci/k8s/pr-check/Jenkinsfile index 37881757f7b..fc0a4ee008d 100644 --- a/e2e/jenkins/crw-ci/k8s/pr-check/Jenkinsfile +++ b/e2e/jenkins/crw-ci/k8s/pr-check/Jenkinsfile @@ -14,7 +14,7 @@ pipeline { PATH = "/tmp:/qa/tools/opt/apache-maven-3.5.4/bin:$PATH" JENKINS_BUILD = "true" - DEVFILE_URL = "${WORKSPACE}/che/e2e/files/happy-path/happy-path-workspace.yaml" + DEVFILE_URL = "${WORKSPACE}/e2e/files/happy-path/happy-path-workspace.yaml" SUCCESS_THRESHOLD = 5 CHE_IMAGE_REPO = "maxura/che-server" @@ -22,27 +22,10 @@ pipeline { } stages { - stage("Prepare codebase") { - failFast true - - parallel { - stage("Cleanup") { - steps { - script() { - sh "/usr/local/bin/minikube delete" - } - } - } - - stage("Get sources") { - steps { - checkout([$class : 'GitSCM', - branches : [[name: "*/${ghprbSourceBranch}"]], - doGenerateSubmoduleConfigurations: false, - extensions : [[$class : 'RelativeTargetDirectory', - relativeTargetDir: 'che']], - userRemoteConfigs : [[url: "https://github.com/${ghprbGhRepository}.git"]]]) - } + stage("Cleanup") { + steps { + script() { + sh "/usr/local/bin/minikube delete" } } } @@ -83,7 +66,7 @@ pipeline { stage("Build Che") { steps { script { - sh "mvn clean install -f ${WORKSPACE}/che/pom.xml" + sh "mvn clean install -f ${WORKSPACE}/pom.xml" } } } @@ -95,7 +78,7 @@ pipeline { withCredentials([string(credentialsId: 'ed71c034-60bc-4fb1-bfdf-9570209076b5', variable: 'maxura_docker_password')]) { script { sh """ - ${WORKSPACE}/che/dockerfiles/che/build.sh --organization:maxura --tag:${CHE_IMAGE_TAG} --dockerfile:Dockerfile + ${WORKSPACE}/dockerfiles/che/build.sh --organization:maxura --tag:${CHE_IMAGE_TAG} --dockerfile:Dockerfile docker tag ${CHE_IMAGE_REPO}:${CHE_IMAGE_TAG} docker.io/${CHE_IMAGE_REPO}:${CHE_IMAGE_TAG} docker login -u maxura -p ${maxura_docker_password} docker push docker.io/${CHE_IMAGE_REPO}:${CHE_IMAGE_TAG} @@ -112,7 +95,7 @@ pipeline { sh """ ${WORKSPACE}/chectl server:start \\ --k8spodreadytimeout=180000 \\ - -t=${WORKSPACE}/che/deploy/ \\ + -t=${WORKSPACE}/deploy/ \\ --listr-renderer=verbose \\ --cheimage=${CHE_IMAGE_REPO}:${CHE_IMAGE_TAG} """ @@ -171,7 +154,7 @@ pipeline { // -e TS_SELENIUM_LOAD_PAGE_TIMEOUT=240000 \\ // -e TS_SELENIUM_WORKSPACE_STATUS_POLLING=20000 \\ // -e TS_SELENIUM_BASE_URL=\${CHE_URL} \\ -// -v ${WORKSPACE}/che/e2e:/root/local_tests:Z \\ +// -v ${WORKSPACE}/e2e:/root/local_tests:Z \\ // eclipse/che-e2e:nightly //""" @@ -208,7 +191,7 @@ pipeline { """ } - archiveArtifacts allowEmptyArchive: true, artifacts: "${WORKSPACE}/che/e2e/report/**" + archiveArtifacts allowEmptyArchive: true, artifacts: "${WORKSPACE}/e2e/report/**" cleanWs notFailBuild: true } From 0a44fd3a05c393b819070d32ac5a03d299b4ae2f Mon Sep 17 00:00:00 2001 From: Dmytro Nochevnov Date: Thu, 8 Aug 2019 14:48:12 +0300 Subject: [PATCH 07/12] Fix path in Jenkinsfile Signed-off-by: Dmytro Nochevnov --- e2e/jenkins/crw-ci/k8s/pr-check/Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/e2e/jenkins/crw-ci/k8s/pr-check/Jenkinsfile b/e2e/jenkins/crw-ci/k8s/pr-check/Jenkinsfile index fc0a4ee008d..1edaab7896c 100644 --- a/e2e/jenkins/crw-ci/k8s/pr-check/Jenkinsfile +++ b/e2e/jenkins/crw-ci/k8s/pr-check/Jenkinsfile @@ -167,7 +167,7 @@ pipeline { -e TS_SELENIUM_LOAD_PAGE_TIMEOUT=240000 \\ -e TS_SELENIUM_BASE_URL=\${CHE_URL} \\ -e TS_SELENIUM_WORKSPACE_STATUS_POLLING=20000 \\ - -w /home/che/e2e \\ + -w /home/e2e \\ -v $WORKSPACE:/home:Z \\ cypress/browsers:node8.9.3-chrome73 bash -c "npm install && npm run test-happy-path" """ From 86f859c3afece760db8d0411d1cccd99951c8783 Mon Sep 17 00:00:00 2001 From: Dmytro Nochevnov Date: Thu, 8 Aug 2019 14:52:08 +0300 Subject: [PATCH 08/12] Clear jenkins workspace immediately at post action Signed-off-by: Dmytro Nochevnov --- e2e/jenkins/crw-ci/k8s/pr-check/Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/e2e/jenkins/crw-ci/k8s/pr-check/Jenkinsfile b/e2e/jenkins/crw-ci/k8s/pr-check/Jenkinsfile index 1edaab7896c..11156604623 100644 --- a/e2e/jenkins/crw-ci/k8s/pr-check/Jenkinsfile +++ b/e2e/jenkins/crw-ci/k8s/pr-check/Jenkinsfile @@ -192,7 +192,7 @@ pipeline { } archiveArtifacts allowEmptyArchive: true, artifacts: "${WORKSPACE}/e2e/report/**" - cleanWs notFailBuild: true + cleanWs notFailBuild: true, disableDeferredWipeout: true, deleteDirs: true } } From 5f0e0cd19050dd314f4de589c72c2b7cc35edfad Mon Sep 17 00:00:00 2001 From: Dmytro Nochevnov Date: Thu, 8 Aug 2019 16:28:02 +0300 Subject: [PATCH 09/12] Fix formatting of multiline sh command Signed-off-by: Dmytro Nochevnov --- e2e/jenkins/crw-ci/k8s/pr-check/Jenkinsfile | 172 ++++++++++---------- 1 file changed, 87 insertions(+), 85 deletions(-) diff --git a/e2e/jenkins/crw-ci/k8s/pr-check/Jenkinsfile b/e2e/jenkins/crw-ci/k8s/pr-check/Jenkinsfile index 11156604623..6bc2e44dfde 100644 --- a/e2e/jenkins/crw-ci/k8s/pr-check/Jenkinsfile +++ b/e2e/jenkins/crw-ci/k8s/pr-check/Jenkinsfile @@ -38,9 +38,11 @@ pipeline { steps { script { sh """ - wget --no-verbose https://github.com/che-incubator/chectl/releases/latest/download/chectl-linux -O ${WORKSPACE}/chectl - sudo chmod +x ${WORKSPACE}/chectl -""" + wget --no-verbose https://github.com/che-incubator/chectl/releases/latest/download/chectl-linux \\ + -O ${WORKSPACE}/chectl + + sudo chmod +x ${WORKSPACE}/chectl + """ } } } @@ -49,16 +51,16 @@ pipeline { steps { script { sh """ - /usr/local/bin/minikube start \\ - --vm-driver=none \\ - --cpus 4 \\ - --memory 12288 \\ - --logtostderr - - sudo chmod g+r -R /home/codenvy/.minikube - sudo chmod g+r -R /home/codenvy/.kube - sudo chmod g+r /var/lib/kubeadm.yaml -""" + /usr/local/bin/minikube start \\ + --vm-driver=none \\ + --cpus 4 \\ + --memory 12288 \\ + --logtostderr + + sudo chmod g+r -R /home/codenvy/.minikube + sudo chmod g+r -R /home/codenvy/.kube + sudo chmod g+r /var/lib/kubeadm.yaml + """ } } } @@ -78,11 +80,11 @@ pipeline { withCredentials([string(credentialsId: 'ed71c034-60bc-4fb1-bfdf-9570209076b5', variable: 'maxura_docker_password')]) { script { sh """ - ${WORKSPACE}/dockerfiles/che/build.sh --organization:maxura --tag:${CHE_IMAGE_TAG} --dockerfile:Dockerfile - docker tag ${CHE_IMAGE_REPO}:${CHE_IMAGE_TAG} docker.io/${CHE_IMAGE_REPO}:${CHE_IMAGE_TAG} - docker login -u maxura -p ${maxura_docker_password} - docker push docker.io/${CHE_IMAGE_REPO}:${CHE_IMAGE_TAG} -""" + ${WORKSPACE}/dockerfiles/che/build.sh --organization:maxura --tag:${CHE_IMAGE_TAG} --dockerfile:Dockerfile + docker tag ${CHE_IMAGE_REPO}:${CHE_IMAGE_TAG} docker.io/${CHE_IMAGE_REPO}:${CHE_IMAGE_TAG} + docker login -u maxura -p ${maxura_docker_password} + docker push docker.io/${CHE_IMAGE_REPO}:${CHE_IMAGE_TAG} + """ } } @@ -93,42 +95,42 @@ pipeline { steps { script { sh """ - ${WORKSPACE}/chectl server:start \\ - --k8spodreadytimeout=180000 \\ - -t=${WORKSPACE}/deploy/ \\ - --listr-renderer=verbose \\ - --cheimage=${CHE_IMAGE_REPO}:${CHE_IMAGE_TAG} -""" + ${WORKSPACE}/chectl server:start \\ + --k8spodreadytimeout=180000 \\ + -t=${WORKSPACE}/deploy/ \\ + --listr-renderer=verbose \\ + --cheimage=${CHE_IMAGE_REPO}:${CHE_IMAGE_TAG} + """ // wait che-server to be available sh """ - CHE_URL=\$(kubectl get ingress che-ingress -n=che -o=jsonpath={'.spec.rules[0].host'}) - - COUNTER=0; - SUCCESS_RATE_COUNTER=0; - while true; do - if [ \$COUNTER -gt 180 ]; then - echo "Unable to get stable route. Exiting" - exit 1 - fi - - ((COUNTER+=1)) - - - STATUS_CODE=\$(curl -sL -w "%{http_code}" -I \${CHE_URL} -o /dev/null; true) || true # added true to not fail the script completely. - - echo "Try \${COUNTER}. Status code: \${STATUS_CODE}" - if [ "\$STATUS_CODE" == "200" ]; then - ((SUCCESS_RATE_COUNTER+=1)) - fi - sleep 1; - - if [ \$SUCCESS_RATE_COUNTER == \$SUCCESS_THRESHOLD ]; then - echo "Route is stable enough. Continuing running tests" - break - fi - done -""" + CHE_URL=\$(kubectl get ingress che-ingress -n=che -o=jsonpath={'.spec.rules[0].host'}) + + COUNTER=0; + SUCCESS_RATE_COUNTER=0; + while true; do + if [ \$COUNTER -gt 180 ]; then + echo "Unable to get stable route. Exiting" + exit 1 + fi + + ((COUNTER+=1)) + + + STATUS_CODE=\$(curl -sL -w "%{http_code}" -I \${CHE_URL} -o /dev/null; true) || true + + echo "Try \${COUNTER}. Status code: \${STATUS_CODE}" + if [ "\$STATUS_CODE" == "200" ]; then + ((SUCCESS_RATE_COUNTER+=1)) + fi + sleep 1; + + if [ \$SUCCESS_RATE_COUNTER == \$SUCCESS_THRESHOLD ]; then + echo "Route is stable enough. Continuing running tests" + break + fi + done + """ } } } @@ -146,31 +148,31 @@ pipeline { script { // TODO switch to eclipse/che-e2e image // sh """ -// CHE_HOST=\$(kubectl get ingress che-ingress -n=che -o=jsonpath={'.spec.rules[0].host'}) -// CHE_URL=http://\${CHE_HOST} -// docker run --shm-size=256m --net=host --ipc=host \\ -// -e TS_SELENIUM_HEADLESS='true' \\ -// -e TS_SELENIUM_DEFAULT_TIMEOUT=300000 \\ -// -e TS_SELENIUM_LOAD_PAGE_TIMEOUT=240000 \\ -// -e TS_SELENIUM_WORKSPACE_STATUS_POLLING=20000 \\ -// -e TS_SELENIUM_BASE_URL=\${CHE_URL} \\ -// -v ${WORKSPACE}/e2e:/root/local_tests:Z \\ -// eclipse/che-e2e:nightly -//""" - - sh """ - CHE_HOST=\$(kubectl get ingress che-ingress -n=che -o=jsonpath={'.spec.rules[0].host'}) - CHE_URL=http://\${CHE_HOST} - docker run --net=host --ipc=host \\ - -e TS_SELENIUM_HEADLESS='true' \\ - -e TS_SELENIUM_DEFAULT_TIMEOUT=300000 \\ - -e TS_SELENIUM_LOAD_PAGE_TIMEOUT=240000 \\ - -e TS_SELENIUM_BASE_URL=\${CHE_URL} \\ - -e TS_SELENIUM_WORKSPACE_STATUS_POLLING=20000 \\ - -w /home/e2e \\ - -v $WORKSPACE:/home:Z \\ - cypress/browsers:node8.9.3-chrome73 bash -c "npm install && npm run test-happy-path" -""" +// CHE_HOST=\$(kubectl get ingress che-ingress -n=che -o=jsonpath={'.spec.rules[0].host'}) +// CHE_URL=http://\${CHE_HOST} +// docker run --shm-size=256m --net=host --ipc=host \\ +// -e TS_SELENIUM_HEADLESS='true' \\ +// -e TS_SELENIUM_DEFAULT_TIMEOUT=300000 \\ +// -e TS_SELENIUM_LOAD_PAGE_TIMEOUT=240000 \\ +// -e TS_SELENIUM_WORKSPACE_STATUS_POLLING=20000 \\ +// -e TS_SELENIUM_BASE_URL=\${CHE_URL} \\ +// -v ${WORKSPACE}/e2e:/root/local_tests:Z \\ +// eclipse/che-e2e:nightly +// """ + + sh """ + CHE_HOST=\$(kubectl get ingress che-ingress -n=che -o=jsonpath={'.spec.rules[0].host'}) + CHE_URL=http://\${CHE_HOST} + docker run --net=host --ipc=host \\ + -e TS_SELENIUM_HEADLESS='true' \\ + -e TS_SELENIUM_DEFAULT_TIMEOUT=300000 \\ + -e TS_SELENIUM_LOAD_PAGE_TIMEOUT=240000 \\ + -e TS_SELENIUM_BASE_URL=\${CHE_URL} \\ + -e TS_SELENIUM_WORKSPACE_STATUS_POLLING=20000 \\ + -w /home/e2e \\ + -v $WORKSPACE:/home:Z \\ + cypress/browsers:node8.9.3-chrome73 bash -c "npm install && npm run test-happy-path" + """ } } } @@ -180,15 +182,15 @@ pipeline { always { script { sh """ - kubectl get configmaps --namespace=che che -o yaml || true - - /usr/local/bin/minikube stop || true - - sudo umount \$(mount | grep "kubelet" | awk '{if(NR>0) print \$3}') || true - sudo rm -rf `sudo find /tmp -name 'hostpath-provisioner' 2>/dev/null` || true - - docker volume rm \$(docker volume ls -q -f dangling=true) || true -""" + kubectl get configmaps --namespace=che che -o yaml || true + + /usr/local/bin/minikube stop || true + + sudo umount \$(mount | grep "kubelet" | awk '{if(NR>0) print \$3}') || true + sudo rm -rf `sudo find /tmp -name 'hostpath-provisioner' 2>/dev/null` || true + + docker volume rm \$(docker volume ls -q -f dangling=true) || true + """ } archiveArtifacts allowEmptyArchive: true, artifacts: "${WORKSPACE}/e2e/report/**" From 91d6826f19c652f7fa1d9e62a9ae5629d87ecb18 Mon Sep 17 00:00:00 2001 From: Dmytro Nochevnov Date: Thu, 8 Aug 2019 16:33:08 +0300 Subject: [PATCH 10/12] Fix chectl path Signed-off-by: Dmytro Nochevnov --- e2e/jenkins/crw-ci/k8s/pr-check/Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/e2e/jenkins/crw-ci/k8s/pr-check/Jenkinsfile b/e2e/jenkins/crw-ci/k8s/pr-check/Jenkinsfile index 6bc2e44dfde..d020ae9c7a6 100644 --- a/e2e/jenkins/crw-ci/k8s/pr-check/Jenkinsfile +++ b/e2e/jenkins/crw-ci/k8s/pr-check/Jenkinsfile @@ -138,7 +138,7 @@ pipeline { stage("Create test workspace") { steps { script { - sh "/usr/local/bin/chectl workspace:start --devfile=$DEVFILE_URL" + sh "${WORKSPACE}/chectl workspace:start --devfile=$DEVFILE_URL" } } } From de6322d04f5734de5c645f120b14be9706938446 Mon Sep 17 00:00:00 2001 From: Dmytro Nochevnov Date: Fri, 9 Aug 2019 01:12:15 +0300 Subject: [PATCH 11/12] Fix cleanup, fix arhiving artifacts Signed-off-by: Dmytro Nochevnov --- e2e/jenkins/crw-ci/k8s/pr-check/Jenkinsfile | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/e2e/jenkins/crw-ci/k8s/pr-check/Jenkinsfile b/e2e/jenkins/crw-ci/k8s/pr-check/Jenkinsfile index d020ae9c7a6..25b7c3f17fb 100644 --- a/e2e/jenkins/crw-ci/k8s/pr-check/Jenkinsfile +++ b/e2e/jenkins/crw-ci/k8s/pr-check/Jenkinsfile @@ -180,8 +180,10 @@ pipeline { post { always { + archiveArtifacts allowEmptyArchive: true, artifacts: "e2e/report/**" + script { - sh """ + sh """ kubectl get configmaps --namespace=che che -o yaml || true /usr/local/bin/minikube stop || true @@ -191,9 +193,10 @@ pipeline { docker volume rm \$(docker volume ls -q -f dangling=true) || true """ + + sh "sudo rm -rf ${WORKSPACE}/e2e" } - archiveArtifacts allowEmptyArchive: true, artifacts: "${WORKSPACE}/e2e/report/**" cleanWs notFailBuild: true, disableDeferredWipeout: true, deleteDirs: true } From 30a70f5f15ccab7c04da7debaf5e2ef6cc22a81e Mon Sep 17 00:00:00 2001 From: Dmytro Nochevnov Date: Fri, 9 Aug 2019 01:15:54 +0300 Subject: [PATCH 12/12] Move to crw-ci/pr-check/k8s/Jenkinsfile Signed-off-by: Dmytro Nochevnov --- e2e/jenkins/crw-ci/{k8s/pr-check => pr-check/k8s}/Jenkinsfile | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename e2e/jenkins/crw-ci/{k8s/pr-check => pr-check/k8s}/Jenkinsfile (100%) diff --git a/e2e/jenkins/crw-ci/k8s/pr-check/Jenkinsfile b/e2e/jenkins/crw-ci/pr-check/k8s/Jenkinsfile similarity index 100% rename from e2e/jenkins/crw-ci/k8s/pr-check/Jenkinsfile rename to e2e/jenkins/crw-ci/pr-check/k8s/Jenkinsfile