diff options
Diffstat (limited to 'tests/run.sh')
-rwxr-xr-x | tests/run.sh | 51 |
1 files changed, 37 insertions, 14 deletions
diff --git a/tests/run.sh b/tests/run.sh index 7f95a8a4..daf23946 100755 --- a/tests/run.sh +++ b/tests/run.sh @@ -28,8 +28,7 @@ CONSUMER_PORT=12346 DOCTOR_USER=doctor DOCTOR_PW=doctor DOCTOR_PROJECT=doctor -#TODO: change back to `_member_` when JIRA DOCTOR-55 is done -DOCTOR_ROLE=admin +DOCTOR_ROLE=_member_ PROFILER_TYPE=${PROFILER_TYPE:-none} PYTHON_ENABLE=${PYTHON_ENABLE:-false} @@ -40,13 +39,15 @@ as_doctor_user="--os-username $DOCTOR_USER --os-password $DOCTOR_PW # NOTE: ceilometer command still requires '--os-tenant-name'. #ceilometer="ceilometer ${as_doctor_user/--os-project-name/--os-tenant-name}" ceilometer="ceilometer $as_doctor_user" +as_admin_user="--os-username admin --os-project-name $DOCTOR_PROJECT + --os-tenant-name $DOCTOR_PROJECT" # Functions get_compute_host_info() { - # get computer host info which first VM boot in - COMPUTE_HOST=$(openstack $as_doctor_user server show ${VM_BASENAME}1 | + # get computer host info which first VM boot in as admin user + COMPUTE_HOST=$(openstack $as_admin_user server show ${VM_BASENAME}1 | grep "OS-EXT-SRV-ATTR:host" | awk '{ print $4 }') compute_host_in_undercloud=${COMPUTE_HOST%%.*} die_if_not_set $LINENO COMPUTE_HOST "Failed to get compute hostname" @@ -109,17 +110,25 @@ register_image() { create_test_user() { openstack project list | grep -q " $DOCTOR_PROJECT " || { - openstack project create "$DOCTOR_PROJECT" + openstack project create --description "Doctor Project" \ + "$DOCTOR_PROJECT" } openstack user list | grep -q " $DOCTOR_USER " || { openstack user create "$DOCTOR_USER" --password "$DOCTOR_PW" \ --project "$DOCTOR_PROJECT" } - openstack role show "$DOCTOR_ROLE" || { + openstack role show "$DOCTOR_ROLE" | grep -q " $DOCTOR_ROLE " || { openstack role create "$DOCTOR_ROLE" } - openstack role add "$DOCTOR_ROLE" --user "$DOCTOR_USER" \ - --project "$DOCTOR_PROJECT" + openstack role assignment list --user "$DOCTOR_USER" \ + --project "$DOCTOR_PROJECT" --names | grep -q " $DOCTOR_ROLE " || { + openstack role add "$DOCTOR_ROLE" --user "$DOCTOR_USER" \ + --project "$DOCTOR_PROJECT" + } + openstack role assignment list --user admin --project "$DOCTOR_PROJECT" \ + --names | grep -q " admin " || { + openstack role add admin --user admin --project "$DOCTOR_PROJECT" + } # tojuvone: openstack quota show is broken and have to use nova # https://bugs.launchpad.net/manila/+bug/1652118 # Note! while it is encouraged to use openstack client it has proven @@ -141,6 +150,24 @@ create_test_user() { fi } +remove_test_user() { + openstack project list | grep -q " $DOCTOR_PROJECT " && { + openstack role assignment list --user admin \ + --project "$DOCTOR_PROJECT" --names | grep -q " admin " && { + openstack role remove admin --user admin --project "$DOCTOR_PROJECT" + } + openstack user list | grep -q " $DOCTOR_USER " && { + openstack role assignment list --user "$DOCTOR_USER" \ + --project "$DOCTOR_PROJECT" --names | grep -q " $DOCTOR_ROLE " && { + openstack role remove "$DOCTOR_ROLE" --user "$DOCTOR_USER" \ + --project "$DOCTOR_PROJECT" + } + openstack user delete "$DOCTOR_USER" + } + openstack project delete "$DOCTOR_PROJECT" + } +} + boot_vm() { # test VM done with test user, so can test non-admin @@ -436,12 +463,8 @@ cleanup() { if [[ "$use_existing_image" == false ]] ; then [ -n "$image_id" ] && openstack image delete "$image_id" fi - openstack role remove "$DOCTOR_ROLE" --user "$DOCTOR_USER" \ - --project "$DOCTOR_PROJECT" - openstack project delete "$DOCTOR_PROJECT" - openstack user delete "$DOCTOR_USER" - # NOTE: remove role only for doctor test. - #openstack role delete "$DOCTOR_ROLE" + + remove_test_user cleanup_installer cleanup_inspector |