Update stage1 and stage3 to run robot tests with tag 56/10656/2
authorgarciadeblas <gerardo.garciadeblas@telefonica.com>
Fri, 16 Apr 2021 13:35:36 +0000 (15:35 +0200)
committerbeierlm <mark.beierl@canonical.com>
Tue, 20 Apr 2021 13:52:55 +0000 (15:52 +0200)
This reverts commit b311476d34bf9d15bdcbf35b0d183779d2b3f0c9.

This commit updates stage1 and stage3 to allow running robot
tests in stage3 by default for every commit.

The commit removes param DO_STAGE_4 since it is confusing. Only
params DO_ROBOT and ROBOT_TAG_NAME will be used. If DO_ROBOT is set
to true, robot tests will be run in stage3 for all tests containing
the tag indicated by ROBOT_TAG_NAME. The param ROBOT_TAG_NAME replaces
the previous param TEST_NAME.

MDG stage1 can specify params DO_ROBOT and ROBOT_TAG_NAME. If
specified, they will be used. Otherwise, the default for stage3 will
apply (DO_ROBOT=true, ROBOT_TAG_NAME=sanity).

Daily job, which will run stage1, can also specify params DO_ROBOT
and ROBOT_TAG_NAME. In principle, they will be set as follows:
DO_ROBOT=true, ROBOT_TAG_NAME=daily.

Stage1 job, in case of failure, will send an e-mail to OSM_MDL
mailing list reporting the failure. The mail will only be sent
if the name of the job starts with "daily-stage_4".

Change-Id: Ibe37fb588fc48297f5fea6e654f9ad64c906d9a6
Signed-off-by: garciadeblas <gerardo.garciadeblas@telefonica.com>
jenkins/ci-pipelines/ci_stage_1.groovy
jenkins/ci-pipelines/ci_stage_3.groovy

index 0f530c5..306b9fd 100644 (file)
@@ -59,12 +59,6 @@ node("${params.NODE}") {
             println("No gerrit event found")
         }
 
-        do_stage_4 = false
-        if (params.DO_STAGE_4)
-        {
-            do_stage_4 = params.DO_STAGE_4
-        }
-
         // pipeline running from gerrit trigger.
         // kickoff the downstream multibranch pipeline
         def downstream_params = [
@@ -75,10 +69,16 @@ node("${params.NODE}") {
             string(name: 'PROJECT_URL_PREFIX', value: params.PROJECT_URL_PREFIX),
             string(name: 'DOCKER_TAG', value: params.DOCKER_TAG),
             booleanParam(name: 'TEST_INSTALL', value: params.TEST_INSTALL),
-            booleanParam(name: 'DO_ROBOT', value: params.DO_ROBOT),
-            booleanParam(name: 'DO_STAGE_4', value: do_stage_4),
         ]
-     
+        if ( params.DO_ROBOT )
+        {
+            downstream_params.add(booleanParam(name: 'DO_ROBOT', value: params.DO_ROBOT))
+        }
+        if ( params.ROBOT_TAG_NAME )
+        {
+            downstream_params.add(booleanParam(name: 'ROBOT_TAG_NAME', value: params.ROBOT_TAG_NAME))
+        }
+
         if ( params.STAGE )
         {
             // go directly to stage 3 (osm system)
@@ -101,8 +101,8 @@ node("${params.NODE}") {
                 project = stage_3_merge_result.getProjectName()
                 build = stage_3_merge_result.getNumber()
                 // Jayant if the build fails the below error will cause the pipeline to terminate. 
-                           // error("${project} build ${build} failed")
-                               currentBuild.result = stage_3_merge_result.getResult()
+                // error("${project} build ${build} failed")
+                currentBuild.result = stage_3_merge_result.getResult()
             }
        }
         catch(caughtError) {
@@ -111,7 +111,7 @@ node("${params.NODE}") {
         }
         finally {
             try {
-                if((currentBuild.result != 'SUCCESS') && (env.JOB_NAME == 'daily-stage_4')){
+                if ((currentBuild.result != 'SUCCESS') && (env.JOB_NAME.startsWith('daily-stage_4'))){
                     emailext (
                         subject: "[OSM-Jenkins] Job: ${env.JOB_NAME} Build: ${env.BUILD_NUMBER} Result: ${currentBuild.result}",
                         body: """ Check console output at "${env.BUILD_URL}"  """,
index f5fa75d..a62b8c9 100644 (file)
@@ -35,15 +35,13 @@ properties([
         booleanParam(defaultValue: false, description: '', name: 'SAVE_CONTAINER_ON_FAIL'),
         booleanParam(defaultValue: false, description: '', name: 'SAVE_CONTAINER_ON_PASS'),
         booleanParam(defaultValue: true, description: '', name: 'SAVE_ARTIFACTS_ON_SMOKE_SUCCESS'),
-        booleanParam(defaultValue: true, description: '', name: 'DO_STAGE_4'),
         booleanParam(defaultValue: true, description: '',  name: 'DO_BUILD'),
         booleanParam(defaultValue: true, description: '', name: 'DO_INSTALL'),
-        booleanParam(defaultValue: true, description: '', name: 'DO_SMOKE'),
         booleanParam(defaultValue: true, description: '', name: 'DO_DOCKERPUSH'),
         booleanParam(defaultValue: false, description: '', name: 'SAVE_ARTIFACTS_OVERRIDE'),
         string(defaultValue: '/home/jenkins/hive/openstack-etsi.rc', description: '', name: 'HIVE_VIM_1'),
-        booleanParam(defaultValue: false, description: '', name: 'DO_ROBOT'),
-        string(defaultValue: 'daily', description: 'sanity/regression/daily are the common options', name: 'TEST_NAME'),
+        booleanParam(defaultValue: true, description: '', name: 'DO_ROBOT'),
+        string(defaultValue: 'sanity', description: 'sanity/regression/daily are the common options', name: 'ROBOT_TAG_NAME'),
         string(defaultValue: '/home/jenkins/hive/robot-systest.cfg', description: '', name: 'ROBOT_VIM'),
         string(defaultValue: '/home/jenkins/hive/kubeconfig.yaml', description: '', name: 'KUBECONFIG'),
         string(defaultValue: '/home/jenkins/hive/clouds.yaml', description: '', name: 'CLOUDS'),
@@ -475,56 +473,52 @@ node("${params.NODE}") {
                         osmHostname = IP_ADDRESS
                     }
                 } // stage("Install")
-            } // if ( params.DO_INSTALL )
-
 ///////////////////////////////////////////////////////////////////////////////////////
 // Health check of installed OSM in remote vm
 ///////////////////////////////////////////////////////////////////////////////////////
-            if ( params.DO_SMOKE ) {
                 stage("OSM Health") {
                     stackName = "osm"
                     sshCommand remote: remote, command: """
                         /usr/share/osm-devops/installers/osm_health.sh -k -s ${stackName}
                     """
-                }
-            }
+                } // stage("OSM Health")
+            } // if ( params.DO_INSTALL )
+
 
 ///////////////////////////////////////////////////////////////////////////////////////
 // Execute Robot tests
 ///////////////////////////////////////////////////////////////////////////////////////
             stage_archive = false
-            if ( params.DO_STAGE_4 ) {
+            if ( params.DO_ROBOT ) {
                 try {
                     stage("System Integration Test") {
-                        if ( params.DO_ROBOT ) {
-                            if( useCharmedInstaller ) {
-                                tempdir = sh(returnStdout: true, script: "mktemp -d").trim()
-                                sh(script: "touch ${tempdir}/hosts")
-                                hostfile="${tempdir}/hosts"
-                                sh """cat << EOF > ${hostfile}
+                        if ( useCharmedInstaller ) {
+                            tempdir = sh(returnStdout: true, script: "mktemp -d").trim()
+                            sh(script: "touch ${tempdir}/hosts")
+                            hostfile="${tempdir}/hosts"
+                            sh """cat << EOF > ${hostfile}
 127.0.0.1           localhost
 ${remote.host}      prometheus.${remote.host}.xip.io nbi.${remote.host}.xip.io
 EOF"""
-                            } else {
-                                hostfile=null
-                            }
-
-                            jujuPassword=sshCommand remote: remote, command: """
-                                echo `juju gui 2>&1 | grep password | cut -d: -f2`
-                            """
-
-                            run_robot_systest(
-                                container_name,
-                                params.TEST_NAME,
-                                osmHostname,
-                                prometheusHostname,
-                                prometheusPort,
-                                params.ROBOT_VIM,
-                                params.KUBECONFIG,
-                                params.CLOUDS,
-                                hostfile,
-                                jujuPassword)
+                        } else {
+                            hostfile=null
                         }
+
+                        jujuPassword=sshCommand remote: remote, command: """
+                            echo `juju gui 2>&1 | grep password | cut -d: -f2`
+                        """
+
+                        run_robot_systest(
+                            container_name,
+                            params.ROBOT_TAG_NAME,
+                            osmHostname,
+                            prometheusHostname,
+                            prometheusPort,
+                            params.ROBOT_VIM,
+                            params.KUBECONFIG,
+                            params.CLOUDS,
+                            hostfile,
+                            jujuPassword)
                     } // stage("System Integration Test")
                 } finally {
                     stage("Archive Container Logs") {
@@ -540,7 +534,7 @@ EOF"""
                         }
                     }
                 }
-            } // if ( params.DO_STAGE_4 )
+            } // if ( params.DO_ROBOT )
 
             if ( params.SAVE_ARTIFACTS_OVERRIDE || stage_archive ) {
                 stage("Archive") {