2 ##############################################################################
3 # Copyright (c) 2015 Huawei Technologies Co.,Ltd and others.
5 # All rights reserved. This program and the accompanying materials
6 # are made available under the terms of the Apache License, Version 2.0
7 # which accompanies this distribution, and is available at
8 # http://www.apache.org/licenses/LICENSE-2.0
9 ##############################################################################
12 GERRIT_REFSPEC_DEBUG=$1
14 echo "vstf DEBUG test"
15 echo "vstf workflow goes here"
17 bottlenecks_env_prepare()
19 if [ -d $BOTTLENECKS_REPO_DIR ]; then
20 rm -rf ${BOTTLENECKS_REPO_DIR}
23 mkdir -p ${BOTTLENECKS_REPO_DIR}
24 git config --global http.sslVerify false
25 git clone ${BOTTLENECKS_REPO} ${BOTTLENECKS_REPO_DIR}
26 if [ x"$GERRIT_REFSPEC_DEBUG" != x ]; then
27 cd ${BOTTLENECKS_REPO_DIR}
28 git fetch $BOTTLENECKS_REPO $GERRIT_REFSPEC_DEBUG && git checkout FETCH_HEAD
32 #obtain installer(openstack) IP, etc, use rubbos's temporarily, later we can amend this
33 source $BOTTLENECKS_REPO_DIR/rubbos/rubbos_scripts/1-1-1/scripts/env_preparation.sh
38 echo "[INFO]Begin to clean up vstf heat-stack ,glance images and keypairs"
39 #heat stack-delete bottlenecks
41 if heat stack-list; then
42 for stack in $(heat stack-list | grep -e " vstf " | awk '{print $2}'); do
43 echo "[INFO]clean up stack $stack"
44 heat stack-delete $stack || true
49 echo "begin to clean the image"
50 glance image-delete ${MANAGER_IMAGE_NAME};glance image-delete "${TARGET_IMAGE_NAME}";glance image-delete "${TESTER_IMAGE_NAME}"
51 if glance image-list; then
52 for image in $(glance image-list | grep -e "${MANAGER_IMAGE_NAME}" | awk '{print $2}'); do
53 echo "[INFO]clean up image $image"
54 glance image-delete $image || true
56 for image in $(glance image-list | grep -e "${TARGET_IMAGE_NAME}" | awk '{print $2}'); do
57 echo "[INFO]clean up image $image"
58 glance image-delete $image || true
60 for image in $(glance image-list | grep -e "${TESTER_IMAGE_NAME}" | awk '{print $2}'); do
61 echo "[INFO]clean up image $image"
62 glance image-delete $image || true
66 if nova keypair-list; then
67 for key in $(nova keypair-list | grep -e $KEY_NAME | awk '{print $2}'); do
68 echo "[INFO]clean up key $key"
69 nova keypair-delete $key || true
73 #check the default flavor m1.large existing
74 if nova flavor-list; then
75 flag=`nova flavor-list | grep "m1.large "`
76 echo "[INFO]the flavor m1.large num is $flag"
80 rm -rf /tmp/vstf-manager.img;rm -rf /tmp/vstf-agent.img ;rm -rf /tmp/vstf-agent_1.img
87 echo "[INFO]download vstf images"
88 #download vstf-manager and vstf-agent image
89 #curl --connect-timeout 10 -o /tmp/vstf-manager.img $MANAGER_IMAGE_URL -v
90 #curl --connect-timeout 10 -o /tmp/vstf-agent.img $AGENT_IMAGE_URL -v
91 curl --connect-timeout 10 -o /tmp/vstf-manager.img $MANAGER_IMAGE_URL -v
92 curl --connect-timeout 10 -o /tmp/vstf-agent.img $MANAGER_IMAGE_URL -v
93 curl --connect-timeout 10 -o /tmp/vstf-agent_1.img $MANAGER_IMAGE_URL -v
94 #echo "begin to test downloading from vstf directory!!!!!!"
95 #curl --connect-timeout 10 -o /tmp/vstf-test.txt
96 #echo "begin to cat /tmp/vstf-test.txt vstf directory!!!!!!"
97 #cat /tmp/vstf-test.txt
99 echo "[INFO]register vstf manager and agent images"
100 result=$(glance image-create \
101 --name $MANAGER_IMAGE_NAME \
102 --disk-format qcow2 \
103 --container-format bare \
104 --file /tmp/vstf-manager.img)
105 echo "Manager image register result $result."
107 result=$(glance image-create \
108 --name $TESTER_IMAGE_NAME \
109 --disk-format qcow2 \
110 --container-format bare \
111 --file /tmp/vstf-agent.img)
112 echo "Agent image register result $result."
114 result=$(glance image-create \
115 --name $TARGET_IMAGE_NAME \
116 --disk-format qcow2 \
117 --container-format bare \
118 --file /tmp/vstf-agent_1.img)
119 echo "Agent image register result $result."
123 rm -rf /tmp/vstf-manager.img;rm -rf /tmp/vstf-agent.img ;rm -rf /tmp/vstf-agent_1.img
126 #vstf logic function here
127 vstf_create_heat_template()
129 echo "create vstf instance using heat template"
130 echo "upload keypair"
131 nova keypair-add --pub_key $KEY_PATH/bottlenecks_key.pub $KEY_NAME
133 echo "use heat template to create stack"
135 heat stack-create vstf -f ${TEMPLATE_NAME}
139 wait_heat_stack_complete()
144 status=$(heat stack-list | grep vstf | awk '{print $6}')
145 if [ x$status = x"CREATE_COMPLETE" ]; then
146 echo "vstf stacke create complete"
148 nova list | grep vstf-
150 elif [ x$status = x"CREATE_FAILED" ]; then
151 echo "bottlenecks stacke create failed !!!"
156 if [ "$BOTTLENECKS_DEBUG" == "True" ]; then
158 nova list | grep vstf-
159 for i in $(nova list | grep "vstf-" | grep ERROR | awk '{print $2}')
166 if [[ $retry -ge $1 ]];then
167 echo "Heat vstf stack create timeout, status $status !!!"
174 vstf_check_instance_ok()
176 wait_heat_stack_complete 120
184 bash -x ./launch_vstf.sh
191 bash -x ./vstf_test.sh
196 echo "bottlenecks vstf: create instances with heat template"
198 BOTTLENECKS_REPO=https://gerrit.opnfv.org/gerrit/bottlenecks
199 BOTTLENECKS_REPO_DIR=/tmp/opnfvrepo_vstf/bottlenecks
201 MANAGER_IMAGE_URL=http://artifacts.opnfv.org/bottlenecks/vstf-manager-new.img
202 AGENT_IMAGE_URL=http://artifacts.opnfv.org/bottlenecks/vstf-agent-new.img
203 #MANAGER_IMAGE_URL=http://artifacts.opnfv.org/bottlenecks/rubbos/bottlenecks-trusty-server.img
204 #AGENT_IMAGE_URL=http://artifacts.opnfv.org/bottlenecks/rubbos/bottlenecks-trusty-server.img
205 MANAGER_IMAGE_NAME="vstf-manager"
206 TESTER_IMAGE_NAME="vstf-tester"
207 TARGET_IMAGE_NAME="vstf-target"
209 KEY_PATH=$BOTTLENECKS_REPO_DIR/utils/infra_setup/bottlenecks_key
210 HOT_PATH=$BOTTLENECKS_REPO_DIR/utils/infra_setup/heat_template/vstf_heat_template
212 #use the default openstack flavor m1.large
213 FLAVOR_NAME="m1.large"
214 TEMPLATE_NAME=bottleneck_vstf.yaml
215 PUBLIC_NET_NAME=net04_ext
218 bottlenecks_env_prepare
222 vstf_create_heat_template
223 vstf_check_instance_ok
231 echo "[INFO]bottleneck vstf testsuite done ,results in the directory ${HOT_PATH}/result"
232 echo "[INFO]Begin to clean up the vstf heat-stack and image"