summaryrefslogtreecommitdiffstats
path: root/tests/run.sh
diff options
context:
space:
mode:
authordongwenjuan <dong.wenjuan@zte.com.cn>2016-07-12 18:10:56 +0800
committerdongwenjuan <dong.wenjuan@zte.com.cn>2016-07-22 09:53:43 +0800
commit5aa254607e0737916dc72200064857882e1abd36 (patch)
tree2b3c9c2b466f89c7cdce1944a07f4bb5b043f658 /tests/run.sh
parent5a189baf2f99032a0c28992fa47e372d5291c2d2 (diff)
use specify host_ip in alarm_action
we can not use `localhost` in `--alarm-action`, it should be the IP which the consumer started on. Change-Id: I50b99e4ff7609c474fb569049b3b8cd216c9178b Signed-off-by: dongwenjuan <dong.wenjuan@zte.com.cn>
Diffstat (limited to 'tests/run.sh')
-rwxr-xr-xtests/run.sh25
1 files changed, 21 insertions, 4 deletions
diff --git a/tests/run.sh b/tests/run.sh
index 3e2fbab5..4d9a5c73 100755
--- a/tests/run.sh
+++ b/tests/run.sh
@@ -29,6 +29,7 @@ SUPPORTED_INSTALLER_TYPES="apex local"
INSTALLER_TYPE=${INSTALLER_TYPE:-apex}
INSTALLER_IP=${INSTALLER_IP:-none}
COMPUTE_USER=${COMPUTE_USER:-none}
+
ssh_opts="-o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no"
if [[ ! "$SUPPORTED_INSTALLER_TYPES" =~ "$INSTALLER_TYPE" ]] ; then
@@ -94,6 +95,20 @@ prepare_compute_ssh() {
fi
}
+get_consumer_ip() {
+ #get network of the compute_ip address
+ network_pre=${COMPUTE_IP%.*}
+ network=${network_pre}.0/24
+
+ #if there is a dedicated route, use it
+ dev=$(ip route |grep $network | awk '{print $3}' |head -n 1)
+
+ #if there is no route, use default route
+ [[ -z $dev ]] && dev=$(ip route |grep ^default | awk '{print $3}' |head -n 1)
+
+ CONSUMER_IP=$(ip addr show $dev |grep inet | grep $network_pre | awk '{print $2}' | cut -d'/' -f1)
+}
+
download_image() {
[ -e "$IMAGE_FILE" ] && return 0
wget "$IMAGE_URL" -o "$IMAGE_FILE"
@@ -149,7 +164,7 @@ create_alarm() {
ceilometer alarm-list | grep -q " $ALARM_NAME " && return 0
vm_id=$(openstack server list | grep " $VM_NAME " | awk '{print $2}')
ceilometer alarm-event-create --name "$ALARM_NAME" \
- --alarm-action "http://localhost:$CONSUMER_PORT/failure" \
+ --alarm-action "http://$CONSUMER_IP:$CONSUMER_PORT/failure" \
--description "VM failure" \
--enabled True \
--repeat-actions False \
@@ -275,7 +290,6 @@ cleanup() {
check_host_status "UP"
ssh $ssh_opts_cpu "$COMPUTE_USER@$COMPUTE_IP" \
"[ -e disable_network.log ] && cat disable_network.log"
- sleep 1
(
change_to_doctor_user
@@ -307,15 +321,18 @@ register_image
echo "creating test user..."
create_test_user
-echo "creating VM and alarm..."
+echo "creating VM..."
boot_vm
wait_for_vm_launch
-create_alarm
echo "get computer host info and prepare to ssh..."
get_compute_host_info
prepare_compute_ssh
+echo "creating alarm..."
+get_consumer_ip
+create_alarm
+
echo "starting doctor sample components..."
start_monitor
start_inspector