29129118697444d9fe2f673f75d730fe7c0f5ba1
[releng.git] / jjb / cperf / cperf-robot-netvirt-csit.sh
1 #!/usr/bin/env bash
2
3 set -o errexit
4 set -o nounset
5 set -o pipefail
6
7 if [ "$OS_VERSION" == 'master' ]; then
8   FULL_OS_VER='master'
9 else
10   FULL_OS_VER="stable/${OS_VERSION}"
11 fi
12
13 if [ "$ODL_BRANCH" == 'master' ]; then
14   ODL_STREAM='flourine'
15 else
16   ODL_STREAM=${ODL_BRANCH}
17 fi
18
19 echo "ODL Branch set: ${ODL_BRANCH} and OS Version is ${FULL_OS_VER}"
20
21 sudo rm -rf releng
22 git clone https://gerrit.opnfv.org/gerrit/releng.git
23 REL_PATH='releng/jjb/cperf'
24
25 # NOTE: sourcing overcloudrc unsets any variable with OS_ prefix
26 source ${WORKSPACE}/overcloudrc
27 # note SDN_CONTROLLER_IP is set in overcloudrc, which is the VIP
28 # for admin/public network (since we are running single network deployment)
29
30 NUM_CONTROL_NODES=$(python ${REL_PATH}/parse-node-yaml.py num_nodes --file $NODE_FILE_PATH)
31 NUM_COMPUTE_NODES=$(python ${REL_PATH}/parse-node-yaml.py num_nodes --node-type compute --file $NODE_FILE_PATH)
32
33 echo "Number of Control nodes found: ${NUM_CONTROL_NODES}"
34 echo "Number of Compute nodes found: ${NUM_COMPUTE_NODES}"
35
36 idx=1
37 EXTRA_ROBOT_ARGS=""
38 for idx in `seq 1 $NUM_CONTROL_NODES`; do
39   CONTROLLER_IP=$(python ${REL_PATH}/parse-node-yaml.py get_value -k address --node-number ${idx} --file $NODE_FILE_PATH)
40   EXTRA_ROBOT_ARGS+=" -v ODL_SYSTEM_${idx}_IP:${CONTROLLER_IP} \
41                       -v OS_CONTROL_NODE_${idx}_IP:${CONTROLLER_IP} \
42                       -v ODL_SYSTEM_${idx}_IP:${CONTROLLER_IP} \
43                       -v HA_PROXY_${idx}_IP:${SDN_CONTROLLER_IP}"
44 done
45
46 idx=1
47 for idx in `seq 1 $NUM_COMPUTE_NODES`; do
48   COMPUTE_IP=$(python ${REL_PATH}/parse-node-yaml.py get_value -k address --node-type compute --node-number ${idx} --file $NODE_FILE_PATH)
49   EXTRA_ROBOT_ARGS+=" -v OS_COMPUTE_${idx}_IP:${COMPUTE_IP}"
50 done
51
52 CONTROLLER_1_IP=$(python ${REL_PATH}/parse-node-yaml.py get_value -k address --node-number 1 --file $NODE_FILE_PATH)
53
54 if [ "$ODL_CONTAINERIZED" == 'false' ]; then
55   EXTRA_ROBOT_ARGS+=" -v NODE_KARAF_COUNT_COMMAND:'ps axf | grep org.apache.karaf | grep -v grep | wc -l || echo 0' \
56                       -v NODE_START_COMMAND:'sudo systemctl start opendaylight_api' \
57                       -v NODE_KILL_COMMAND:'sudo systemctl stop opendaylight_api' \
58                       -v NODE_STOP_COMMAND:'sudo systemctl stop opendaylight_api' \
59                       -v NODE_FREEZE_COMMAND:'sudo systemctl stop opendaylight_api' "
60 else
61   EXTRA_ROBOT_ARGS+=" -v NODE_KARAF_COUNT_COMMAND:\"sudo docker exec opendaylight_api /bin/bash -c 'ps axf | \
62                                 grep org.apache.karaf | grep -v grep | wc -l' || echo 0\" \
63                       -v NODE_START_COMMAND:\"sudo docker start opendaylight_api\" \
64                       -v NODE_KILL_COMMAND:\"sudo docker stop opendaylight_api\" \
65                       -v NODE_STOP_COMMAND:\"sudo docker stop opendaylight_api\" \
66                       -v NODE_FREEZE_COMMAND:\"sudo docker stop opendaylight_api\" "
67 fi
68
69 robot_cmd="pybot \
70   --removekeywords wuks \
71   --xunit robotxunit.xml \
72   -c critical \
73   -e exclude \
74   -d /tmp/robot_results \
75   -v BUNDLEFOLDER:/opt/opendaylight \
76   -v CONTROLLER_USER:heat-admin \
77   -v DEFAULT_LINUX_PROMPT:\$ \
78   -v DEFAULT_LINUX_PROMPT_STRICT:]\$ \
79   -v DEFAULT_USER:heat-admin \
80   -v DEVSTACK_DEPLOY_PATH:/tmp \
81   -v HA_PROXY_IP:$SDN_CONTROLLER_IP \
82   -v NUM_ODL_SYSTEM:$NUM_CONTROL_NODES \
83   -v NUM_OS_SYSTEM:$NUM_CONTROL_NODES \
84   -v NUM_TOOLS_SYSTEM:0 \
85   -v ODL_SNAT_MODE:conntrack \
86   -v ODL_STREAM:$ODL_STREAM \
87   -v ODL_SYSTEM_IP:$CONTROLLER_1_IP \
88   -v OS_CONTROL_NODE_IP:$CONTROLLER_1_IP \
89   -v OPENSTACK_BRANCH:$FULL_OS_VER \
90   -v OS_USER:heat-admin \
91   -v ODL_ENABLE_L3_FWD:yes \
92   -v ODL_SYSTEM_USER:heat-admin \
93   -v ODL_SYSTEM_PROMPT:\$ \
94   -v PRE_CLEAN_OPENSTACK_ALL:True \
95   -v PUBLIC_PHYSICAL_NETWORK:datacentre \
96   -v RESTCONFPORT:8081 \
97   -v ODL_RESTCONF_USER:admin \
98   -v ODL_RESTCONF_PASSWORD:$SDN_CONTROLLER_PASSWORD \
99   -v KARAF_PROMPT_LOGIN:'opendaylight-user' \
100   -v KARAF_PROMPT:'opendaylight-user.*root.*>' \
101   -v SECURITY_GROUP_MODE:stateful \
102   -v USER:heat-admin \
103   -v USER_HOME:\$HOME \
104   -v TOOLS_SYSTEM_IP:'' \
105   -v NODE_ROLE_INDEX_START:0 \
106   -v WORKSPACE:/tmp  \
107   $EXTRA_ROBOT_ARGS \
108   -v of_port:6653 "
109
110 echo "Robot command set: ${robot_cmd}"
111 echo "Running robot..."
112 docker run -i --net=host \
113   -v ${WORKSPACE}/id_rsa:/tmp/id_rsa \
114   -v ${WORKSPACE}/overcloudrc:/tmp/overcloudrc \
115   opnfv/cperf:$DOCKER_TAG \
116   /bin/bash -c "source /tmp/overcloudrc; mkdir -p \$HOME/.ssh; cp /tmp/id_rsa \$HOME/.ssh; \
117   $robot_cmd /home/opnfv/repos/odl_test/csit/suites/openstack/connectivity/l2.robot;"