+def run_robot_systest(tagName,testName,osmHostname,prometheusHostname,prometheus_port=null,envfile=null,kubeconfig=null,clouds=null,hostfile=null,jujuPassword=null) {
+ 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 ${kubeconfig}:/root/.kube/config -v ${tempdir}:/robot-systest/reports ${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 : 0,
+ unstableThreshold: 0,
+ 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'
+}
+
+def get_value(key, output) {
+ for (String line : output.split( '\n' )) {
+ data = line.split( '\\|' )
+ if (data.length > 1) {
+ if ( data[1].trim() == key ) {
+ return data[2].trim()
+ }
+ }
+ }
+}
+