summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/monitor.py7
-rwxr-xr-xtests/run.sh54
2 files changed, 49 insertions, 12 deletions
diff --git a/tests/monitor.py b/tests/monitor.py
index 953ef09b..bc22b1ea 100644
--- a/tests/monitor.py
+++ b/tests/monitor.py
@@ -28,10 +28,11 @@ class DoctorMonitorSample(object):
def __init__(self, args):
self.hostname = args.hostname
self.inspector = args.inspector
- self.ip_addr = socket.gethostbyname(self.hostname)
+ self.ip_addr = args.ip or socket.gethostbyname(self.hostname)
def start_loop(self):
- print "start ping to host %s" % self.hostname
+ print "start ping to host %(h)s (ip=$(i)s)" % {'h': self.hostname,
+ 'i': self.ip_addr}
sock = socket.socket(socket.AF_INET, socket.SOCK_RAW,
socket.IPPROTO_ICMP)
sock.settimeout(self.timeout)
@@ -57,6 +58,8 @@ def get_args():
parser = argparse.ArgumentParser(description='Doctor Sample Monitor')
parser.add_argument('hostname', metavar='HOSTNAME', type=str, nargs='?',
help='a hostname to monitor connectivity')
+ parser.add_argument('ip', metavar='IP', type=str, nargs='?',
+ help='an IP address to monitor connectivity')
parser.add_argument('inspector', metavar='INSPECTOR', type=str, nargs='?',
help='inspector url to report error',
default='http://127.0.0.1:12345/events')
diff --git a/tests/run.sh b/tests/run.sh
index d6cc3cbd..5c58463f 100755
--- a/tests/run.sh
+++ b/tests/run.sh
@@ -20,7 +20,8 @@ CONSUMER_PORT=12346
INSTALLER_TYPE=${INSTALLER_TYPE:-apex}
INSTALLER_IP=${INSTALLER_IP:-none}
-COMPUTE_HOST=${COMPUTE_HOST:-none}
+COMPUTE_HOST=${COMPUTE_HOST:-overcloud-novacompute-0}
+COMPUTE_IP=${COMPUTE_IP:-none}
ssh_opts="-o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no"
if [[ "$INSTALLER_TYPE" != "apex" ]] ; then
@@ -33,11 +34,11 @@ if [[ "$INSTALLER_IP" == "none" ]] ; then
INSTALLER_IP=$(/usr/sbin/arp -e | grep ${instack_mac} | awk '{print $1}')
fi
-if [[ "$COMPUTE_HOST" == "none" ]] ; then
- COMPUTE_HOST=$(sudo ssh $ssh_opts $INSTALLER_IP \
- "source stackrc; \
- nova show overcloud-novacompute-0 \
- | awk '/ ctlplane network /{print \$5}'")
+if [[ "$COMPUTE_IP" == "none" ]] ; then
+ COMPUTE_IP=$(sudo ssh $ssh_opts $INSTALLER_IP \
+ "source stackrc; \
+ nova show $COMPUTE_HOST \
+ | awk '/ ctlplane network /{print \$5}'")
fi
download_image() {
@@ -77,8 +78,8 @@ create_alarm() {
start_monitor() {
pgrep -f "python monitor.py" && return 0
- sudo python monitor.py "$COMPUTE_HOST" "http://127.0.0.1:$INSPECTOR_PORT/events" > monitor.log 2>&1 &
- MONITOR_PID=$!
+ sudo python monitor.py "$COMPUTE_HOST" "$COMPUTE_IP" \
+ "http://127.0.0.1:$INSPECTOR_PORT/events" > monitor.log 2>&1 &
}
stop_monitor() {
@@ -126,7 +127,7 @@ inject_failure() {
dev=$(/usr/sbin/ip route | awk '/^default/{print $5}')
sleep 1
echo sudo ip link set $dev down
-sleep 180
+sleep 120
echo sudo ip link set $dev up
sleep 1
END_TXT
@@ -146,24 +147,57 @@ calculate_notification_time() {
awk '{d = $1 - $2; if (d < 1 ) print d " OK"; else print d " NG"}'
}
+cleanup() {
+ set +e
+ echo "cleanup..."
+ stop_monitor
+ stop_inspector
+ stop_consumer
+
+ nova service-force-down --unset "$COMPUTE_HOST" nova-compute
+ sleep 1
+ nova delete "$VM_NAME"
+ sleep 1
+ alarm_id=$(ceilometer alarm-list | grep " $ALARM_NAME " | awk '{print $2}')
+ sleep 1
+ [ -n "$alarm_id" ] && ceilometer alarm-delete "$alarm_id"
+ sleep 1
+ image_id=$(glance image-list | grep " $IMAGE_NAME " | awk '{print $2}')
+ sleep 1
+ [ -n "$image_id" ] && glance image-delete "$image_id"
+ #TODO: add host status check via nova admin api
+ echo "waiting disabled compute host back to be enabled..."
+ sleep 180
+}
+
+
echo "Note: doctor/tests/run.sh has been executed."
-exit 0
+ping -c 1 "$COMPUTE_IP"
+
+trap cleanup ERR
+
+echo "preparing VM image..."
download_image
register_image
+echo "starting doctor sample components..."
start_monitor
start_inspector
start_consumer
+echo "creating VM and alarm..."
boot_vm
create_alarm
wait_for_vm_launch
sleep 60
+echo "injecting host failure..."
inject_failure
sleep 10
calculate_notification_time
+cleanup
+
echo "done"