Remove all compass jobs
[releng.git] / jjb / bottlenecks / bottlenecks-run-suite.sh
1 #!/bin/bash
2 ##############################################################################
3 # Copyright (c) 2017 Huawei Technologies Co.,Ltd and others.
4 # All rights reserved. This program and the accompanying materials
5 # are made available under the terms of the Apache License, Version 2.0
6 # which accompanies this distribution, and is available at
7 # http://www.apache.org/licenses/LICENSE-2.0
8 ##############################################################################
9
10 #set -e
11 [[ $GERRIT_REFSPEC_DEBUG == true ]] && redirect="/dev/stdout" || redirect="/dev/null"
12 BOTTLENECKS_IMAGE=opnfv/bottlenecks
13 REPORT="True"
14
15 RELENG_REPO=${WORKSPACE}/releng
16 [ -d ${RELENG_REPO} ] && rm -rf ${RELENG_REPO}
17 git clone https://gerrit.opnfv.org/gerrit/releng ${RELENG_REPO} >${redirect}
18
19 YARDSTICK_REPO=${WORKSPACE}/yardstick
20 [ -d ${YARDSTICK_REPO} ] && rm -rf ${YARDSTICK_REPO}
21 git clone https://gerrit.opnfv.org/gerrit/yardstick ${YARDSTICK_REPO} >${redirect}
22
23 OPENRC=/tmp/admin_rc.sh
24 OS_CACERT=/tmp/os_cacert
25
26 BOTTLENECKS_CONFIG=/tmp
27 KUBESTONE_TEST_DIR=/home/opnfv/bottlenecks/testsuites/kubestone/testcases
28
29 # Pulling Bottlenecks docker and passing environment variables
30 echo "INFO: pulling Bottlenecks docker ${DOCKER_TAG}"
31 docker pull opnfv/bottlenecks:${DOCKER_TAG} >$redirect
32
33 opts="--privileged=true -id"
34 envs="-e INSTALLER_TYPE=${INSTALLER_TYPE} -e INSTALLER_IP=${INSTALLER_IP} \
35       -e NODE_NAME=${NODE_NAME} -e EXTERNAL_NET=${EXTERNAL_NETWORK} \
36       -e BRANCH=${BRANCH} -e GERRIT_REFSPEC_DEBUG=${GERRIT_REFSPEC_DEBUG} \
37       -e BOTTLENECKS_DB_TARGET=${BOTTLENECKS_DB_TARGET} -e PACKAGE_URL=${PACKAGE_URL} \
38       -e DEPLOY_SCENARIO=${DEPLOY_SCENARIO} -e BUILD_TAG=${BUILD_TAG}"
39 docker_volume="-v /var/run/docker.sock:/var/run/docker.sock -v /tmp:/tmp"
40
41 cmd="docker run ${opts} ${envs} --name bottlenecks-load-master ${docker_volume} opnfv/bottlenecks:${DOCKER_TAG} /bin/bash"
42 echo "BOTTLENECKS INFO: running docker run commond: ${cmd}"
43 ${cmd} >$redirect
44 sleep 5
45
46 # Run test suite
47 if [[ $SUITE_NAME == *posca* ]]; then
48     POSCA_SCRIPT=/home/opnfv/bottlenecks/testsuites/posca
49     sudo rm -f ${OPENRC}
50
51     if [[ -f ${OPENRC} ]]; then
52         echo "BOTTLENECKS INFO: openstack credentials path is ${OPENRC}"
53         cat ${OPENRC}
54     else
55         echo "BOTTLENECKS ERROR: couldn't find openstack rc file: ${OPENRC}, please check if the it's been properly provided."
56         exit 1
57     fi
58
59     # Finding and crearting POD description files from different deployments
60     ssh_options="-o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no"
61
62     if [ "$INSTALLER_TYPE" == "fuel" ]; then
63         echo "Fetching id_rsa file from jump_server $INSTALLER_IP..."
64         sshpass -p r00tme sudo scp $ssh_options root@${INSTALLER_IP}:~/.ssh/id_rsa ${BOTTLENECKS_CONFIG}/id_rsa
65     fi
66
67     if [ "$INSTALLER_TYPE" == "apex" ]; then
68         echo "Fetching id_rsa file from jump_server $INSTALLER_IP..."
69         sudo scp $ssh_options stack@${INSTALLER_IP}:~/.ssh/id_rsa ${BOTTLENECKS_CONFIG}/id_rsa
70     fi
71
72     set +e
73
74     sudo -H pip install virtualenv
75
76     cd ${RELENG_REPO}/modules
77     sudo virtualenv venv
78     source venv/bin/activate
79     sudo -H pip install -e ./ >/dev/null
80     sudo -H pip install netaddr
81
82     if [[ ${INSTALLER_TYPE} == fuel ]]; then
83         options="-u root -p r00tme"
84     elif [[ ${INSTALLER_TYPE} == apex ]]; then
85         options="-u stack -k /root/.ssh/id_rsa"
86     else
87         echo "Don't support to generate pod.yaml on ${INSTALLER_TYPE} currently."
88     fi
89
90     deactivate
91
92     sudo rm -rf ${RELENG_REPO}/modules/venv
93     sudo rm -rf ${RELENG_REPO}/modules/opnfv.egg-info
94
95     set -e
96
97     cd ${WORKSPACE}
98
99     if [ -f ${BOTTLENECKS_CONFIG}/pod.yaml ]; then
100         echo "FILE: ${BOTTLENECKS_CONFIG}/pod.yaml:"
101         cat ${BOTTLENECKS_CONFIG}/pod.yaml
102     else
103         echo "ERROR: cannot find file ${BOTTLENECKS_CONFIG}/pod.yaml. Please check if it is existing."
104         sudo ls -al ${BOTTLENECKS_CONFIG}
105     fi
106
107     # Running test cases through Bottlenecks docker
108     if [[ $SUITE_NAME == posca_stress_traffic ]]; then
109         TEST_CASE=posca_factor_system_bandwidth
110     elif [[ $SUITE_NAME == posca_stress_ping ]]; then
111         TEST_CASE=posca_factor_ping
112     else
113         TEST_CASE=$SUITE_NAME
114     fi
115     testcase_cmd="docker exec bottlenecks-load-master python ${POSCA_SCRIPT}/../run_testsuite.py testcase $TEST_CASE $REPORT"
116     echo "BOTTLENECKS INFO: running test case ${TEST_CASE} with report indicator: ${testcase_cmd}"
117     ${testcase_cmd} >$redirect
118 elif [[ $SUITE_NAME == *kubestone* ]]; then
119     if [[ $SUITE_NAME == kubestone_deployment_capacity ]]; then
120         TEST_CASE=${KUBESTONE_TEST_DIR}/deployment_capacity.yaml
121     fi
122     testcase_cmd="docker exec bottlenecks-load-master python ${KUBESTONE_TEST_DIR}/../stress_test.py -c $TEST_CASE"
123     echo "BOTTLENECKS INFO: running test case ${TEST_CASE} with report indicator: ${testcase_cmd}"
124     ${testcase_cmd} >$redirect
125 fi