summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorTomi Juvonen <tomi.juvonen@nokia.com>2016-05-16 13:38:23 +0300
committerTomi Juvonen <tomi.juvonen@nokia.com>2016-05-24 03:43:37 +0000
commit24359cbe708c27b80db6d5dcfed3a9191740f1d4 (patch)
treec310c3bf2fa55cc8fa7bda4d9c01c0343beae393 /tests
parenta1bab6ecdfbfaf5521f31d9539e256fc6e0cac29 (diff)
Adding checking of host_status
Checking of host_status is added for non-admin user to see that installer have properly set the Nova policy.json like: "os_compute_api:servers:show:host_status": "rule:admin_or_owner" JIRA: DOCTOR-61 Change-Id: Ieee997951b54f25b698ef0b70a628cfcf87b396a Signed-off-by: Tomi Juvonen <tomi.juvonen@nokia.com>
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 fc9ec951..426583e0 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"