[openstack-dev] Execute Tempest test with admin privileges

Giulio Fidente gfidente at redhat.com
Mon Jul 15 16:49:51 UTC 2013

On 07/15/2013 05:59 PM, Joe Hakim Rahme wrote:
> Hello,
> I am trying to write a test in Tempest that would cover the behavior of
> the Swift Account Quotas middleware. The use case I'm trying to cover
> is that the test would create an account, put a quota on it, and try to
> upload a file larger and a file smaller than the quota.
> Here's what I have in my class:
> class AccountQuotaTest(base.BaseObjectTest):
>     @classmethod
>     def setUpClass(cls):
>         super(AccountQuotaTest, cls).setUpClass()
>         cls.container_name = rand_name(name="TestContainer")
>         cls.container_client.create_container(cls.container_name)
>         # Add the account quota metadata
>         size = "10"
>         metadata = {"Quota-Bytes": size}
>         cls.account_client.create_account_metadata(metadata=metadata)
> However when I execute the tests, I get a Unauthorized exception. I
> guess it makes sense, since only the admin (or any account with
> ResellerAdmin role) can set this metadata.

In the base class you'll see the container_client , account_client and 
other clients are defined out of cls.os


redefine those in your test class from cls.os_admin so they will "run" 
using the admin credentials

Ideally you could also provide some BaseAdminObjectTest class in base.py 
to use, as it happens for the volume tests:

Giulio Fidente
GPG KEY: 08D733BA | IRC: giulivo

More information about the OpenStack-dev mailing list