Introducing common functions
[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 print_log() {
303     log_file=$1
304     echo "$log_file:"
305     sed -e 's/^/    /' "$log_file"
306 }
307
308 start_monitor() {
309     pgrep -f "python monitor.py" && return 0
310     sudo -E python monitor.py "$COMPUTE_HOST" "$COMPUTE_IP" "$INSPECTOR_TYPE" \
311         "http://127.0.0.1:$INSPECTOR_PORT/events" > monitor.log 2>&1 &
312 }
313
314 stop_monitor() {
315     pgrep -f "python monitor.py" || return 0
316     sudo kill $(pgrep -f "python monitor.py")
317     print_log monitor.log
318 }
319
320 congress_add_rule() {
321     name=$1
322     policy=$2
323     rule=$3
324
325     if ! openstack congress policy rule list $policy | grep -q -e "// Name: $name$" ; then
326         openstack congress policy rule create --name $name $policy "$rule"
327     fi
328 }
329
330 congress_del_rule() {
331     name=$1
332     policy=$2
333
334     if openstack congress policy rule list $policy | grep -q -e "^// Name: $name$" ; then
335         openstack congress policy rule delete $policy $name
336     fi
337 }
338
339 congress_setup_rules() {
340     congress_add_rule host_down classification \
341         'host_down(host) :-
342             doctor:events(hostname=host, type="compute.host.down", status="down")'
343
344     congress_add_rule active_instance_in_host classification \
345         'active_instance_in_host(vmid, host) :-
346             nova:servers(id=vmid, host_name=host, status="ACTIVE")'
347
348     congress_add_rule host_force_down classification \
349         'execute[nova:services.force_down(host, "nova-compute", "True")] :-
350             host_down(host)'
351
352     congress_add_rule error_vm_states classification \
353         'execute[nova:servers.reset_state(vmid, "error")] :-
354             host_down(host),
355             active_instance_in_host(vmid, host)'
356 }
357
358 start_inspector() {
359     if [[ "$INSPECTOR_TYPE" == "sample" ]] ; then
360         pgrep -f "python inspector.py" && return 0
361         python inspector.py "$INSPECTOR_PORT" > inspector.log 2>&1 &
362     elif [[ "$INSPECTOR_TYPE" == "congress" ]] ; then
363         nova_api_min_version="2.11"
364         nova_api_version=$(openstack congress datasource list | \
365                            grep nova | grep -Po "(?<='api_version': ')[^']*")
366         if ! is_set nova_api_version; then
367             nova_api_version="2.0"
368         fi
369         if [[ "$nova_api_version" < "$nova_api_min_version" ]]; then
370             die $LINENO "Congress Nova datasource API version < $nova_api_min_version ($nova_api_version)"
371         fi
372         openstack congress driver list | grep -q " doctor "
373         openstack congress datasource list | grep -q " doctor " || {
374             openstack congress datasource create doctor doctor
375         }
376         congress_setup_rules
377     fi
378 }
379
380 stop_inspector() {
381     if [[ "$INSPECTOR_TYPE" == "sample" ]] ; then
382         pgrep -f "python inspector.py" || return 0
383         kill $(pgrep -f "python inspector.py")
384         print_log inspector.log
385     elif [[ "$INSPECTOR_TYPE" == "congress" ]] ; then
386         congress_del_rule host_force_down classification
387         congress_del_rule error_vm_states classification
388         congress_del_rule active_instance_in_host classification
389         congress_del_rule host_down classification
390     fi
391 }
392
393 start_consumer() {
394     pgrep -f "python consumer.py" && return 0
395     python consumer.py "$CONSUMER_PORT" > consumer.log 2>&1 &
396
397     # NOTE(r-mibu): create tunnel to the controller nodes, so that we can
398     # avoid some network problems dpends on infra and installers.
399     # This tunnel will be terminated by stop_consumer() or after 10 mins passed.
400     if [[ "$INSTALLER_TYPE" != "local" ]] ; then
401         if [[ "$INSTALLER_TYPE" == "apex" ]] ; then
402             CONTROLLER_IPS=$(sudo ssh $ssh_opts $INSTALLER_IP \
403                              "source stackrc; \
404                              nova list | grep ' overcloud-controller-[0-9] ' \
405                              | sed -e 's/^.*ctlplane=//' -e 's/ *|\$//'")
406         elif [[ "$INSTALLER_TYPE" == "fuel" ]] ; then
407             CONTROLLER_IPS=$(sshpass -p r00tme ssh 2>/dev/null $ssh_opts root@${INSTALLER_IP} \
408                             "fuel node | grep controller | cut -d '|' -f 5|xargs")
409         fi
410
411         die_if_not_set $LINENO CONTROLLER_IPS "Could not get CONTROLLER_IPS."
412         for ip in $CONTROLLER_IPS
413         do
414             forward_rule="-R $CONSUMER_PORT:localhost:$CONSUMER_PORT"
415             tunnel_command="sudo ssh $ssh_opts_cpu $COMPUTE_USER@$ip $forward_rule sleep 600"
416             $tunnel_command > "ssh_tunnel.${ip}.log" 2>&1 < /dev/null &
417         done
418     fi
419 }
420
421 stop_consumer() {
422     pgrep -f "python consumer.py" || return 0
423     kill $(pgrep -f "python consumer.py")
424     print_log consumer.log
425
426     # NOTE(r-mibu): terminate tunnels to the controller nodes
427     if [[ "$INSTALLER_TYPE" != "local" ]] ; then
428         for ip in $CONTROLLER_IPS
429         do
430             forward_rule="-R $CONSUMER_PORT:localhost:$CONSUMER_PORT"
431             tunnel_command="sudo ssh $ssh_opts_cpu $COMPUTE_USER@$ip $forward_rule sleep 600"
432             kill $(pgrep -f "$tunnel_command")
433             print_log "ssh_tunnel.${ip}.log"
434         done
435     fi
436 }
437
438 wait_for_vm_launch() {
439     echo "waiting for vm launch..."
440
441     count=0
442     while [[ ${count} -lt 60 ]]
443     do
444         state=$(openstack $as_doctor_user server list | grep " $VM_NAME " | awk '{print $6}')
445         if [[ "$state" == "ACTIVE" ]]; then
446             # NOTE(cgoncalves): sleeping for a bit to stabilize
447             # See python-openstackclient/functional/tests/compute/v2/test_server.py:wait_for_status
448             sleep 5
449             return 0
450         fi
451         if [[ "$state" == "ERROR" ]]; then
452             die $LINENO "vm state is ERROR"
453         fi
454         count=$(($count+1))
455         sleep 1
456     done
457     die $LINENO "Time out while waiting for VM launch"
458 }
459
460 inject_failure() {
461     echo "disabling network of compute host [$COMPUTE_HOST] for 3 mins..."
462     cat > disable_network.sh << 'END_TXT'
463 #!/bin/bash -x
464 dev=$(sudo ip a | awk '/ @COMPUTE_IP@\//{print $7}')
465 sleep 1
466 sudo ip link set $dev down
467 sleep 180
468 sudo ip link set $dev up
469 sleep 1
470 END_TXT
471     sed -i -e "s/@COMPUTE_IP@/$COMPUTE_IP/" disable_network.sh
472     chmod +x disable_network.sh
473     scp $ssh_opts_cpu disable_network.sh "$COMPUTE_USER@$COMPUTE_IP:"
474     ssh $ssh_opts_cpu "$COMPUTE_USER@$COMPUTE_IP" 'nohup ./disable_network.sh > disable_network.log 2>&1 &'
475 }
476
477 calculate_notification_time() {
478     detected=$(grep "doctor monitor detected at" monitor.log | awk '{print $5}')
479     notified=$(grep "doctor consumer notified at" consumer.log | awk '{print $5}')
480     if ! grep -q "doctor consumer notified at" consumer.log ; then
481         die $LINENO "Consumer hasn't received fault notification."
482     fi
483     echo "$notified $detected" | \
484         awk '{
485             d = $1 - $2;
486             if (d < 1 && d > 0) { print d " OK"; exit 0 }
487             else { print d " NG"; exit 1 }
488         }'
489 }
490
491 check_host_status() {
492     expected_state=$1
493
494     host_status_line=$(openstack $as_doctor_user --os-compute-api-version 2.16 \
495                        server show $VM_NAME | grep "host_status")
496     host_status=$(echo $host_status_line | awk '{print $4}')
497     die_if_not_set $LINENO host_status "host_status not reported by: nova show $VM_NAME"
498     if [[ "$expected_state" =~ "$host_status" ]] ; then
499         echo "$VM_NAME showing host_status: $host_status"
500     else
501         die $LINENO "host_status:$host_status not equal to expected_state: $expected_state"
502     fi
503 }
504
505 cleanup() {
506     set +e
507     echo "cleanup..."
508     stop_monitor
509     stop_inspector
510     stop_consumer
511
512     echo "waiting disabled compute host back to be enabled..."
513     python ./nova_force_down.py "$COMPUTE_HOST" --unset
514     sleep 240
515     check_host_status "UP"
516     scp $ssh_opts_cpu "$COMPUTE_USER@$COMPUTE_IP:disable_network.log" .
517     print_log disable_network.log
518
519     openstack $as_doctor_user server list | grep -q " $VM_NAME " && openstack $as_doctor_user server delete "$VM_NAME"
520     sleep 1
521     alarm_id=$(ceilometer $as_doctor_user alarm-list | grep " $ALARM_NAME " | awk '{print $2}')
522     sleep 1
523     [ -n "$alarm_id" ] && ceilometer $as_doctor_user alarm-delete "$alarm_id"
524     sleep 1
525
526     image_id=$(openstack image list | grep " $IMAGE_NAME " | awk '{print $2}')
527     sleep 1
528     #if an existing image was used, there's no need to remove it here
529     if [[ "$use_existing_image" == false ]] ; then
530         [ -n "$image_id" ] && openstack image delete "$image_id"
531     fi
532     openstack role remove "$DOCTOR_ROLE" --user "$DOCTOR_USER" \
533                               --project "$DOCTOR_PROJECT"
534     openstack project delete "$DOCTOR_PROJECT"
535     openstack user delete "$DOCTOR_USER"
536
537     restore_test_env
538 }
539
540
541 echo "Note: doctor/tests/run.sh has been executed."
542
543 trap cleanup EXIT
544
545 source $TOP_DIR/functions-common
546
547 echo "preparing test env..."
548 get_installer_ip
549 prepare_ssh_to_cloud
550 prepare_test_env
551
552 echo "preparing VM image..."
553 download_image
554 register_image
555
556 echo "creating test user..."
557 create_test_user
558
559 echo "creating VM..."
560 boot_vm
561 wait_for_vm_launch
562
563 echo "get computer host info..."
564 get_compute_host_info
565
566 echo "creating alarm..."
567 #TODO: change back to use, network problems depends on infra and installers
568 #get_consumer_ip
569 create_alarm
570
571 echo "starting doctor sample components..."
572 start_inspector
573 start_monitor
574 start_consumer
575
576 sleep 60
577 echo "injecting host failure..."
578 inject_failure
579 sleep 60
580
581 check_host_status "(DOWN|UNKNOWN)"
582 calculate_notification_time
583
584 echo "done"