CI integration for KVMforNFV.
[kvmfornfv.git] / ci / test_kvmfornfv.sh
1 #!/bin/bash
2
3 #############################################################
4 ## !!! The original test_kvmfornfv.sh is removed because it
5 ## break the verification process!!!
6 #############################################################
7 ## This script  will launch ubuntu docker container
8 ## runs cyclictest through yardstick
9 ## and verifies the test results.
10 ############################################################
11
12
13 function env_clean {
14     container_id=`sudo docker ps -a | grep kvmfornfv |awk '{print $1}'`
15     sudo docker rm $container_id
16     sudo ssh root@10.2.117.23 "rm -rf /root/workspace/*"
17     sudo ssh root@10.2.117.23 "pid=\$(ps aux | grep 'qemu' | awk '{print \$2}' | head -1); echo \$pid |xargs kill"
18     sudo rm -rf /tmp/kvmtest-*
19 }
20
21 #Cleaning up the test environment before running cyclictest through yardstick.
22 env_clean
23
24 time_stamp=$(date +%Y%m%d%H%M%S)
25 volume=/tmp/kvmtest-${time_stamp}
26 mkdir -p $volume/{image,rpm,scripts}
27
28 #copying required files to run yardstick cyclic testcase
29 mv $WORKSPACE/build_output/kernel-4.4*.rpm $volume/rpm
30 cp -r $WORKSPACE/ci/envs/* $volume/scripts
31 cp -r $WORKSPACE/tests/cyclictest-node-context.yaml $volume
32 cp -r $WORKSPACE/tests/pod.yaml $volume
33
34 #Launching ubuntu docker container to run yardstick
35 sudo docker run -i -v $volume:/opt --net=host --name kvmfornfv \
36 kvmfornfv:latest  /bin/bash -c "cd /opt/scripts && ls; ./cyclictest.sh"
37
38 #Verifying the results of cyclictest
39 result=`grep -o '"errors":[^,]*' $volume/yardstick.out | awk -F '"' '{print $4}'`
40
41 if [ -z "$result" ]; then
42     echo "####################################################"
43     echo ""
44     echo `grep -o '"data":[^}]*' $volume/yardstick.out | awk -F '{' '{print $2}'`
45     echo ""
46     echo "####################################################"
47     env_clean
48     exit 0
49 else
50     echo "Testcase failed"
51     echo `grep -o '"errors":[^,]*' ${volume}/yardstick.out | awk -F '"' '{print $4}'`
52     env_clean
53     exit 1
54 fi