Manager object should allow username, password, tenant to be passed in parameters

Bug #973338 reported by Rohit Karajgi
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
tempest
Fix Released
Medium
Jay Pipes

Bug Description

This issue is related to the re-factorings introduced by the following patch
https://review.openstack.org/#change,5894

We have tests to be checked into tempest that require client API operations to be performed by admin (privileged role)
as well as non admin (member role) users.

With this view, the earlier behavior, and signature of __init__ in Manager of openstack.py was suitable.
I could create two instances of manager, one for an admin user, and the other for non-admin user.

Also, the latest tempest.conf.sample has a [compute-admin] section that allows an admin test user
to be configured.
However this is not updated in config.py. The file needs a compute-admin class to define these properties,
so they can be used in test cases to execute APIs.

https://github.com/openstack/tempest/commit/3f981df854cb55679b883713165262d7c37e45c0#diff-3

It would be good if some of the above changes were reverted.
I'll submit a patch.

Rohit Karajgi (rohitk)
description: updated
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to tempest (master)

Fix proposed to branch: master
Review: https://review.openstack.org/6227

Changed in tempest:
assignee: nobody → Rohit Karajgi (rohitkarajgi)
status: New → In Progress
Revision history for this message
Rohit Karajgi (rohitk) wrote :
Changed in tempest:
importance: Undecided → Medium
Revision history for this message
Jay Pipes (jaypipes) wrote :

Hi Rohit! :)

Could you detail precisely which test cases (or tests within test cases) need:

* Administrators privs to run
* Both an admin AND a non-admin user

I'd like to document this and move tests around so that it is clear exactly when we are expecting admin vs. non-admin users to be executing the test cases -- or if we want to run test cases with different sets of credentials (admin vs. non-admin) and validate different results where appropriate....

I'd actually prefer to keep the [compute-admin] section in the tempest conf and create a new tempest.config.ComputeAdminConfig class that stores information about the administrative user credentials needed to execute test cases that are specifically intended for admin users and eventually move these tests into a /tempest/tests/compute/admin/ directory...

Thoughts?
-jay

Revision history for this message
Rohit Karajgi (rohitk) wrote :

Hi Jay,

I need to add tests for create and delete flavors, specifically. This is one use case that I have come across.

* Create and delete flavor api can only be run by a user with an "admin" role. A user with Member role is unauthorized as per policy.json for flavorsmanage.

Currently, the default behavior is to run tests as non-admin users (list flavors, get flavor details etc). which is fine.

* To test create delete, i'd also need to call list. So either I run the whole suite as admin or just the create and delete API as
admin user.

Please suggest.

I do agree with your suggestions to separate the admin tests into another directory.

Revision history for this message
David Kranz (david-kranz) wrote :

I think the real question is which tests *should* there be that need admin privs. Looking at the nova source I think that the following actions require admin:

pause
unpause
suspend
resume
migrate
reset_network
inject_network_info
lock
unlock
create_backup
migrate_live

But I am able to do a pause without being am admin user. Is this a bug in nova?
It is unfortunate that the admin APIs are not distinguished in a better way. What are the admin APIs and where are they documented?

Revision history for this message
Jay Pipes (jaypipes) wrote :

@Rohit: I think having a separate /tempest/tests/compute/admin/test_flavors.py that contains all tests that are relevant for an admin (CRUD + list) and having /tempest/tests/compute/test_flavors.py contain tests that are relevant for a non-admin user (list only?) is the most appropriate solution.

@David: Yes, I agree it's not ideal (the documentation), but hopefully we can go through each API piece and identify those specs that are intended for admin only and move them into /tempest/tests/compute/admin/* with the ComputeAdminConfig object handling that configuration?

Revision history for this message
David Kranz (david-kranz) wrote :

Jay, I agree. I was confused about pause working but that is expected because pause and some others actually have a policy of "admin or owner". So we have to be careful about these admin tests.

Revision history for this message
Rohit Karajgi (rohitk) wrote :

In case of flavor_create and flavor_delete, they are extensions (FlavorManage) __and__ need to be run as admin user.
So I can see two ways to segregate such tests.

1. /tempest/tests/compute/admin/test_flavors.py (as Jay suggested above)
2. /tempest/tests/compute/extensions/admin/test_flavor_extension.py
(and maybe have a ..extensions/nonadmin/ directory)

Since flavorsmanage.py resides in compute/contrib in nova source, I think structure (2) above
might be more closer to the source code.

Revision history for this message
Daryl Walleck (dwalleck) wrote :

Regardless of implementation, these the scenarios I need to be able to perform:

-As a normal user, run all tests that don't require admin access and verify they pass
-As a normal user, run all tests that do require admin access to verify they fail
-As an admin user, run all tests that require admin access and verify they pass
-As an admin user, run all tests using a normal user's tenant id and verify they pass
-As a normal user, run all tests around admin functionality and verify they fail

This is just the high level of the flexibility I'm looking for.

Revision history for this message
David Kranz (david-kranz) wrote :

Another wrinkle is that I filed a bug about the fact that nova-client did identify the "admin apis" in its help.
https://bugs.launchpad.net/bugs/973708 I got this response:

   I don't think this is a bug, because:
   1. nova client just acts as an API caller, which does not know policy.json at all.
   2. policy.json is just one of implementations. For example, We can implementation policy with SQL backend.
   3. policy is dynamic. Operators can define their own rules in policy.

If (3) is really true then I don't understand how we can have tests that do what Daryl says above. This is really saying that whether or not a Compute API requires admin access is not part of the definition of the API. That doesn't make a lot of sense to me and seems not very helpful to users. I thought this modular implementation for extensions was so that you could add and control extensions without having to install a new release.

Revision history for this message
OpenStack Infra (hudson-openstack) wrote :

Fix proposed to branch: master
Review: https://review.openstack.org/6333

Changed in tempest:
assignee: Rohit Karajgi (rohitkarajgi) → Jay Pipes (jaypipes)
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to tempest (master)

Reviewed: https://review.openstack.org/6333
Committed: http://github.com/openstack/tempest/commit/ff10d5577df75b50ddf5ae0fead837292c4b3209
Submitter: Jenkins
Branch: master

commit ff10d5577df75b50ddf5ae0fead837292c4b3209
Author: Jay Pipes <email address hidden>
Date: Fri Apr 6 14:18:50 2012 -0400

    Fixes LP 973338 - Add custom alt and admin manager

    * Adds new AltManager, AdminManager derived manager classes
    * Allows Manager to be inited with custom credentials
    * Adds config.ComputeAdminConfig class and setup
    * Updates test_authorization to use AltManager class

    Change-Id: Iff5b20fbdfb8979a775f30f7e07d6e06b29e6c1c

Changed in tempest:
status: In Progress → Fix Committed
Jay Pipes (jaypipes)
Changed in tempest:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.