[openstack-qa] Tempest Architecture/Design brainstorming

Jay Pipes jaypipes at gmail.com
Thu Jun 6 14:04:35 UTC 2013


On 06/06/2013 01:57 AM, Attila Fazekas wrote:
> Hi All,
>
> I am looking for ideas for unifying the tempest "Object Model" and to enhance it's capabilities.
>
> Several interesting topic:
> - Plug-ability
> - Identity management ("impersonate the right person efficiently")

I put together a proof of concept of this exact functionality using 
fixtures.Fixture and a context manager called acting_as() [1] that was 
extended by subclasses' do_as() method [2] to make it easy to write 
clean impersonation code [3]:

class TestFlavorsNonAdmin(base.ComputeApiTest):

     def test_list_flavors(self):
         with self.do_as('non_admin') as client:
             flavors = client.flavors.list()
             self.assertTrue(len(flavors) > 0)

     def test_unauthorized(self):
         with self.do_as('non_admin') as client:
             self.assertRaises(Exception, client.flavors.create, 
'flavorname')


class TestFlavorsAdmin(base.ComputeApiTest):

     def test_list_flavors(self):
         with self.do_as('admin') as client:
             flavors = client.flavors.list()
             self.assertTrue(len(flavors) > 0)

     def test_crud(self):
         with self.do_as('admin') as client:
             flavor_name = self.getUniqueString("flavor")
             flavor = client.flavors.create(flavor_name, 64, 1, 10)
             self.assertEqual(flavor_name, flavor.name)
             self.assertEqual(64, flavor.ram)
             self.assertEqual(1, flavor.vcpus)
             self.assertEqual(10, flavor.disk)
             flavors = client.flavors.list()
             flavor_ids = [x.id for x in flavors]
             self.assertIn(flavor.id, flavor_ids)
             flavor = client.flavors.find(name=flavor_name)
             self.assertEqual(flavor_name, flavor.name)
             self.assertEqual(64, flavor.ram)
             self.assertEqual(1, flavor.vcpus)
             self.assertEqual(10, flavor.disk)
             client.flavors.delete(flavor.id)

Best,
-jay

[1] 
https://github.com/jaypipes/tempest/blob/api/tempest/tests/api/base.py#L89
[2] 
https://github.com/jaypipes/tempest/blob/api/tempest/tests/api/compute/base.py#L27
[3] 
https://github.com/jaypipes/tempest/blob/api/tempest/tests/api/compute/test_flavors.py


> - test case selection (based on supported feature, installed services..)
>
> An ideal proposal should answer the
> - What you would like to achieve.
> - Why do you want/need this.
> - How do you want to do it.
>
> Feel free to add incomplete idea as well.
>
> Best Regards,
> Attila
>
> PS.: python is not juts OOP language,
> we should use the imperative and functional programming styles as well.
>
> _______________________________________________
> openstack-qa mailing list
> openstack-qa at lists.openstack.org
> http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-qa
>




More information about the openstack-qa mailing list