From: garciadeblas Date: Fri, 13 Aug 2021 14:43:15 +0000 (+0200) Subject: Add private key to docker/tests to access OSM instance X-Git-Tag: release-v11.0-start~34 X-Git-Url: https://osm.etsi.org/gitweb/?a=commitdiff_plain;h=2ad643224e7f9b5443db6fdd41e1acb3535cec25;p=osm%2Fdevops.git Add private key to docker/tests to access OSM instance Some of the tests require access to OSM instance in order to run some commands from there. Those commands could be run using ssh, but a private key is required to be able connect to that OSM instance. This change gets the private key corresponding to the public key in OSM instance and mounts it in docker/tests so that the container can access to OSM instance via ssh and run commands there. Change-Id: Id12ede582d5e519afbc41647b90d192b80cf8fcf Signed-off-by: garciadeblas --- diff --git a/docker/tests/Dockerfile b/docker/tests/Dockerfile index 5ae1d3cb..689e37e5 100644 --- a/docker/tests/Dockerfile +++ b/docker/tests/Dockerfile @@ -89,6 +89,9 @@ ENV K8S_CREDENTIALS=/root/.kube/config # Juju data folder ENV JUJU_DATA=/root/.local/share/juju +# OSM RSA file +ENV OSM_RSA_FILE=/root/osm_id_rsa + ENV LC_ALL=C.UTF-8 ENV LANG=C.UTF-8 diff --git a/jenkins/ci-pipelines/ci_stage_3.groovy b/jenkins/ci-pipelines/ci_stage_3.groovy index d9c687cf..8804ceec 100644 --- a/jenkins/ci-pipelines/ci_stage_3.groovy +++ b/jenkins/ci-pipelines/ci_stage_3.groovy @@ -56,10 +56,23 @@ properties([ //////////////////////////////////////////////////////////////////////////////////////// // Helper Functions //////////////////////////////////////////////////////////////////////////////////////// -def run_robot_systest(tagName,testName,osmHostname,prometheusHostname,prometheus_port=null,envfile=null,portmappingfile=null,jujudata=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 jujudata=null, + String kubeconfig=null, + String clouds=null, + String hostfile=null, + String jujuPassword=null, + String osmRSAfile=null, + String passThreshold='0.0', + String unstableThreshold='0.0') { + tempdir = sh(returnStdout: true, script: 'mktemp -d').trim() + if ( !envfile ) { sh(script: "touch ${tempdir}/env") envfile="${tempdir}/env" } @@ -78,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 ${jujudata}:/root/.local/share/juju -v ${kubeconfig}:/root/.kube/config -v ${tempdir}:/robot-systest/reports -v ${portmappingfile}:/root/port-mapping.yaml ${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 ${jujudata}:/root/.local/share/juju -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() @@ -537,6 +550,7 @@ EOF""" params.CLOUDS, hostfile, jujuPassword, + SSH_KEY, params.ROBOT_PASS_THRESHOLD, params.ROBOT_UNSTABLE_THRESHOLD )