summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorGerald Kunzmann <kunzmann@docomolab-euro.com>2016-05-24 07:29:04 +0000
committerGerrit Code Review <gerrit@172.30.200.206>2016-05-24 07:29:04 +0000
commit7ae47c0ef0f968d17a8d52e2f1df4e97d12087c1 (patch)
treebaf9648005e3021ce2384affb2f25c90697b1bb3 /tests
parent725aae8ef5e0a3b7bc4f84d78c7cb9f84dcec57d (diff)
parent24359cbe708c27b80db6d5dcfed3a9191740f1d4 (diff)
Merge "Adding checking of host_status"
Diffstat (limited to 'tests')
-rwxr-xr-xtests/run.sh62
1 files changed, 58 insertions, 4 deletions
diff --git a/tests/run.sh b/tests/run.sh
index bbe093a6..00dcabca 100755
--- a/tests/run.sh
+++ b/tests/run.sh
@@ -17,6 +17,10 @@ VM_FLAVOR=m1.tiny
ALARM_NAME=doctor_alarm1
INSPECTOR_PORT=12345
CONSUMER_PORT=12346
+TEST_USER=demo
+TEST_PW=demo
+TEST_TENANT=demo
+TEST_ROLE=_member_
SUPPORTED_INSTALLER_TYPES="apex local"
INSTALLER_TYPE=${INSTALLER_TYPE:-apex}
@@ -82,12 +86,33 @@ register_image() {
--file "$IMAGE_FILE"
}
+create_test_user() {
+ keystone user-list | grep -q "$TEST_USER" || {
+ keystone user-create --name "$TEST_USER" --pass "$TEST_PW"
+ }
+ keystone tenant-list | grep -q "$TEST_TENANT" || {
+ keystone tenant-create --name "$TEST_TENANT"
+ }
+ keystone user-role-list --user "$TEST_USER" --tenant "$TEST_TENANT" \
+ | grep -q "$TEST_ROLE" || {
+ keystone user-role-add --user "$TEST_USER" --role "$TEST_ROLE" \
+ --tenant "$TEST_TENANT"
+ }
+}
+
boot_vm() {
nova list | grep -q " $VM_NAME " && return 0
- nova boot --flavor "$VM_FLAVOR" \
- --image "$IMAGE_NAME" \
- "$VM_NAME"
- sleep 1
+ (
+ # test VM done with test user, so can test non-admin
+ export OS_USERNAME="$TEST_USER"
+ export OS_PASSWORD="$TEST_PW"
+ export OS_TENANT_NAME="$TEST_TENANT"
+ nova boot --flavor "$VM_FLAVOR" \
+ --image "$IMAGE_NAME" \
+ "$VM_NAME"
+ sleep 1
+ )
+
}
create_alarm() {
@@ -170,6 +195,26 @@ calculate_notification_time() {
awk '{d = $1 - $2; if (d < 1 && d > 0) print d " OK"; else print d " NG"}'
}
+check_host_status_down() {
+ (
+ # Switching to test user
+ export OS_USERNAME="$TEST_USER"
+ export OS_PASSWORD="$TEST_PW"
+ export OS_TENANT_NAME="$TEST_TENANT"
+
+ host_status_line=$(nova show $VM_NAME | grep "host_status")
+ [[ $? -ne 0 ]] && {
+ echo "ERROR: host_status not configured for owner in Nova policy.json"
+ }
+
+ host_status=$(echo $host_status_line | awk '{print $4}')
+ [[ "$host_status" == "DOWN" ]] && {
+ echo "$VM_NAME showing host_status: $host_status"
+ }
+ echo "ERROR: host_status not reported by: nova show $VM_NAME"
+ )
+}
+
cleanup() {
set +e
echo "cleanup..."
@@ -188,6 +233,11 @@ cleanup() {
image_id=$(glance image-list | grep " $IMAGE_NAME " | awk '{print $2}')
sleep 1
[ -n "$image_id" ] && glance image-delete "$image_id"
+ keystone user-role-remove --user "$TEST_USER" --role "$TEST_ROLE" \
+ --tenant "$TEST_TENANT"
+ keystone tenant-remove --name "$TEST_TENANT"
+ keystone user-delete "$TEST_USER"
+
#TODO: add host status check via nova admin api
echo "waiting disabled compute host back to be enabled..."
sleep 180
@@ -211,6 +261,9 @@ start_monitor
start_inspector
start_consumer
+echo "creating test user..."
+create_test_user
+
echo "creating VM and alarm..."
boot_vm
create_alarm
@@ -221,6 +274,7 @@ echo "injecting host failure..."
inject_failure
sleep 10
+check_host_status_down
calculate_notification_time
echo "done"