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