summaryrefslogtreecommitdiffstats
path: root/tests/run.sh
diff options
context:
space:
mode:
Diffstat (limited to 'tests/run.sh')
-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"