@@ -31,11 +31,12 @@ TEMPEST_DIR=$DEST/tempest
3131NOVA_CONF=/etc/nova/nova.conf
3232IMAGE_NAME=${IMAGE_NAME:- " cirros-0.3.5-x86_64-disk" }
3333VM_NAME=${VM_NAME:- " testVM" }
34+ SNAPSHOT_NAME=${SNAPSHOT_NAME:- " testSnapshot" }
35+ SNAPSHOT_VM_NAME=${SNAPSHOT_VM_NAME:- " testSnapshot_VM" }
3436JOURNAL_DIR=/var/log/journal
35- VGPU_TEST_LOG_DIR =${VGPU_TEST_LOG_DIR :- " /opt/stack/workspace/test_vgpu/logs" }
37+ OPENSTACK_LOGS =${OPENSTACK_LOGS :- " /opt/stack/workspace/test_vgpu/logs" }
3638TMP_LOG_DIR=/tmp/openstack
3739
38-
3940SLEEP_TIME_GAP=3
4041SLEEP_MAX_TRIES=40
4142
@@ -56,17 +57,42 @@ on_exit()
5657 do
5758 sudo journalctl --unit $service > $TMP_LOG_DIR /$service " .log" ;
5859 done
59- cp $TMP_LOG_DIR /* $VGPU_TEST_LOG_DIR /
60+ cp $TMP_LOG_DIR /* $OPENSTACK_LOGS /
6061 echo " ###################Clean environment if requested#####################"
6162 if [ $keep_env != " true" ]; then
6263 pushd $DEVSTACK_PATH /
63- nova delete $VM_NAME
64+ nova delete $VM_NAME $SNAPSHOT_VM_NAME
65+ openstack image delete $SNAPSHOT_NAME
6466 ./clean.sh
6567 popd
68+ rm $DEVSTACK_PATH -rf
69+
6670 fi
6771 set +x
6872}
6973
74+ waiting_vm_active ()
75+ {
76+ count=0
77+ vm_name=$1
78+ while :
79+ do
80+ echo " Waitting to VM active"
81+ sleep $SLEEP_TIME_GAP
82+ count=$(( count + 1 ))
83+ vm_state=$( nova show $vm_name | grep -w ' status' | awk ' {print $4}' )
84+ if [ $vm_state = " ERROR" ]; then
85+ error_log=$error_log " \n\tVM create failed"
86+ exit 1
87+ elif [ $vm_state = " ACTIVE" ]; then
88+ break
89+ elif [ $count -gt $SLEEP_MAX_TRIES ]; then
90+ error_log=$error_log " \n\tVM can not reach active status"
91+ exit 1
92+ fi
93+ done
94+ }
95+
7096trap on_exit EXIT
7197
7298error_log=" VGPU test failed with the following errors: "
@@ -77,6 +103,13 @@ _SSH_OPTIONS="\
77103 -o UserKnownHostsFile=/dev/null \
78104 -i /opt/stack/.ssh/id_rsa"
79105
106+ pushd $ROOT_DIR
107+ rm $DEVSTACK_PATH -rf
108+ git clone https://github.com/openstack-dev/devstack.git
109+ popd
110+
111+ cp $ROOT_DIR /local.conf $DEVSTACK_PATH
112+
80113DOM0_IP=$( grep XENAPI_CONNECTION_URL ${DEVSTACK_PATH} /local.conf | cut -d' =' -f2 | sed ' s/[^0-9,.]*//g' )
81114
82115echo " Dom0 IP is: $DOM0_IP "
@@ -107,16 +140,21 @@ echo "###################Update openstack repositories#####################"
107140PROJECT_LIST=$( echo $ZUUL_CHANGES | tr ' ^' ' \n' | cut -d: -f1 | cut -d/ -f2 | sort | uniq)
108141
109142pushd ${DEST}
143+
144+ # remove requirements folder because it contains run time modifications
145+ rm requirements -rf
146+
110147for dir in ${DEST} /*
111148do
112149 if [ -d " ${dir} " ] ; then
113150 echo " check ${dir} "
114151 pushd ${dir}
115152 if [ -d .git ]; then
116153 echo " update repository ${dir} "
117- git checkout master
118- if ! git diff-index --quiet HEAD --; then
119- git checkout *
154+ cur_branch=$( git branch | grep \* | cut -d ' ' -f2)
155+ if [ $cur_branch != ' master' ]; then
156+ git checkout master
157+ git branch -D $cur_branch
120158 fi
121159 git pull --ff origin master
122160
@@ -155,14 +193,20 @@ done
155193END_OF_REQ_VGPU_TYPE
156194)
157195
158- echo " ###################Devstack start stack#####################"
159196pushd $DEVSTACK_PATH /
160197if ! grep " enabled_vgpu_types=" ${DEVSTACK_PATH} /local.conf; then
161198 echo " [devices]" >> ${DEVSTACK_PATH} /local.conf
162199 echo " enabled_vgpu_types = $first_vgpu_type " >> ${DEVSTACK_PATH} /local.conf
163200fi
201+ echo " ###################Set image handler to remote stream#####################"
202+ if ! grep " image_handler = vdi_remote_stream" ${DEVSTACK_PATH} /local.conf; then
203+ echo " [xenserver]" >> ${DEVSTACK_PATH} /local.conf
204+ echo " image_handler = vdi_remote_stream" >> ${DEVSTACK_PATH} /local.conf
205+ fi
206+
164207sudo find $JOURNAL_DIR -name " *.journal" -exec rm {} \;
165208sudo systemctl restart systemd-journald
209+ echo " ###################Devstack start stack#####################"
166210./stack.sh
167211popd
168212
@@ -182,23 +226,7 @@ prv_net=$(openstack network list | grep "private" | awk '{print $2}')
182226nova boot --image $IMAGE_NAME --flavor 1 --nic net-id=$prv_net $VM_NAME
183227
184228nova_vm_id=$( nova show $VM_NAME | grep -w ' id' | awk ' {print $4}' )
185- count=0
186- while :
187- do
188- echo " Waitting to VM active"
189- sleep $SLEEP_TIME_GAP
190- count=$(( count + 1 ))
191- vm_state=$( nova show $VM_NAME | grep -w ' status' | awk ' {print $4}' )
192- if [ $vm_state = " ERROR" ]; then
193- error_log=$error_log " \n\tVM create failed"
194- break
195- elif [ $vm_state = " ACTIVE" ]; then
196- break
197- elif [ $count -gt $SLEEP_MAX_TRIES ]; then
198- error_log=$error_log " \n\tVM can not reach active status"
199- break
200- fi
201- done
229+ waiting_vm_active $VM_NAME
202230
203231echo " ###################Check VGPU create status#####################"
204232if [ $vm_state = " ACTIVE" ]; then
@@ -215,10 +243,22 @@ END_OF_VGPU_CONFIRM
215243fi
216244
217245if [ -n " $result " ]; then
218- echo " VGPU create success"
246+ echo $VGPU_CREATE_SUCCESS_FLAG
247+ echo " ###################Check LVM image upload status#####################"
248+ nova image-create --poll $VM_NAME $SNAPSHOT_NAME
249+ if ! openstack image show $SNAPSHOT_NAME ; then
250+ error_log=$error_log " \n\tImage create failed!"
251+ echo $error_log
252+ exit 1
253+ fi
254+ nova boot --image $SNAPSHOT_NAME --flavor 1 --nic net-id=$prv_net $SNAPSHOT_VM_NAME
255+ waiting_vm_active $SNAPSHOT_VM_NAME
219256else
220- error_log=$error_log " \n\tVGPU create failed"
257+ error_log=$error_log " \n\tVGPU create failed! "
221258 echo $error_log
259+ exit 1
222260fi
223261
262+
263+
224264set +ex
0 commit comments