summaryrefslogtreecommitdiffstats
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
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>
-rw-r--r--tests/consumer.py4
-rwxr-xr-xtests/run.sh25
2 files changed, 23 insertions, 6 deletions
diff --git a/tests/consumer.py b/tests/consumer.py
index ef4116a9..6618f615 100644
--- a/tests/consumer.py
+++ b/tests/consumer.py
@@ -29,13 +29,13 @@ def event_posted():
def get_args():
parser = argparse.ArgumentParser(description='Doctor Sample Consumer')
parser.add_argument('port', metavar='PORT', type=int, nargs='?',
- help='a port for consumer')
+ help='the port for consumer')
return parser.parse_args()
def main():
args = get_args()
- app.run(port=args.port, debug=True)
+ app.run(host="0.0.0.0", port=args.port)
if __name__ == '__main__':
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