This patch includes scripts to create multiple yaml file for different
[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 cyclictest_env_verify=("idle_idle" "cpustress_idle" "memorystress_idle" "iostress_idle") #cyclictest environment
17 cyclictest_env_daily=("idle_idle" "cpustress_idle" "memorystress_idle" "iostress_idle")
18 cyclictest_result=0 #exit code of cyclictest
19 packetforward_result=0 #exit code of packet forward
20
21 function packetForward {
22 #   source $WORKSPACE/ci/packet_forward_test.sh $HOST_IP
23    echo "Packetforwarding need to be implemented"
24    packetforward_result=$?
25    if [ ${packetforward_result} -ne 0 ];then
26       echo "Packet Forwarding test case execution FAILED"
27    else
28       echo "Packet Forwarding test case executed SUCCESSFULLY"
29    fi
30    host_clean
31 }
32
33 function cyclictest {
34    test_case=$1
35    source $WORKSPACE/ci/cyclicTestTrigger.sh $HOST_IP $test_time $test_type $test_case
36    #calculating and verifying sha512sum of the guestimage.
37    if ! verifyGuestImage;then
38       exit 1
39    fi
40    #Update kvmfornfv_cyclictest_${testName}.yaml with test_time and pod.yaml with IP
41    updateYaml
42    #Cleaning up the test environment before running cyclictest through yardstick.
43    env_clean
44    #Creating a docker image with yardstick installed and launching ubuntu docker to run yardstick cyclic testcase
45    if runCyclicTest;then
46       cyclictest_result=`expr ${cyclictest_result} + 0`
47    else
48       echo "Test case execution FAILED for ${test_case} environment"
49       cyclictest_result=`expr ${cyclictest_result} + 1`
50    fi
51 }
52
53 #Execution of testcases based on test type and test name from releng.
54 if [ ${test_type} == "verify" ];then
55    HOST_IP="10.2.117.23"
56    test_time=120000 # 2m
57    for env in ${cyclictest_env_verify[@]}
58    do
59       #Executing cyclictest through yardstick.
60       cyclictest ${env}
61       sleep 10
62    done
63    #Execution of packet forwarding test cases.
64    packetForward
65    if [ ${cyclictest_result} -ne 0 ] ||  [ ${packetforward_result} -ne 0 ];then
66       echo "Test case FAILED"
67       exit 1
68    else
69       exit 0
70    fi
71 elif [ ${test_type} == "daily" ];then
72    HOST_IP="10.2.117.25"
73    test_time=3600000 #1h
74    if [ ${test_name} == "packet_forward" ];then
75       packetForward
76       if [ ${packetforward_result} -ne 0 ] ; then
77          exit 1
78       else
79          exit 0
80       fi
81    elif [ ${test_name} == "cyclictest" ];then
82       for env in ${cyclictest_env_daily[@]}
83       do
84          #Executing cyclictest through yardstick.
85          cyclictest ${env}
86          sleep 5
87       done
88       if [ ${cyclictest_result} -ne 0 ] ; then
89          echo "Cyclictest case execution FAILED"
90          exit 1
91       else
92          echo "Cyclictest case executed SUCCESSFULLY"
93          exit 0
94       fi
95    fi
96 elif [ ${test_type} == "merge" ];then
97    echo "Test is not enabled for ${test_type}"
98    exit 0
99 else
100    echo "Incorrect test type ${test_type}"
101 fi