Add private key to docker/tests to access OSM instance 08/11108/2
authorgarciadeblas <gerardo.garciadeblas@telefonica.com>
Fri, 13 Aug 2021 14:43:15 +0000 (16:43 +0200)
committerbeierlm <mark.beierl@canonical.com>
Thu, 26 Aug 2021 20:17:26 +0000 (22:17 +0200)
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 <gerardo.garciadeblas@telefonica.com>
docker/tests/Dockerfile
jenkins/ci-pipelines/ci_stage_3.groovy

index 5ae1d3c..689e37e 100644 (file)
@@ -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
 
index d9c687c..8804cee 100644 (file)
@@ -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
                         )