Execution of kvm4nfv cyclictest based on job type.
[kvmfornfv.git] / ci / test_kvmfornfv.sh
old mode 100644 (file)
new mode 100755 (executable)
index a338149..858aaf3
@@ -1,44 +1,33 @@
 #!/bin/bash
 
-#############################################################
-## This script  will launch ubuntu docker container
-## runs cyclictest through yardstick
-## and verifies the test results.
 ############################################################
+## This script  is an interface to trigger the
+## cyclicTestTrigger.sh for test type like patch verification,
+## daily testing.
+## Releng will trigger this script by passing test type like
+## verify/daily as an argument
+############################################################
+
+test_type=$1
 
-volume=/tmp/kvmtest-*
-if [ -d ${volume} ] ; then
-    echo "Directory '${volume}' exists"
-    sudo rm -rf ${volume}
+if [ ${test_type} == "verify" ];then
+   HOST_IP="10.2.117.23"
+   test_time=600000 # 10m
+elif [ ${test_type} == "daily" ];then
+   HOST_IP="10.2.117.25"
+   test_time=7200000 #2h
+elif [ ${test_type} == "merge" ];then
+   echo "Test is not enabled for ${test_type}"
+   exit 0
 fi
 
-time_stamp=$(date +%Y%m%d%H%M%S)
-mkdir -p /tmp/kvmtest-${time_stamp}/{image,rpm,scripts}
+source $WORKSPACE/ci/cyclicTestTrigger.sh $HOST_IP $test_time $test_type
 
-#copying required files to run yardstick cyclic testcase
-mv ${WORKSPACE}/build_output/* $volume/rpm
-cp ${WORKSPACE}/ci/envs/* $volume/scripts
-cp ${WORKSPACE}/tests/cyclictest-node-context.yaml $volume
-cp ${WORKSPACE}/tests/pod.yaml $volume
+#Update cyclictest-node-context.yaml with test_time and pod.yaml with IP
+updateYaml
 
-#Launching ubuntu docker container to run yardstick
-sudo docker run -t -i -v $volume:/opt --net=host --name kvmfornfv \
-kvmfornfv:latest  /bin/bash /opt/scripts/cyclictest.sh
-container_id=`sudo docker ps -a | grep kvmfornfv |awk '{print $1}'`
-sudo docker rm $container_id
+#Cleaning up the test environment before running cyclictest through yardstick.
+env_clean
 
-#Verifying the results of cyclictest
-result=`grep -o '"errors":[^,]*' $volume/yardstick.out | awk -F '"' \
-'{print $4}'| awk '{if (NF=0) print "SUCCESS" }'`
-if [ "$result" = "SUCCESS" ]; then
-    echo "####################################################"
-    echo ""
-    echo `grep -o '"data":[^}]*' $volume/yardstick.out | awk -F '{' '{print $2}'`
-    echo ""
-    echo "####################################################"
-    exit 0
-else
-    echo "Testcase failed"
-    echo `grep -o '"errors":[^,]*' $volume/yardstick.out | awk -F '"' '{print $4}'`
-    exit 1
-fi
+#Creating a docker image with yardstick installed and launching ubuntu docker to run yardstick cyclic testcase
+runCyclicTest