X-Git-Url: https://osm.etsi.org/gitweb/?a=blobdiff_plain;f=jenkins%2Fci-pipelines%2Fci_stage_3.groovy;h=7a920762928b3b3c0626365bae1ec15ccb81a1ad;hb=f83c20ab3304291aca8224ebe2dd88b58b5dc1b4;hp=a119ecfa8d584177ea8068c671cad14aac8d3aa8;hpb=4a7a23cdf44402d3be70b491049129b0b28ed02f;p=osm%2Fdevops.git diff --git a/jenkins/ci-pipelines/ci_stage_3.groovy b/jenkins/ci-pipelines/ci_stage_3.groovy index a119ecfa..7a920762 100644 --- a/jenkins/ci-pipelines/ci_stage_3.groovy +++ b/jenkins/ci-pipelines/ci_stage_3.groovy @@ -32,6 +32,7 @@ properties([ string(defaultValue: 'artifactory-osm', description: '', name: 'ARTIFACTORY_SERVER'), string(defaultValue: 'osm-stage_4', description: '', name: 'DOWNSTREAM_STAGE_NAME'), string(defaultValue: 'testing-daily', description: '', name: 'DOCKER_TAG'), + string(defaultValue: 'ubuntu20.04', description: '', name: 'OPENSTACK_BASE_IMAGE'), 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'), @@ -43,6 +44,7 @@ properties([ 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/port-mapping-etsi-vim.yaml', description: 'Port mapping file for SDN assist in ETSI VIM', name: 'ROBOT_PORT_MAPPING_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'), @@ -55,10 +57,22 @@ properties([ //////////////////////////////////////////////////////////////////////////////////////// // Helper Functions //////////////////////////////////////////////////////////////////////////////////////// -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 ) - { +void run_robot_systest(String tagName, + String testName, + String osmHostname, + String prometheusHostname, + Integer prometheusPort=null, + String envfile=null, + String portmappingfile=null, + String kubeconfig=null, + String clouds=null, + String hostfile=null, + String jujuPassword=null, + String osmRSAfile=null, + String pass_th='0.0', + String unstable_th='0.0') { + tempdir = sh(returnStdout: true, script: 'mktemp -d').trim() + if ( !envfile ) { sh(script: "touch ${tempdir}/env") envfile="${tempdir}/env" } @@ -77,7 +91,7 @@ def run_robot_systest(tagName,testName,osmHostname,prometheusHostname,prometheus } try { - sh "docker run --env OSM_HOSTNAME=${osmHostname} --env PROMETHEUS_HOSTNAME=${prometheusHostname} ${PROMETHEUS_PORT_VAR} ${JUJU_PASSWORD_VAR} --env-file ${envfile} -v ${clouds}:/etc/openstack/clouds.yaml -v ${kubeconfig}:/root/.kube/config -v ${tempdir}:/robot-systest/reports ${hostfilemount} opensourcemano/tests:${tagName} -c -t ${testName}" + sh "docker run --env OSM_HOSTNAME=${osmHostname} --env PROMETHEUS_HOSTNAME=${prometheusHostname} ${PROMETHEUS_PORT_VAR} ${JUJU_PASSWORD_VAR} --env-file ${envfile} -v ${clouds}:/etc/openstack/clouds.yaml -v ${osmRSAfile}:/root/osm_id_rsa -v ${kubeconfig}:/root/.kube/config -v ${tempdir}:/robot-systest/reports -v ${portmappingfile}:/root/port-mapping.yaml ${hostfilemount} opensourcemano/tests:${tagName} -c -t ${testName}" } finally { sh "cp ${tempdir}/* ." outputDirectory = sh(returnStdout: true, script: "pwd").trim() @@ -147,6 +161,7 @@ node("${params.NODE}") { INTERNAL_DOCKER_REGISTRY = 'osm.etsi.org:5050/devops/cicd/' INTERNAL_DOCKER_PROXY = 'http://172.21.1.1:5000' + APT_PROXY="http://172.21.1.1:3142" SSH_KEY = '~/hive/cicd_rsa' sh 'env' @@ -198,32 +213,33 @@ node("${params.NODE}") { def upstreamComponent="" if ( params.UPSTREAM_JOB_NAME ) { println("Fetching upstream job artifact from ${params.UPSTREAM_JOB_NAME}") + lock('Artifactory') { + step ([$class: 'CopyArtifact', + projectName: "${params.UPSTREAM_JOB_NAME}", + selector: [$class: 'SpecificBuildSelector', + buildNumber: "${params.UPSTREAM_JOB_NUMBER}"] + ]) + + upstreamComponent = ci_helper.get_mdg_from_project( + ci_helper.get_env_value('build.env','GERRIT_PROJECT')) + def buildNumber = ci_helper.get_env_value('build.env','BUILD_NUMBER') + dir("$upstreamComponent") { + // the upstream job name contains suffix with the project. Need this stripped off + def project_without_branch = params.UPSTREAM_JOB_NAME.split('/')[0] + def packages = ci_helper.get_archive(params.ARTIFACTORY_SERVER, + upstreamComponent, + GERRIT_BRANCH, + "${project_without_branch} :: ${GERRIT_BRANCH}", + buildNumber) - step ([$class: 'CopyArtifact', - projectName: "${params.UPSTREAM_JOB_NAME}", - selector: [$class: 'SpecificBuildSelector', - buildNumber: "${params.UPSTREAM_JOB_NUMBER}"] - ]) - - upstreamComponent = ci_helper.get_mdg_from_project( - ci_helper.get_env_value('build.env','GERRIT_PROJECT')) - def buildNumber = ci_helper.get_env_value('build.env','BUILD_NUMBER') - dir("$upstreamComponent") { - // the upstream job name contains suffix with the project. Need this stripped off - def project_without_branch = params.UPSTREAM_JOB_NAME.split('/')[0] - def packages = ci_helper.get_archive(params.ARTIFACTORY_SERVER, - upstreamComponent, - GERRIT_BRANCH, - "${project_without_branch} :: ${GERRIT_BRANCH}", - buildNumber) - - packageList.addAll(packages) - println("Fetched pre-merge ${params.UPSTREAM_JOB_NAME}: ${packages}") - } + packageList.addAll(packages) + println("Fetched pre-merge ${params.UPSTREAM_JOB_NAME}: ${packages}") + } + } // lock artifactory } parallelSteps = [:] - def list = ["RO", "openvim", "osmclient", "IM", "devops", "MON", "N2VC", "NBI", "common", "LCM", "POL", "NG-UI", "PLA", "tests"] + def list = ["RO", "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) @@ -248,7 +264,9 @@ node("${params.NODE}") { } } } - parallel parallelSteps + lock('Artifactory') { + parallel parallelSteps + } /////////////////////////////////////////////////////////////////////////////////////// // Create Devops APT repository @@ -308,7 +326,8 @@ node("${params.NODE}") { usernameVariable: 'USERNAME', passwordVariable: 'PASSWORD']]) { sh "docker login ${INTERNAL_DOCKER_REGISTRY} -u ${USERNAME} -p ${PASSWORD}" } - moduleBuildArgs = "" + datetime = sh(returnStdout: true, script: "date +%Y-%m-%d:%H:%M:%S").trim() + moduleBuildArgs = " --build-arg CACHE_DATE=${datetime}" for (packageName in builtModules.keySet()) { envName=packageName.replaceAll("-","_").toUpperCase()+"_URL" moduleBuildArgs += " --build-arg ${envName}=" + builtModules[packageName] @@ -326,7 +345,7 @@ node("${params.NODE}") { def moduleTag = container_name parallelSteps[module] = { dir("$module") { - sh "docker build -t opensourcemano/${moduleName}:${moduleTag} ${moduleBuildArgs} ." + sh "docker build --build-arg APT_PROXY=${APT_PROXY} -t opensourcemano/${moduleName}:${moduleTag} ${moduleBuildArgs} ." println("Tagging ${moduleName}:${moduleTag}") sh "docker tag opensourcemano/${moduleName}:${moduleTag} ${INTERNAL_DOCKER_REGISTRY}opensourcemano/${moduleName}:${moduleTag}" sh "docker push ${INTERNAL_DOCKER_REGISTRY}opensourcemano/${moduleName}:${moduleTag}" @@ -347,7 +366,7 @@ node("${params.NODE}") { output=sh(returnStdout: true, script: """#!/bin/sh -e for line in `grep OS ~/hive/robot-systest.cfg | grep -v OS_CLOUD` ; do export \$line ; done openstack server create --flavor osm.sanity \ - --image ubuntu18.04 \ + --image ${OPENSTACK_BASE_IMAGE} \ --key-name CICD \ --property build_url="${BUILD_URL}" \ --nic net-id=osm-ext \ @@ -430,8 +449,17 @@ node("${params.NODE}") { remote.logLevel = 'INFO' remote.pty = true + // Force time sync to avoid clock drift and invalid certificates + sshCommand remote: remote, command: """ + sudo apt update + sudo apt install -y ntp + sudo service ntp stop + sudo ntpd -gq + sudo service ntp start + """ + sshCommand remote: remote, command: """ - wget https://osm-download.etsi.org/ftp/osm-9.0-nine/install_osm.sh + wget https://osm-download.etsi.org/ftp/osm-11.0-eleven/install_osm.sh chmod +x ./install_osm.sh sed -i '1 i\\export PATH=/snap/bin:\${PATH}' ~/.bashrc """ @@ -471,8 +499,7 @@ node("${params.NODE}") { ${release} -r unstable \ -d ${USERNAME}:${PASSWORD}@${INTERNAL_DOCKER_REGISTRY} \ -p ${INTERNAL_DOCKER_PROXY} \ - -t ${container_name} \ - --nocachelxdimages + -t ${container_name} """ } prometheusHostname = IP_ADDRESS @@ -522,10 +549,12 @@ EOF""" prometheusHostname, prometheusPort, params.ROBOT_VIM, + params.ROBOT_PORT_MAPPING_VIM, params.KUBECONFIG, params.CLOUDS, hostfile, jujuPassword, + SSH_KEY, params.ROBOT_PASS_THRESHOLD, params.ROBOT_UNSTABLE_THRESHOLD ) @@ -534,7 +563,7 @@ EOF""" 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")