This patch updates latency threshold values for execution of
[kvmfornfv.git] / ci / test_kvmfornfv.sh
1 #!/bin/bash
2
3 ############################################################
4 ## This script  is an interface to trigger the
5 ## cyclicTestTrigger.sh for test type like patch verification,
6 ## daily testing.
7 ## Releng will trigger this script by passing test type as
8 ## verify/daily and test name as idle_idle/stress_idle/
9 ## packet_forward as arguments.
10 ## Verify Job runs idle_idle,packet_forward test
11 ## daily job runs base on the test name parameter
12 ############################################################
13
14 test_type=$1
15 test_name=$2
16 ftrace_enable=0
17 cyclictest_env_verify=("idle_idle" "cpustress_idle" "memorystress_idle" "iostress_idle") #cyclictest environment
18 cyclictest_env_daily=("idle_idle" "cpustress_idle" "memorystress_idle" "iostress_idle")
19 cyclictest_result=0 #exit code of cyclictest
20 packetforward_result=0 #exit code of packet forward
21 source $WORKSPACE/ci/envs/host-config
22
23 function packetForward {
24 #   source $WORKSPACE/ci/packet_forward_test.sh $HOST_IP
25    echo "Packetforwarding need to be implemented"
26    packetforward_result=$?
27    if [ ${packetforward_result} -ne 0 ];then
28       echo "Packet Forwarding test case execution FAILED"
29    else
30       echo "Packet Forwarding test case executed SUCCESSFULLY"
31    fi
32    host_clean
33 }
34
35 function cyclictest {
36    test_case=$1
37    source $WORKSPACE/ci/cyclicTestTrigger.sh $HOST_IP $test_time $test_type $test_case
38    #Verifying whether the test node is up and running
39    connect_host
40    #Waiting for ssh to be available for the host machine.
41    sleep 10
42    #calculating and verifying sha512sum of the guestimage.
43    if ! verifyGuestImage;then
44       exit 1
45    fi
46    #Update kvmfornfv_cyclictest_${testName}.yaml with test_time and pod.yaml with IP
47    updateYaml
48    #Cleaning up the test environment before running cyclictest through yardstick.
49    env_clean
50    #Creating a docker image with yardstick installed and launching ubuntu docker to run yardstick cyclic testcase
51    if runCyclicTest;then
52       cyclictest_result=`expr ${cyclictest_result} + 0`
53    else
54       echo "Test case execution FAILED for ${test_case} environment"
55       cyclictest_result=`expr ${cyclictest_result} + 1`
56    fi
57 }
58
59 function ftrace_disable {
60    sudo ssh root@${HOST_IP} "sh /root/workspace/scripts/disbale-trace.sh"
61    sudo ssh root@${HOST_IP} "cd /tmp ; a=\$(ls -rt | tail -1) ; echo \$a ; mv \$a cyclictest_${env}.txt"
62    sudo mkdir -p $WORKSPACE/build_output/log/kernel_trace
63    sudo scp root@${HOST_IP}:/tmp/cyclictest_${env}.txt $WORKSPACE/build_output/log/kernel_trace/
64 }
65
66 #Execution of testcases based on test type and test name from releng.
67 if [ ${test_type} == "verify" ];then
68    HOST_IP="10.10.100.21"
69    test_time=1000 # 1s
70    if [ ${ftrace_enable} -eq '1' ]; then
71       for env in ${cyclictest_env_verify[@]}
72       do
73          #Enabling ftrace for kernel debugging.
74          sed -i '/host-setup1.sh/a\    \- \"enable-trace.sh\"' kvmfornfv_cyclictest_hostenv_guestenv.yaml
75          #Executing cyclictest through yardstick.
76          cyclictest ${env}
77          #disabling ftrace and collecting the logs to upload to artifact repository.
78          ftrace_disable
79          sleep 10
80       done
81       #Execution of packet forwarding test cases.
82       packetForward
83    else
84       for env in ${cyclictest_env_verify[@]}
85       do
86          #Executing cyclictest through yardstick.
87          cyclictest ${env}
88          sleep 10
89       done
90       #Execution of packet forwarding test cases.
91       packetForward
92    fi
93       if [ ${cyclictest_result} -ne 0 ] ||  [ ${packetforward_result} -ne 0 ];then
94          echo "Test case FAILED"
95          err_exit 1
96       else
97          err_exit 0
98       fi
99 elif [ ${test_type} == "daily" ];then
100    HOST_IP="10.10.100.22"
101    test_time=3600000 #1h
102    if [ ${test_name} == "packet_forward" ];then
103       packetForward
104       if [ ${packetforward_result} -ne 0 ] ; then
105          err_exit 1
106       else
107          err_exit 0
108       fi
109    elif [ ${test_name} == "cyclictest" ];then
110       if [ ${ftrace_enable} -eq '1' ]; then
111          for env in ${cyclictest_env_daily[@]}
112          do
113             #Enabling ftrace for kernel debugging.
114             sed -i '/host-setup1.sh/a\    \- \"enable-trace.sh\"' kvmfornfv_cyclictest_hostenv_guestenv.yaml
115             #Executing cyclictest through yardstick.
116             cyclictest ${env}
117             #disabling ftrace and collecting the logs to upload to artifact repository. 
118             ftrace_disable
119             sleep 5
120          done
121       else
122          for env in ${cyclictest_env_daily[@]}
123          do
124          #Executing cyclictest through yardstick.
125          cyclictest ${env}
126          sleep 5
127          done
128       fi
129          if [ ${cyclictest_result} -ne 0 ] ; then
130             echo "Cyclictest case execution FAILED"
131             err_exit 1
132          else
133             echo "Cyclictest case executed SUCCESSFULLY"
134             err_exit 0
135          fi
136    fi
137 elif [ ${test_type} == "merge" ];then
138    echo "Test is not enabled for ${test_type}"
139    exit 0
140 else
141    echo "Incorrect test type ${test_type}"
142 fi