add timeout handle 19/15719/6
authordongwenjuan <dong.wenjuan@zte.com.cn>
Thu, 16 Jun 2016 09:34:24 +0000 (17:34 +0800)
committerwenjuan dong <dong.wenjuan@zte.com.cn>
Thu, 30 Jun 2016 02:54:50 +0000 (02:54 +0000)
If create instance don't success, it will have a
endless loop for waiting instance to change to
`active` state.

Change-Id: I6eff3cbaefaf1ba7e30ae7fddcec62ac5c1544de
Signed-off-by: dongwenjuan <dong.wenjuan@zte.com.cn>
tests/run.sh

index 56bacca..d7240d2 100755 (executable)
@@ -166,12 +166,17 @@ stop_consumer() {
 
 wait_for_vm_launch() {
     echo "waiting for vm launch..."
-    while true
+    count=0
+    while [[ ${count} -lt 60 ]]
     do
         state=$(nova list | grep " $VM_NAME " | awk '{print $6}')
         [[ "$state" == "ACTIVE" ]] && return 0
+        [[ "$state" == "ERROR" ]] && echo "vm state is ERROR" && exit 1
+        count=$(($count+1))
         sleep 1
     done
+    echo "ERROR: time out while waiting for vm launch"
+    exit 1
 }
 
 inject_failure() {