+
+////////////////////////////////////////////////////////////////////////////////////////
+// Helper Functions
+////////////////////////////////////////////////////////////////////////////////////////
+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"
+ }
+ PROMETHEUS_PORT_VAR = ""
+ if ( prometheusPort != null) {
+ PROMETHEUS_PORT_VAR = "--env PROMETHEUS_PORT="+prometheusPort
+ }
+ hostfilemount=""
+ if ( hostfile ) {
+ hostfilemount="-v "+hostfile+":/etc/hosts"
+ }
+
+ JUJU_PASSWORD_VAR = ""
+ if ( jujuPassword != null) {
+ JUJU_PASSWORD_VAR = "--env JUJU_PASSWORD="+jujuPassword
+ }
+
+ 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 ${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()
+ println ("Present Directory is : ${outputDirectory}")
+ step([
+ $class : 'RobotPublisher',
+ outputPath : "${outputDirectory}",
+ outputFileName : "*.xml",
+ disableArchiveOutput : false,
+ reportFileName : "report.html",
+ logFileName : "log.html",
+ passThreshold : pass_th,
+ unstableThreshold: unstable_th,
+ otherFiles : "*.png",
+ ])
+ }
+}
+
+def archive_logs(remote) {
+
+ sshCommand remote: remote, command: '''mkdir -p logs'''
+ if (useCharmedInstaller) {
+ sshCommand remote: remote, command: '''
+ for container in `kubectl get pods -n osm | grep -v operator | grep -v NAME| awk '{print $1}'`; do
+ logfile=`echo $container | cut -d- -f1`
+ echo "Extracting log for $logfile"
+ kubectl logs -n osm $container --timestamps=true 2>&1 > logs/$logfile.log
+ done
+ '''
+ } else {
+ sshCommand remote: remote, command: '''
+ for deployment in `kubectl -n osm get deployments | grep -v operator | grep -v NAME| awk '{print $1}'`; do
+ echo "Extracting log for $deployment"
+ kubectl -n osm logs deployments/$deployment --timestamps=true --all-containers 2>&1 > logs/$deployment.log
+ done
+ '''
+ sshCommand remote: remote, command: '''
+ for statefulset in `kubectl -n osm get statefulsets | grep -v operator | grep -v NAME| awk '{print $1}'`; do
+ echo "Extracting log for $statefulset"
+ kubectl -n osm logs statefulsets/$statefulset --timestamps=true --all-containers 2>&1 > logs/$statefulset.log
+ done
+ '''
+ }
+
+ sh "rm -rf logs"
+ sshCommand remote: remote, command: '''ls -al logs'''
+ sshGet remote: remote, from: 'logs', into: '.', override: true
+ sh "cp logs/* ."
+ archiveArtifacts artifacts: '*.log'