3 #############################################################
4 ## This script will launch ubuntu docker container
5 ## runs cyclictest through yardstick
6 ## and verifies the test results.
7 ############################################################
9 source $WORKSPACE/ci/envs/utils.sh
10 HOST_IP=$( getHostIP )
11 KERNEL_VERSION=$( getKernelVersion )
12 if [ -z $KERNEL_VERSION ];then
13 echo "Kernel RPM not found in $WORKSPACE/build_output Directory"
17 docker_image_dir=$WORKSPACE/docker_image_build
19 container_id=`sudo docker ps -a | grep kvmfornfv |awk '{print $1}'|sed -e 's/\r//g'`
20 sudo docker rm $container_id
21 sudo ssh root@$HOST_IP "rm -rf /root/workspace/*"
22 sudo ssh root@$HOST_IP "pid=\$(ps aux | grep 'qemu' | awk '{print \$2}' | head -1); echo \$pid |xargs kill"
23 sudo rm -rf /tmp/kvmtest-*
27 sudo ssh root@$HOST_IP "rpm=\$(rpm -qa | grep 'kernel-${KERNEL_VERSION}' | awk '{print \$1}'); rpm -ev \$rpm"
28 sudo ssh root@$HOST_IP "rm -rf /boot/initramfs-${KERNEL_VERSION}*.img"
29 sudo ssh root@$HOST_IP "grub2-mkconfig -o /boot/grub2/grub.cfg"
30 sudo ssh root@$HOST_IP "reboot"
33 #Cleaning up the test environment before running cyclictest through yardstick.
36 #Creating a docker image with yardstick installed.
37 ( cd ${docker_image_dir}; sudo docker build -t kvmfornfv:latest --no-cache=true . )
38 if [ ${?} -ne 0 ] ; then
39 echo "Docker image build failed"
40 id=$(sudo docker ps -a | head -2 | tail -1 | awk '{print $1}'); sudo docker rm -f $id
44 time_stamp=$(date +%Y%m%d%H%M%S)
45 volume=/tmp/kvmtest-${time_stamp}
46 mkdir -p $volume/{image,rpm,scripts}
48 #copying required files to run yardstick cyclic testcase
49 mv $WORKSPACE/build_output/kernel-${KERNEL_VERSION}*.rpm $volume/rpm
50 cp -r $WORKSPACE/ci/envs/* $volume/scripts
51 cp -r $WORKSPACE/tests/cyclictest-node-context.yaml $volume
52 cp -r $WORKSPACE/tests/pod.yaml $volume
54 #Launching ubuntu docker container to run yardstick
55 sudo docker run -i -v $volume:/opt --net=host --name kvmfornfv \
56 kvmfornfv:latest /bin/bash -c "cd /opt/scripts && ls; ./cyclictest.sh"
58 #Verifying the results of cyclictest
59 result=`grep -o '"errors":[^,]*' $volume/yardstick.out | awk -F '"' '{print $4}'`
61 if [ -z "$result" ]; then
62 echo "####################################################"
64 echo `grep -o '"data":[^}]*' $volume/yardstick.out | awk -F '{' '{print $2}'`
66 echo "####################################################"
67 #cleaning the environment after executing the test through yardstick.
69 #Cleaning the latest kernel changes on host after executing the test.
73 echo "Testcase failed"
74 echo `grep -o '"errors":[^,]*' ${volume}/yardstick.out | awk -F '"' '{print $4}'`
75 #cleaning the environment after executing the test through yardstick.
77 #Cleaning the latest kernel changes on host after executing the test.