From 35c45d5c524bf83375fab7b9483835d43b69a5a6 Mon Sep 17 00:00:00 2001 From: zhihui wu Date: Tue, 25 Jul 2017 17:37:39 +0800 Subject: run storperf test by using these scripts Local test with apex is OK. JIRA:QTIP-248 Change-Id: I47c55ddd88f9722ce83b73a4d7ec91ece2aab2ed Signed-off-by: zhihui wu --- integration/storperf/start_job.sh | 91 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 91 insertions(+) create mode 100755 integration/storperf/start_job.sh (limited to 'integration/storperf/start_job.sh') diff --git a/integration/storperf/start_job.sh b/integration/storperf/start_job.sh new file mode 100755 index 00000000..6ac95ec0 --- /dev/null +++ b/integration/storperf/start_job.sh @@ -0,0 +1,91 @@ +#! /bin/bash +############################################################################## +# Copyright (c) 2017 ZTE and others. +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Apache License, Version 2.0 +# which accompanies this distribution, and is available at +# http://www.apache.org/licenses/LICENSE-2.0 +############################################################################## + +usage(){ + echo "usage: $0 -s -j " >&2 +} + +#Get options +while getopts ":s:j:he" optchar; do + case "${optchar}" in + s) stack_json=${OPTARG} ;; + j) job_json=${OPTARG} ;; + h) usage + exit 0 + ;; + *) echo "Non-option argument: '-${OPTARG}'" >&2 + usage + exit 2 + ;; + esac +done + +if [[ -z $WORKSPACE ]];then + WORKSPACE=`pwd` +fi + +echo ========================================================================== +echo "Start to create storperf stack" +cat ${stack_json} 1>&2 +echo ========================================================================== + +curl -X POST --header 'Content-Type: application/json' \ + --header 'Accept: application/json' -d @${stack_json} \ + 'http://127.0.0.1:5000/api/v1.0/configurations' + +echo +echo ========================================================================== +echo "Start to run storperf test" +cat ${job_json} 1>&2 +echo ========================================================================== + +JOB=$(curl -s -X POST --header 'Content-Type: application/json' \ + --header 'Accept: application/json' \ + -d @${job_json} 'http://127.0.0.1:5000/api/v1.0/jobs' | \ + awk '/job_id/ {print $2}' | sed 's/"//g') + +echo "JOB ID: $JOB" +if [[ -z "$JOB" ]]; then + echo "Oops, JOB ID is empty!" +else + echo "Loop: check job status" + curl -s -X GET "http://127.0.0.1:5000/api/v1.0/jobs?id=$JOB&type=status" \ + -o $WORKSPACE/status.json + + JOB_STATUS=`cat $WORKSPACE/status.json | awk '/Status/ {print $2}' | cut -d\" -f2` + while [ "$JOB_STATUS" != "Completed" ] + do + sleep 300 + mv $WORKSPACE/status.json $WORKSPACE/old-status.json + curl -s -X GET "http://127.0.0.1:5000/api/v1.0/jobs?id=$JOB&type=status" \ + -o $WORKSPACE/status.json + JOB_STATUS=`cat $WORKSPACE/status.json | awk '/Status/ {print $2}' | cut -d\" -f2` + diff $WORKSPACE/status.json $WORKSPACE/old-status.json >/dev/null + if [ $? -eq 1 ] + then + cat $WORKSPACE/status.json + fi + done + + echo ========================================================================== + echo "Storperf test completed!" + echo ========================================================================== + + curl -s -X GET "http://127.0.0.1:5000/api/v1.0/jobs?id=$JOB&type=metadata" \ + -o $WORKSPACE/report.json + + echo ========================================================================== + echo Final report + echo ========================================================================== + cat $WORKSPACE/report.json +fi + +echo "Deleting stack for cleanup" +curl -s -X DELETE --header 'Accept: application/json' 'http://127.0.0.1:5000/api/v1.0/configurations' + -- cgit 1.2.3-korg