Do not throw error if robot test result is unstable
[osm/devops.git] / jenkins / ci-pipelines / ci_stage_3.groovy
index d42c6dd..98b0020 100644 (file)
@@ -41,11 +41,13 @@ properties([
         booleanParam(defaultValue: false, description: '', name: 'SAVE_ARTIFACTS_OVERRIDE'),
         string(defaultValue: '/home/jenkins/hive/openstack-etsi.rc', description: '', name: 'HIVE_VIM_1'),
         booleanParam(defaultValue: true, description: '', name: 'DO_ROBOT'),
-        string(defaultValue: 'sanity', description: 'sanity/regression/daily are the common options', name: 'ROBOT_TAG'),
+        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'),
         string(defaultValue: 'Default', description: '', name: 'INSTALLER'),
+        string(defaultValue: '100.0', description: '% passed Robot tests to mark the build as passed', name: 'ROBOT_PASS_THRESHOLD'),
+        string(defaultValue: '80.0', description: '% passed Robot tests to mark the build as unstable (if lower, it will be failed)', name: 'ROBOT_UNSTABLE_THRESHOLD'),
     ])
 ])
 
@@ -53,7 +55,7 @@ properties([
 ////////////////////////////////////////////////////////////////////////////////////////
 // Helper Functions
 ////////////////////////////////////////////////////////////////////////////////////////
-def run_robot_systest(tagName,testName,osmHostname,prometheusHostname,prometheus_port=null,envfile=null,kubeconfig=null,clouds=null,hostfile=null,jujuPassword=null) {
+def run_robot_systest(tagName,testName,osmHostname,prometheusHostname,prometheus_port=null,envfile=null,kubeconfig=null,clouds=null,hostfile=null,jujuPassword=null,pass_th='0.0',unstable_th='0.0') {
     tempdir = sh(returnStdout: true, script: "mktemp -d").trim()
     if ( !envfile )
     {
@@ -87,8 +89,8 @@ def run_robot_systest(tagName,testName,osmHostname,prometheusHostname,prometheus
             disableArchiveOutput : false,
             reportFileName : "report.html",
             logFileName : "log.html",
-            passThreshold : 0,
-            unstableThreshold: 0,
+            passThreshold : pass_th,
+            unstableThreshold: unstable_th,
             otherFiles : "*.png",
         ])
     }
@@ -221,7 +223,7 @@ node("${params.NODE}") {
                     }
 
                     parallelSteps = [:]
-                    def list = ["RO", "openvim", "osmclient", "IM", "devops", "MON", "N2VC", "NBI", "common", "LCM", "POL", "LW-UI", "NG-UI", "PLA", "tests"]
+                    def list = ["RO", "openvim", "osmclient", "IM", "devops", "MON", "N2VC", "NBI", "common", "LCM", "POL", "NG-UI", "PLA", "tests"]
                     if (upstreamComponent.length()>0) {
                         println("Skipping upstream fetch of "+upstreamComponent)
                         list.remove(upstreamComponent)
@@ -251,11 +253,15 @@ node("${params.NODE}") {
 ///////////////////////////////////////////////////////////////////////////////////////
 // Create Devops APT repository
 ///////////////////////////////////////////////////////////////////////////////////////
-                    sh "mv devops/pool/ pool"
-                    sh "dpkg-sig --sign builder -k ${GPG_KEY_NAME} pool/devops/*"
-                    sh "mkdir -p dists/${params.REPO_DISTRO}/devops/binary-amd64/"
-                    sh "apt-ftparchive packages pool/devops > dists/${params.REPO_DISTRO}/devops/binary-amd64/Packages"
-                    sh "gzip -9fk dists/${params.REPO_DISTRO}/devops/binary-amd64/Packages"
+                    sh "mkdir -p pool"
+                    for (component in [ "devops", "IM", "osmclient" ]) {
+                        sh "ls -al ${component}/pool/"
+                        sh "cp -r ${component}/pool/* pool/"
+                        sh "dpkg-sig --sign builder -k ${GPG_KEY_NAME} pool/${component}/*"
+                        sh "mkdir -p dists/${params.REPO_DISTRO}/${component}/binary-amd64/"
+                        sh "apt-ftparchive packages pool/${component} > dists/${params.REPO_DISTRO}/${component}/binary-amd64/Packages"
+                        sh "gzip -9fk dists/${params.REPO_DISTRO}/${component}/binary-amd64/Packages"
+                    }
 
                     // create and sign the release file
                     sh "apt-ftparchive release dists/${params.REPO_DISTRO} > dists/${params.REPO_DISTRO}/Release"
@@ -451,9 +457,9 @@ node("${params.NODE}") {
                                     --tag ${container_name}
                             """
                         }
-                        prometheusHostname = "prometheus."+IP_ADDRESS+".xip.io"
+                        prometheusHostname = "prometheus."+IP_ADDRESS+".nip.io"
                         prometheusPort = 80
-                        osmHostname = "nbi."+IP_ADDRESS+".xip.io:443"
+                        osmHostname = "nbi."+IP_ADDRESS+".nip.io:443"
                     } else {
                         // Run -k8s installer here specifying internal docker registry and docker proxy
                         withCredentials([[$class: 'UsernamePasswordMultiBinding', credentialsId: 'gitlab-registry',
@@ -465,7 +471,8 @@ node("${params.NODE}") {
                                     ${release} -r unstable \
                                     -d ${USERNAME}:${PASSWORD}@${INTERNAL_DOCKER_REGISTRY} \
                                     -p ${INTERNAL_DOCKER_PROXY} \
-                                    -t ${container_name}
+                                    -t ${container_name} \
+                                    --nocachelxdimages
                             """
                         }
                         prometheusHostname = IP_ADDRESS
@@ -482,7 +489,6 @@ node("${params.NODE}") {
                         /usr/share/osm-devops/installers/osm_health.sh -k -s ${stackName}
                     """
                 } // stage("OSM Health")
-            }
             } // if ( params.DO_INSTALL )
 
 
@@ -499,7 +505,7 @@ node("${params.NODE}") {
                             hostfile="${tempdir}/hosts"
                             sh """cat << EOF > ${hostfile}
 127.0.0.1           localhost
-${remote.host}      prometheus.${remote.host}.xip.io nbi.${remote.host}.xip.io
+${remote.host}      prometheus.${remote.host}.nip.io nbi.${remote.host}.nip.io
 EOF"""
                         } else {
                             hostfile=null
@@ -511,7 +517,7 @@ EOF"""
 
                         run_robot_systest(
                             container_name,
-                            params.ROBOT_TAG,
+                            params.ROBOT_TAG_NAME,
                             osmHostname,
                             prometheusHostname,
                             prometheusPort,
@@ -519,13 +525,16 @@ EOF"""
                             params.KUBECONFIG,
                             params.CLOUDS,
                             hostfile,
-                            jujuPassword)
+                            jujuPassword,
+                            params.ROBOT_PASS_THRESHOLD,
+                            params.ROBOT_UNSTABLE_THRESHOLD
+                        )
                     } // stage("System Integration Test")
                 } finally {
                     stage("Archive Container Logs") {
                         // Archive logs to containers_logs.txt
                         archive_logs(remote)
-                        if ( ! currentBuild.result.equals('UNSTABLE') && ! currentBuild.result.equals('FAILURE')) {
+                        if ( ! currentBuild.result.equals('FAILURE') ) {
                             stage_archive = keep_artifacts
                         } else {
                             println ("Systest test failed, throwing error")