Adding post-execute scripts to cyclictest execution
[kvmfornfv.git] / ci / envs / cyclictest.sh
1 #!/bin/bash
2
3 ###########################################################
4 ## Invoking this script from ubuntu docker container runs
5 ## cyclictest through yardstick
6 ###########################################################
7 source utils.sh
8
9 testType=$1 #daily/verify/merge
10 testName=$2 #idle_idle/stress_idle
11 HOST_IP=$( getHostIP )
12 pod_config='/opt/scripts/pod.yaml'
13 cyclictest_context_file='/opt/kvmfornfv_cyclictest_'${testName}'.yaml'
14 yardstick_prefix='/root/yardstick/yardstick/benchmark/scenarios/compute' # yardstick teardown path
15
16 if [ ! -f ${pod_config} ] ; then
17     echo "file ${pod_config} not found"
18     exit 1
19 fi
20
21 if [ ! -f ${cyclictest_context_file} ] ; then
22     echo "file ${cyclictest_context_file} not found"
23     exit 1
24 fi
25
26 #As yardstick executes only *.bash scripts, copy the post-execute script as .bash script
27 cp /opt/scripts/disable_trace.sh ${yardstick_prefix}/disable_trace.bash
28
29 #Execution of the post-execute script copied requires re-installation of yardstick
30 ( cd /root/yardstick ; python setup.py install )
31
32 #setting up of image for launching guest vm.
33 ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null \
34 root@$HOST_IP "cp /root/images/guest1.qcow2 /root/"
35
36 #Updating the yardstick.conf file for daily
37 function updateConfDaily() {
38    DISPATCHER_TYPE=influxdb
39    DISPATCHER_FILE_NAME="/tmp/yardstick.out"
40    # Use the influxDB on the jumping server
41    DISPATCHER_INFLUXDB_TARGET="http://104.197.68.199:8086"
42    mkdir -p /etc/yardstick
43    cat << EOF > /etc/yardstick/yardstick.conf
44 [DEFAULT]
45 debug = True
46 dispatcher = ${DISPATCHER_TYPE}
47
48 [dispatcher_file]
49 file_name = ${DISPATCHER_FILE_NAME}
50
51 [dispatcher_influxdb]
52 timeout = 5
53 db_name = yardstick
54 username = opnfv
55 password = 0pnfv2015
56 target = ${DISPATCHER_INFLUXDB_TARGET}
57 EOF
58 }
59
60 #Function call to update yardstick conf file based on Job type
61 if [ "$testType" == "daily" ];then
62    updateConfDaily
63 fi
64
65 #Running cyclictest through yardstick
66 yardstick -d task start ${cyclictest_context_file}
67 output=$?
68
69 if [ "$testType" == "verify" ];then
70    chmod 777 /tmp/yardstick.out
71    cat /tmp/yardstick.out  > /opt/yardstick.out
72 fi
73
74 if [ $output != 0 ];then
75    echo "Yardstick Failed !!!"
76    exit 1
77 fi