Before deleting the instance, check if the instance exists
[doctor.git] / tests / run.sh
index 00dcabc..a2656aa 100755 (executable)
@@ -1,4 +1,4 @@
-#!/bin/bash -ex
+#!/bin/bash -e
 ##############################################################################
 # Copyright (c) 2016 NEC Corporation and others.
 #
@@ -8,6 +8,8 @@
 # http://www.apache.org/licenses/LICENSE-2.0
 ##############################################################################
 
+[[ "${CI_DEBUG:-true}" == "true" ]] && set -x
+
 IMAGE_URL=https://launchpad.net/cirros/trunk/0.3.0/+download/cirros-0.3.0-x86_64-disk.img
 IMAGE_NAME=cirros
 IMAGE_FILE="${IMAGE_NAME}.img"
@@ -224,7 +226,7 @@ cleanup() {
 
     python ./nova_force_down.py "$COMPUTE_HOST" --unset
     sleep 1
-    nova delete "$VM_NAME"
+    nova list | grep -q " $VM_NAME " && nova delete "$VM_NAME"
     sleep 1
     alarm_id=$(ceilometer alarm-list | grep " $ALARM_NAME " | awk '{print $2}')
     sleep 1