Merge "Inspector design guideline"
[doctor.git] / tests / run.sh
1 #!/bin/bash -e
2 ##############################################################################
3 # Copyright (c) 2016 NEC Corporation and others.
4 #
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 ##############################################################################
10
11 [[ "${CI_DEBUG:-true}" == [Tt]rue ]] && set -x
12
13 IMAGE_URL=https://launchpad.net/cirros/trunk/0.3.0/+download/cirros-0.3.0-x86_64-disk.img
14 #if an existing image name is provided in the enviroment, use that one
15 IMAGE_NAME=${IMAGE_NAME:-cirros}
16 IMAGE_FILE="${IMAGE_NAME}.img"
17 IMAGE_FORMAT=qcow2
18 VM_NAME=doctor_vm1
19 VM_FLAVOR=m1.tiny
20 ALARM_NAME=doctor_alarm1
21 INSPECTOR_PORT=12345
22 CONSUMER_PORT=12346
23 DOCTOR_USER=doctor
24 DOCTOR_PW=doctor
25 DOCTOR_PROJECT=doctor
26 #TODO: change back to `_member_` when JIRA DOCTOR-55 is done
27 DOCTOR_ROLE=admin
28
29 SUPPORTED_INSTALLER_TYPES="apex fuel local"
30 INSTALLER_TYPE=${INSTALLER_TYPE:-local}
31 INSTALLER_IP=${INSTALLER_IP:-none}
32
33 SUPPORTED_INSPECTOR_TYPES="sample congress"
34 INSPECTOR_TYPE=${INSPECTOR_TYPE:-sample}
35 TOP_DIR=$(cd $(dirname "$0") && pwd)
36
37 ssh_opts="-o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no"
38 as_doctor_user="--os-username $DOCTOR_USER --os-password $DOCTOR_PW
39                 --os-tenant-name $DOCTOR_PROJECT"
40
41 if [[ ! "$SUPPORTED_INSTALLER_TYPES" =~ "$INSTALLER_TYPE" ]] ; then
42     echo "ERROR: INSTALLER_TYPE=$INSTALLER_TYPE is not supported."
43     exit 1
44 fi
45
46 if [[ ! "$SUPPORTED_INSPECTOR_TYPES" =~ "$INSPECTOR_TYPE" ]] ; then
47     echo "ERROR: INSPECTOR_TYPE=$INSPECTOR_TYPE is not supported."
48     exit 1
49 fi
50
51 get_installer_ip() {
52     if [[ "$INSTALLER_TYPE" == "apex" ]] ; then
53         if [[ "$INSTALLER_IP" == "none" ]] ; then
54             instack_mac=$(sudo virsh domiflist instack | awk '/default/{print $5}')
55             INSTALLER_IP=$(/usr/sbin/arp -e | grep ${instack_mac} | awk '{print $1}')
56         fi
57     elif [[ "$INSTALLER_TYPE" == "fuel" ]] ; then
58         if [[ "$INSTALLER_IP" == "none" ]] ; then
59             instack_mac=$(sudo virsh domiflist fuel-opnfv | awk '/pxebr/{print $5}')
60             INSTALLER_IP=$(/usr/sbin/arp -e | grep ${instack_mac} | awk '{print $1}')
61         fi
62     fi
63
64     if [[ "$INSTALLER_TYPE" != "local" ]] ; then
65         die_if_not_set $LINENO INSTALLER_IP "No installer IP"
66     fi
67 }
68
69 prepare_ssh_to_cloud() {
70     ssh_opts_cpu="$ssh_opts"
71
72     # get ssh key from installer node
73     if [[ "$INSTALLER_TYPE" == "apex" ]] ; then
74         sudo scp $ssh_opts root@"$INSTALLER_IP":/home/stack/.ssh/id_rsa instack_key
75         sudo chown $(whoami):$(whoami) instack_key
76         chmod 400 instack_key
77         ssh_opts_cpu+=" -i instack_key"
78     elif [[ "$INSTALLER_TYPE" == "fuel" ]] ; then
79         sshpass -p r00tme scp $ssh_opts root@${INSTALLER_IP}:.ssh/id_rsa instack_key
80         sudo chown $(whoami):$(whoami) instack_key
81         chmod 400 instack_key
82         ssh_opts_cpu+=" -i instack_key"
83     elif [[ "$INSTALLER_TYPE" == "local" ]] ; then
84         echo "INSTALLER_TYPE set to 'local'. Assuming SSH keys already exchanged with $COMPUTE_HOST"
85     fi
86 }
87
88 prepare_test_env() {
89     #TODO delete it when fuel support the configuration
90     if [[ "$INSTALLER_TYPE" == "fuel" ]] ; then
91         echo "modify the configuration..."
92         cat > set_conf.sh << 'END_TXT'
93 #!/bin/bash
94 if [ -e /etc/ceilometer/event_pipeline.yaml ]; then
95     if ! grep -q '^ *- notifier://?topic=alarm.all$' /etc/ceilometer/event_pipeline.yaml; then
96         sed -i 's|- notifier://|- notifier://?topic=alarm.all|' /etc/ceilometer/event_pipeline.yaml
97         echo "modify the ceilometer config"
98         service ceilometer-agent-notification restart
99     fi
100 else
101     echo "ceilometer event_pipeline.yaml file does not exist"
102     exit 1
103 fi
104 if [ -e /etc/nova/nova.conf ]; then
105     if ! grep -q '^notification_driver=messaging$' /etc/nova/nova.conf; then
106         sed -i -r 's/notification_driver=/notification_driver=messaging/g' /etc/nova/nova.conf
107         echo "modify nova config"
108         service nova-api restart
109     fi
110 else
111     echo "nova.conf file does not exist"
112     exit 1
113 fi
114 exit 0
115 END_TXT
116         chmod +x set_conf.sh
117         CONTROLLER_IP=$(sshpass -p r00tme ssh 2>/dev/null $ssh_opts root@${INSTALLER_IP} \
118              "fuel node | grep controller | cut -d '|' -f 5|xargs")
119         for node in $CONTROLLER_IP;do
120             scp $ssh_opts_cpu set_conf.sh "root@$node:"
121             ssh $ssh_opts_cpu "root@$node" './set_conf.sh > set_conf.log 2>&1 &'
122             sleep 1
123             scp $ssh_opts_cpu "root@$node:set_conf.log" set_conf_$node.log
124         done
125
126         if grep -q "modify the ceilometer config" set_conf_*.log ; then
127             NEED_TO_RESTORE_CEILOMETER=true
128         fi
129         if grep -q "modify nova config" set_conf_*.log ; then
130             NEED_TO_RESTORE_NOVA=true
131         fi
132
133         echo "waiting service restart..."
134         sleep 60
135     fi
136 }
137
138 restore_test_env() {
139     #TODO delete it when fuel support the configuration
140     if [[ "$INSTALLER_TYPE" == "fuel" ]] ; then
141         if ! ($NEED_TO_RESTORE_CEILOMETER || $NEED_TO_RESTORE_NOVA) ; then
142             echo "Don't need to restore config"
143             exit 0
144         fi
145
146         echo "restore the configuration..."
147         cat > restore_conf.sh << 'END_TXT'
148 #!/bin/bash
149 if @NEED_TO_RESTORE_CEILOMETER@ ; then
150     if [ -e /etc/ceilometer/event_pipeline.yaml ]; then
151         if grep -q '^ *- notifier://?topic=alarm.all$' /etc/ceilometer/event_pipeline.yaml; then
152             sed -i 's|- notifier://?topic=alarm.all|- notifier://|' /etc/ceilometer/event_pipeline.yaml
153             service ceilometer-agent-notification restart
154         fi
155     else
156         echo "ceilometer event_pipeline.yaml file does not exist"
157         exit 1
158     fi
159 fi
160 if @NEED_TO_RESTORE_NOVA@ ; then
161     if [ -e /etc/nova/nova.conf ]; then
162         if grep -q '^notification_driver=messaging$' /etc/nova/nova.conf; then
163             sed -i -r 's/notification_driver=messaging/notification_driver=/g' /etc/nova/nova.conf
164             service nova-api restart
165         fi
166     else
167         echo "nova.conf file does not exist"
168         exit 1
169     fi
170 fi
171 exit 0
172 END_TXT
173         sed -i -e "s/@NEED_TO_RESTORE_CEILOMETER@/$NEED_TO_RESTORE_CEILOMETER/" restore_conf.sh
174         sed -i -e "s/@NEED_TO_RESTORE_NOVA@/$NEED_TO_RESTORE_NOVA/" restore_conf.sh
175         chmod +x restore_conf.sh
176         for node in $CONTROLLER_IP;do
177             scp $ssh_opts_cpu restore_conf.sh "root@$node:"
178             ssh $ssh_opts_cpu "root@$node" './restore_conf.sh > restore_conf.log 2>&1 &'
179         done
180
181         echo "waiting service restart..."
182         sleep 60
183     fi
184 }
185
186 get_compute_host_info() {
187     # get computer host info which VM boot in
188     COMPUTE_HOST=$(openstack $as_doctor_user server show $VM_NAME |
189                    grep "OS-EXT-SRV-ATTR:host" | awk '{ print $4 }')
190     compute_host_in_undercloud=${COMPUTE_HOST%%.*}
191     die_if_not_set $LINENO COMPUTE_HOST "Failed to get compute hostname"
192
193     if [[ "$INSTALLER_TYPE" == "apex" ]] ; then
194         COMPUTE_USER=${COMPUTE_USER:-heat-admin}
195         COMPUTE_IP=$(sudo ssh $ssh_opts $INSTALLER_IP \
196              "source stackrc; \
197              nova show $compute_host_in_undercloud \
198              | awk '/ ctlplane network /{print \$5}'")
199     elif [[ "$INSTALLER_TYPE" == "fuel" ]] ; then
200         COMPUTE_USER=${COMPUTE_USER:-root}
201         node_id=$(echo $compute_host_in_undercloud | cut -d "-" -f 2)
202         COMPUTE_IP=$(sshpass -p r00tme ssh 2>/dev/null $ssh_opts root@${INSTALLER_IP} \
203              "fuel node|awk -F '|' -v id=$node_id '{if (\$1 == id) print \$5}' |xargs")
204     elif [[ "$INSTALLER_TYPE" == "local" ]] ; then
205         COMPUTE_USER=${COMPUTE_USER:-$(whoami)}
206         COMPUTE_IP=$(getent hosts "$COMPUTE_HOST" | awk '{ print $1 }')
207     fi
208
209     die_if_not_set $LINENO COMPUTE_IP "Could not resolve $COMPUTE_HOST. Either manually set COMPUTE_IP or enable DNS resolution."
210     echo "COMPUTE_HOST=$COMPUTE_HOST"
211     echo "COMPUTE_IP=$COMPUTE_IP"
212
213     # verify connectivity to target compute host
214     ping -c 1 "$COMPUTE_IP"
215     if [[ $? -ne 0 ]] ; then
216         die $LINENO "Can not ping to computer host"
217     fi
218
219     # verify ssh to target compute host
220     ssh $ssh_opts_cpu "$COMPUTE_USER@$COMPUTE_IP" 'exit'
221     if [[ $? -ne 0 ]] ; then
222         die $LINENO "Can not ssh to computer host"
223     fi
224 }
225
226 get_consumer_ip() {
227     local get_consumer_command="ip route get $COMPUTE_IP | awk '/ src /{print \$NF}'"
228     if [[ "$INSTALLER_TYPE" == "apex" ]] ; then
229         CONSUMER_IP=$(sudo ssh $ssh_opts root@$INSTALLER_IP \
230                       "$get_consumer_command")
231     elif [[ "$INSTALLER_TYPE" == "fuel" ]] ; then
232         CONSUMER_IP=$(sudo sshpass -p r00tme ssh $ssh_opts root@${INSTALLER_IP} \
233                       "$get_consumer_command")
234     elif [[ "$INSTALLER_TYPE" == "local" ]] ; then
235         CONSUMER_IP=`$get_consumer_command`
236     fi
237     echo "CONSUMER_IP=$CONSUMER_IP"
238
239     die_if_not_set $LINENO CONSUMER_IP "Could not get CONSUMER_IP."
240 }
241
242 download_image() {
243     #if a different name was provided for the image in the enviroment there's no need to download the image
244     use_existing_image=false
245     openstack image list | grep -q " $IMAGE_NAME " && use_existing_image=true
246
247     if [[ "$use_existing_image" == false ]] ; then
248         [ -e "$IMAGE_FILE" ] && return 0
249         wget "$IMAGE_URL" -o "$IMAGE_FILE"
250     fi
251 }
252
253 register_image() {
254     openstack image list | grep -q " $IMAGE_NAME " && return 0
255     openstack image create "$IMAGE_NAME" \
256                            --public \
257                            --disk-format "$IMAGE_FORMAT" \
258                            --container-format bare \
259                            --file "$IMAGE_FILE"
260 }
261
262 create_test_user() {
263     openstack project list | grep -q " $DOCTOR_PROJECT " || {
264         openstack project create "$DOCTOR_PROJECT"
265     }
266     openstack user list | grep -q " $DOCTOR_USER " || {
267         openstack user create "$DOCTOR_USER" --password "$DOCTOR_PW" \
268                               --project "$DOCTOR_PROJECT"
269     }
270     openstack user role list "$DOCTOR_USER" --project "$DOCTOR_PROJECT" \
271     | grep -q " $DOCTOR_ROLE " || {
272         openstack role add "$DOCTOR_ROLE" --user "$DOCTOR_USER" \
273                            --project "$DOCTOR_PROJECT"
274     }
275 }
276
277 boot_vm() {
278     # test VM done with test user, so can test non-admin
279     openstack $as_doctor_user server list | grep -q " $VM_NAME " && return 0
280     openstack $as_doctor_user server create --flavor "$VM_FLAVOR" \
281                             --image "$IMAGE_NAME" \
282                             "$VM_NAME"
283     sleep 1
284 }
285
286 create_alarm() {
287     # get vm_id as test user
288     ceilometer $as_doctor_user alarm-list | grep -q " $ALARM_NAME " && return 0
289     vm_id=$(openstack $as_doctor_user server list | grep " $VM_NAME " | awk '{print $2}')
290     # TODO(r-mibu): change notification endpoint from localhost to the consumer
291     # IP address (functest container).
292     ceilometer $as_doctor_user alarm-event-create --name "$ALARM_NAME" \
293         --alarm-action "http://localhost:$CONSUMER_PORT/failure" \
294         --description "VM failure" \
295         --enabled True \
296         --repeat-actions False \
297         --severity "moderate" \
298         --event-type compute.instance.update \
299         -q "traits.state=string::error; traits.instance_id=string::$vm_id"
300 }
301
302 start_monitor() {
303     pgrep -f "python monitor.py" && return 0
304     sudo -E python monitor.py "$COMPUTE_HOST" "$COMPUTE_IP" "$INSPECTOR_TYPE" \
305         "http://127.0.0.1:$INSPECTOR_PORT/events" > monitor.log 2>&1 &
306 }
307
308 stop_monitor() {
309     pgrep -f "python monitor.py" || return 0
310     sudo kill $(pgrep -f "python monitor.py")
311 }
312
313 congress_add_rule() {
314     name=$1
315     policy=$2
316     rule=$3
317
318     if ! openstack congress policy rule list $policy | grep -q -e "// Name: $name$" ; then
319         openstack congress policy rule create --name $name $policy "$rule"
320     fi
321 }
322
323 congress_del_rule() {
324     name=$1
325     policy=$2
326
327     if openstack congress policy rule list $policy | grep -q -e "^// Name: $name$" ; then
328         openstack congress policy rule delete $policy $name
329     fi
330 }
331
332 congress_setup_rules() {
333     congress_add_rule host_down classification \
334         'host_down(host) :-
335             doctor:events(hostname=host, type="compute.host.down", status="down")'
336
337     congress_add_rule active_instance_in_host classification \
338         'active_instance_in_host(vmid, host) :-
339             nova:servers(id=vmid, host_name=host, status="ACTIVE")'
340
341     congress_add_rule host_force_down classification \
342         'execute[nova:services.force_down(host, "nova-compute", "True")] :-
343             host_down(host)'
344
345     congress_add_rule error_vm_states classification \
346         'execute[nova:servers.reset_state(vmid, "error")] :-
347             host_down(host),
348             active_instance_in_host(vmid, host)'
349 }
350
351 start_inspector() {
352     if [[ "$INSPECTOR_TYPE" == "sample" ]] ; then
353         pgrep -f "python inspector.py" && return 0
354         python inspector.py "$INSPECTOR_PORT" > inspector.log 2>&1 &
355     elif [[ "$INSPECTOR_TYPE" == "congress" ]] ; then
356         nova_api_min_version="2.11"
357         nova_api_version=$(openstack congress datasource list | \
358                            grep nova | grep -Po "(?<='api_version': ')[^']*")
359         if ! is_set nova_api_version; then
360             nova_api_version="2.0"
361         fi
362         if [[ "$nova_api_version" < "$nova_api_min_version" ]]; then
363             die $LINENO "Congress Nova datasource API version < $nova_api_min_version ($nova_api_version)"
364         fi
365         openstack congress driver list | grep -q " doctor "
366         openstack congress datasource list | grep -q " doctor " || {
367             openstack congress datasource create doctor doctor
368         }
369         congress_setup_rules
370     fi
371 }
372
373 stop_inspector() {
374     if [[ "$INSPECTOR_TYPE" == "sample" ]] ; then
375         pgrep -f "python inspector.py" || return 0
376         kill $(pgrep -f "python inspector.py")
377     elif [[ "$INSPECTOR_TYPE" == "congress" ]] ; then
378         congress_del_rule host_force_down classification
379         congress_del_rule error_vm_states classification
380         congress_del_rule active_instance_in_host classification
381         congress_del_rule host_down classification
382     fi
383 }
384
385 start_consumer() {
386     pgrep -f "python consumer.py" && return 0
387     python consumer.py "$CONSUMER_PORT" > consumer.log 2>&1 &
388
389     # NOTE(r-mibu): create tunnel to the controller nodes, so that we can
390     # avoid some network problems dpends on infra and installers.
391     # This tunnel will be terminated by stop_consumer() or after 10 mins passed.
392     if [[ "$INSTALLER_TYPE" != "local" ]] ; then
393         if [[ "$INSTALLER_TYPE" == "apex" ]] ; then
394             CONTROLLER_IPS=$(sudo ssh $ssh_opts $INSTALLER_IP \
395                              "source stackrc; \
396                              nova list | grep ' overcloud-controller-[0-9] ' \
397                              | sed -e 's/^.*ctlplane=//' -e 's/ *|\$//'")
398         elif [[ "$INSTALLER_TYPE" == "fuel" ]] ; then
399             CONTROLLER_IPS=$(sshpass -p r00tme ssh 2>/dev/null $ssh_opts root@${INSTALLER_IP} \
400                             "fuel node | grep controller | cut -d '|' -f 5|xargs")
401         fi
402
403         die_if_not_set $LINENO CONTROLLER_IPS "Could not get CONTROLLER_IPS."
404         for ip in $CONTROLLER_IPS
405         do
406             forward_rule="-R $CONSUMER_PORT:localhost:$CONSUMER_PORT"
407             tunnel_command="sudo ssh $ssh_opts_cpu $COMPUTE_USER@$ip $forward_rule sleep 600"
408             $tunnel_command > "ssh_tunnel.${ip}.log" 2>&1 < /dev/null &
409         done
410     fi
411 }
412
413 stop_consumer() {
414     pgrep -f "python consumer.py" || return 0
415     kill $(pgrep -f "python consumer.py")
416
417     # NOTE(r-mibu): terminate tunnels to the controller nodes
418     if [[ "$INSTALLER_TYPE" != "local" ]] ; then
419         for ip in $CONTROLLER_IPS
420         do
421             forward_rule="-R $CONSUMER_PORT:localhost:$CONSUMER_PORT"
422             tunnel_command="sudo ssh $ssh_opts_cpu $COMPUTE_USER@$ip $forward_rule sleep 600"
423             kill $(pgrep -f "$tunnel_command")
424         done
425     fi
426 }
427
428 wait_for_vm_launch() {
429     echo "waiting for vm launch..."
430
431     count=0
432     while [[ ${count} -lt 60 ]]
433     do
434         state=$(openstack $as_doctor_user server list | grep " $VM_NAME " | awk '{print $6}')
435         if [[ "$state" == "ACTIVE" ]]; then
436             # NOTE(cgoncalves): sleeping for a bit to stabilize
437             # See python-openstackclient/functional/tests/compute/v2/test_server.py:wait_for_status
438             sleep 5
439             return 0
440         fi
441         if [[ "$state" == "ERROR" ]]; then
442             die $LINENO "vm state is ERROR"
443         fi
444         count=$(($count+1))
445         sleep 1
446     done
447     die $LINENO "Time out while waiting for VM launch"
448 }
449
450 inject_failure() {
451     echo "disabling network of compute host [$COMPUTE_HOST] for 3 mins..."
452     cat > disable_network.sh << 'END_TXT'
453 #!/bin/bash -x
454 dev=$(sudo ip a | awk '/ @COMPUTE_IP@\//{print $7}')
455 sleep 1
456 sudo ip link set $dev down
457 sleep 180
458 sudo ip link set $dev up
459 sleep 1
460 END_TXT
461     sed -i -e "s/@COMPUTE_IP@/$COMPUTE_IP/" disable_network.sh
462     chmod +x disable_network.sh
463     scp $ssh_opts_cpu disable_network.sh "$COMPUTE_USER@$COMPUTE_IP:"
464     ssh $ssh_opts_cpu "$COMPUTE_USER@$COMPUTE_IP" 'nohup ./disable_network.sh > disable_network.log 2>&1 &'
465 }
466
467 calculate_notification_time() {
468     detected=$(grep "doctor monitor detected at" monitor.log | awk '{print $10}')
469     notified=$(grep "doctor consumer notified at" consumer.log | awk '{print $10}')
470     if ! grep -q "doctor consumer notified at" consumer.log ; then
471         die $LINENO "Consumer hasn't received fault notification."
472     fi
473     echo "$notified $detected" | \
474         awk '{
475             d = $1 - $2;
476             if (d < 1 && d > 0) { print d " OK"; exit 0 }
477             else { print d " NG"; exit 1 }
478         }'
479 }
480
481 check_host_status() {
482     expected_state=$1
483
484     host_status_line=$(openstack $as_doctor_user --os-compute-api-version 2.16 \
485                        server show $VM_NAME | grep "host_status")
486     host_status=$(echo $host_status_line | awk '{print $4}')
487     die_if_not_set $LINENO host_status "host_status not reported by: nova show $VM_NAME"
488     if [[ "$expected_state" =~ "$host_status" ]] ; then
489         echo "$VM_NAME showing host_status: $host_status"
490     else
491         die $LINENO "host_status:$host_status not equal to expected_state: $expected_state"
492     fi
493 }
494
495 cleanup() {
496     set +e
497     echo "cleanup..."
498     stop_monitor
499     stop_inspector
500     stop_consumer
501
502     echo "waiting disabled compute host back to be enabled..."
503     python ./nova_force_down.py "$COMPUTE_HOST" --unset
504     sleep 240
505     check_host_status "UP"
506     scp $ssh_opts_cpu "$COMPUTE_USER@$COMPUTE_IP:disable_network.log" .
507
508     openstack $as_doctor_user server list | grep -q " $VM_NAME " && openstack $as_doctor_user server delete "$VM_NAME"
509     sleep 1
510     alarm_id=$(ceilometer $as_doctor_user alarm-list | grep " $ALARM_NAME " | awk '{print $2}')
511     sleep 1
512     [ -n "$alarm_id" ] && ceilometer $as_doctor_user alarm-delete "$alarm_id"
513     sleep 1
514
515     image_id=$(openstack image list | grep " $IMAGE_NAME " | awk '{print $2}')
516     sleep 1
517     #if an existing image was used, there's no need to remove it here
518     if [[ "$use_existing_image" == false ]] ; then
519         [ -n "$image_id" ] && openstack image delete "$image_id"
520     fi
521     openstack role remove "$DOCTOR_ROLE" --user "$DOCTOR_USER" \
522                               --project "$DOCTOR_PROJECT"
523     openstack project delete "$DOCTOR_PROJECT"
524     openstack user delete "$DOCTOR_USER"
525
526     restore_test_env
527 }
528
529
530 echo "Note: doctor/tests/run.sh has been executed."
531
532 trap cleanup EXIT
533
534 source $TOP_DIR/functions-common
535
536 echo "preparing test env..."
537 get_installer_ip
538 prepare_ssh_to_cloud
539 prepare_test_env
540
541 echo "preparing VM image..."
542 download_image
543 register_image
544
545 echo "creating test user..."
546 create_test_user
547
548 echo "creating VM..."
549 boot_vm
550 wait_for_vm_launch
551
552 echo "get computer host info..."
553 get_compute_host_info
554
555 echo "creating alarm..."
556 #TODO: change back to use, network problems depends on infra and installers
557 #get_consumer_ip
558 create_alarm
559
560 echo "starting doctor sample components..."
561 start_inspector
562 start_monitor
563 start_consumer
564
565 sleep 60
566 echo "injecting host failure..."
567 inject_failure
568 sleep 60
569
570 check_host_status "(DOWN|UNKNOWN)"
571 calculate_notification_time
572
573 echo "done"