a338149071ffa4a2f136e98993c28418436f93ae
[kvmfornfv.git] / ci / test_kvmfornfv.sh
1 #!/bin/bash
2
3 #############################################################
4 ## This script  will launch ubuntu docker container
5 ## runs cyclictest through yardstick
6 ## and verifies the test results.
7 ############################################################
8
9 volume=/tmp/kvmtest-*
10 if [ -d ${volume} ] ; then
11     echo "Directory '${volume}' exists"
12     sudo rm -rf ${volume}
13 fi
14
15 time_stamp=$(date +%Y%m%d%H%M%S)
16 mkdir -p /tmp/kvmtest-${time_stamp}/{image,rpm,scripts}
17
18 #copying required files to run yardstick cyclic testcase
19 mv ${WORKSPACE}/build_output/* $volume/rpm
20 cp ${WORKSPACE}/ci/envs/* $volume/scripts
21 cp ${WORKSPACE}/tests/cyclictest-node-context.yaml $volume
22 cp ${WORKSPACE}/tests/pod.yaml $volume
23
24 #Launching ubuntu docker container to run yardstick
25 sudo docker run -t -i -v $volume:/opt --net=host --name kvmfornfv \
26 kvmfornfv:latest  /bin/bash /opt/scripts/cyclictest.sh
27 container_id=`sudo docker ps -a | grep kvmfornfv |awk '{print $1}'`
28 sudo docker rm $container_id
29
30 #Verifying the results of cyclictest
31 result=`grep -o '"errors":[^,]*' $volume/yardstick.out | awk -F '"' \
32 '{print $4}'| awk '{if (NF=0) print "SUCCESS" }'`
33 if [ "$result" = "SUCCESS" ]; then
34     echo "####################################################"
35     echo ""
36     echo `grep -o '"data":[^}]*' $volume/yardstick.out | awk -F '{' '{print $2}'`
37     echo ""
38     echo "####################################################"
39     exit 0
40 else
41     echo "Testcase failed"
42     echo `grep -o '"errors":[^,]*' $volume/yardstick.out | awk -F '"' '{print $4}'`
43     exit 1
44 fi