You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hop.apache.org by ha...@apache.org on 2020/12/06 15:25:59 UTC

[incubator-hop] branch master updated: HOP-2122: add integration tests to Hop (#440)

This is an automated email from the ASF dual-hosted git repository.

hansva pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-hop.git


The following commit(s) were added to refs/heads/master by this push:
     new b5b2710  HOP-2122: add integration tests to Hop (#440)
b5b2710 is described below

commit b5b27101a16d65aecb3c9002b9fd18f3ef87062a
Author: Hans Van Akelyen <ha...@gmail.com>
AuthorDate: Sun Dec 6 16:25:53 2020 +0100

    HOP-2122: add integration tests to Hop (#440)
---
 .gitignore            |  2 +-
 Dockerfile.unit-tests | 24 +++++++++++++-------
 Jenkinsfile           |  8 -------
 Jenkinsfile.daily     | 63 +++++++++++++++++++++++++++++++++------------------
 4 files changed, 58 insertions(+), 39 deletions(-)

diff --git a/.gitignore b/.gitignore
index 4acc473..82131e3 100644
--- a/.gitignore
+++ b/.gitignore
@@ -27,4 +27,4 @@ Workflow Run Configuration/
 Hop Server/
 Relational Database Connection/
 \.temp-beam-*/
-
+integration-tests/surefire-reports
\ No newline at end of file
diff --git a/Dockerfile.unit-tests b/Dockerfile.unit-tests
index 1704359..2cb1f1a 100644
--- a/Dockerfile.unit-tests
+++ b/Dockerfile.unit-tests
@@ -8,6 +8,11 @@ ENV BRANCH_NAME=$BRANCH_NAME
 ENV DEPLOYMENT_PATH=/opt
 # volume mount point
 ENV VOLUME_MOUNT_POINT=/files
+#Jenkins user an group
+ARG JENKINS_USER=hop
+ARG JENKINS_GROUP=hop
+ARG JENKINS_UID=1000
+ARG JENKINS_GID=1000
 
 # any JRE settings you want to pass on
 # The “-XX:+AggressiveHeap” tells the container to use all memory assigned to the container. 
@@ -21,22 +26,25 @@ RUN apk update \
   && apk add --no-cache bash curl procps \ 
   && rm -rf /var/cache/apk/* \
   && mkdir ${VOLUME_MOUNT_POINT} \
-  && adduser -D -s /bin/bash -h /home/hop hop \
-  && chown hop:hop ${DEPLOYMENT_PATH} \
-  && chown hop:hop ${VOLUME_MOUNT_POINT}
+  && addgroup -g ${JENKINS_GID} ${JENKINS_GROUP} \
+  && adduser -D -s /bin/bash -h /home/${JENKINS_USER} --uid ${JENKINS_UID} --ingroup ${JENKINS_GROUP} ${JENKINS_USER} \
+  && chown ${JENKINS_USER}:${JENKINS_GROUP} ${DEPLOYMENT_PATH} \
+  && chown ${JENKINS_USER}:${JENKINS_GROUP} ${VOLUME_MOUNT_POINT}
 
 # copy the hop package from the local resources folder to the container image directory
-COPY --chown=hop:hop ./assemblies/client/target/hop-* ${DEPLOYMENT_PATH}/hop.zip
+COPY --chown=${JENKINS_USER}:${JENKINS_GROUP} ./assemblies/client/target/hop-* ${DEPLOYMENT_PATH}/hop.zip
 
 RUN unzip ${DEPLOYMENT_PATH}/hop.zip -d ${DEPLOYMENT_PATH} \
   && rm ${DEPLOYMENT_PATH}/hop.zip \
-  && chown -R hop:hop ${DEPLOYMENT_PATH}/hop \
+  && chown -R ${JENKINS_USER}:${JENKINS_GROUP} ${DEPLOYMENT_PATH}/hop \
   && chmod 700 ${DEPLOYMENT_PATH}/hop/*.sh
 
 # make volume available so that hop pipeline and workflow files can be provided easily
 VOLUME ["/files"]
-USER hop
+USER ${JENKINS_USER}
 ENV PATH=$PATH:${DEPLOYMENT_PATH}/hop
-WORKDIR /home/hop
+#SET HOP_JAVA_HOME
+ENV HOP_JAVA_HOME /usr/lib/jvm/java-1.8-openjdk
+WORKDIR /home/${JENKINS_USER}
 # CMD ["/bin/bash"]
-ENTRYPOINT ["/bin/bash", "/files/scripts/run-tests.sh"]
\ No newline at end of file
+ENTRYPOINT []
\ No newline at end of file
diff --git a/Jenkinsfile b/Jenkinsfile
index 9067b1c..5bf2ce5 100644
--- a/Jenkinsfile
+++ b/Jenkinsfile
@@ -98,14 +98,6 @@ pipeline {
                 }
             }
         }
-        stage('Code Quality') {
-            steps {
-                echo 'Checking Code Quality on SonarCloud'
-                withCredentials([string(credentialsId: 'sonarcloud-key-apache-hop', variable: 'SONAR_TOKEN')]) {
-                    sh 'mvn sonar:sonar -Dsonar.host.url=https://sonarcloud.io -Dsonar.organization=apache -Dsonar.projectKey=apache_incubator-hop -Dsonar.branch.name=${BRANCH_NAME} -Dsonar.login=${SONAR_TOKEN}'
-                }
-            }
-        }
         stage('Deploy'){
             when {
                 branch 'master'
diff --git a/Jenkinsfile.daily b/Jenkinsfile.daily
index cce1854..8abcdf7 100644
--- a/Jenkinsfile.daily
+++ b/Jenkinsfile.daily
@@ -29,6 +29,10 @@ pipeline {
         label AGENT_LABEL
     }
 
+    triggers {
+        cron('H H(2-7) * * *')
+    }
+
     tools {
         jdk JDK_NAME
         maven MAVEN_NAME
@@ -38,6 +42,10 @@ pipeline {
         MAVEN_SKIP_RC = true
         dockerImage = ''
         imagename = 'hop'
+        jenkins_user = "${USER}"
+        jenkins_uid = sh(script: "id -u ${USER}", returnStdout: true).trim()
+        jenkins_gid = sh(script: "id -g ${USER}", returnStdout: true).trim()
+        jenkins_group = sh(script: "id -gn ${USER}", returnStdout: true).trim()
     }
 
     options {
@@ -56,6 +64,10 @@ pipeline {
               steps {
                   echo 'Building Branch: ' + env.BRANCH_NAME
                   echo 'Using PATH = ' + env.PATH
+                  echo 'Using Jenkins user = ' + jenkins_user
+                  echo 'Using Jenkins userid = ' + jenkins_uid
+                  echo 'Using Jenkins group = ' + jenkins_group
+                  echo 'Using Jenkins groupid = ' + jenkins_gid
               }
          }
          stage('Cleanup') {
@@ -72,47 +84,54 @@ pipeline {
         }
         stage('Build & Test') {
             when {
-                branch 'integration-tests'
+                branch 'master'
             }
             steps {
                 echo 'Build & Test'
                 sh "mvn $MAVEN_PARAMS clean install"
             }
         }
-        // stage('Code Quality') {
-        //     steps {
-        //         echo 'Checking Code Quality on SonarCloud'
-        //         withCredentials([string(credentialsId: 'sonarcloud-key-apache-hop', variable: 'SONAR_TOKEN')]) {
-        //             sh 'mvn sonar:sonar -Dsonar.host.url=https://sonarcloud.io -Dsonar.organization=apache -Dsonar.projectKey=apache_incubator-hop -Dsonar.branch.name=${BRANCH_NAME} -Dsonar.login=${SONAR_TOKEN}'
-        //         }
-        //     }
-        // }
-        stage('Create Docker image'){
+        stage('Code Quality') {
+            tools{
+                jdk 'jdk_11_latest'
+            }
+            when {
+                branch 'master'
+            }
             steps {
-                script {
-                    dockerImage = docker.build -f 'Dockerfile.unit-tests' imagename
+                echo 'Checking Code Quality on SonarCloud'
+                withCredentials([string(credentialsId: 'sonarcloud-key-apache-hop', variable: 'SONAR_TOKEN')]) {
+                    sh 'mvn sonar:sonar -Dsonar.host.url=https://sonarcloud.io -Dsonar.organization=apache -Dsonar.projectKey=apache_incubator-hop -Dsonar.branch.name=${BRANCH_NAME} -Dsonar.login=${SONAR_TOKEN}'
                 }
             }
         }
-        stage('Run Integration Tests'){
+        stage('Create Docker image & Run Tests'){
+            when {
+                branch 'master'
+            }
             steps {
                 script {
-                    echo 'Run tests'
+                    dockerImage = docker.build(imagename, "--build-arg JENKINS_USER=${jenkins_user} --build-arg JENKINS_UID=${jenkins_uid} --build-arg JENKINS_GROUP=${jenkins_group} --build-arg JENKINS_GID=${jenkins_gid} -f Dockerfile.unit-tests .")
+                    dockerImage.inside("-v $WORKSPACE/integration-tests:/files"){
+                        echo 'Run tests'
+                        sh 'cd /files/scripts && ./run-tests.sh'
+                    }
                 }
-            }            
+            }
             post {
                 always {
-                    junit(testResults: '**/surefire-reports/*.xml', allowEmptyResults: true)
-                    junit(testResults: '**/failsafe-reports/*.xml', allowEmptyResults: true)
+                    junit(testResults: 'integration-tests/**/surefire-reports/*.xml', allowEmptyResults: true)
                 }
             }
         }
         stage('Remove docker image'){
-            sh "docker rmi $iamgename:$BUILD_NUMBER"
-            sh "docker rmi $iamgename:latest"
-        }
-        
-
+            when {
+                branch 'master'
+            }
+            steps {
+                sh "docker rmi $imagename:latest"
+            }
+        }       
     }
     post {
         always {