Merge "Add keystone create_update_and_delete_tenant scenario"

This commit is contained in:
Jenkins 2015-04-21 16:55:38 +00:00 committed by Gerrit Code Review
commit 349c8e2dfa
8 changed files with 98 additions and 1 deletions

View File

@ -86,6 +86,18 @@
failure_rate:
max: 0
KeystoneBasic.create_update_and_delete_tenant:
-
args:
name_length: 10
runner:
type: "constant"
times: 10
concurrency: 5
sla:
failure_rate:
max: 0
KeystoneBasic.create_delete_user:
-
args:

View File

@ -125,6 +125,19 @@ class KeystoneBasic(kutils.KeystoneScenario):
service = self._service_create(name, service_type, description)
self._delete_service(service.id)
@validation.number("name_length", minval=10)
@validation.required_openstack(admin=True)
@base.scenario(context={"admin_cleanup": ["keystone"]})
def create_update_and_delete_tenant(self, name_length=10, **kwargs):
"""Create, update and delete tenant.
:param name_length: length of the random part of tenant name
:param kwargs: Other optional parameters for tenant creation
"""
tenant = self._tenant_create(name_length=name_length, **kwargs)
self._update_tenant(tenant)
self._resource_delete(tenant)
@validation.required_openstack(admin=True)
@base.scenario(context={"admin_cleanup": ["keystone"]})
def create_and_list_services(self, name=None, service_type=None,

View File

@ -164,3 +164,16 @@ class KeystoneScenario(base.Scenario):
:param service_id: service to be deleted
"""
self.admin_clients("keystone").services.delete(service_id)
@base.atomic_action_timer("keystone.update_tenant")
def _update_tenant(self, tenant, name=None, description=None):
"""Update tenant name and description.
:param tenant: tenant to be updated
:param name: tenant name to be set
:param description: tenant description to be set
"""
name = name or (tenant.name + "_updated")
description = description or (tenant.name + "_description_updated")
self.admin_clients("keystone").tenants.update(tenant.id,
name, description)

View File

@ -0,0 +1,14 @@
{
"KeystoneBasic.create_update_and_delete_tenant": [
{
"args": {
"name_length": 10
},
"runner": {
"type": "constant",
"times": 100,
"concurrency": 10
}
}
]
}

View File

@ -0,0 +1,9 @@
---
KeystoneBasic.create_update_and_delete_tenant:
-
args:
name_length: 10
runner:
type: "constant"
times: 100
concurrency: 10

View File

@ -141,6 +141,16 @@ class KeystoneBasicTestCase(test.TestCase):
description)
scenario._delete_service.assert_called_once_with(fake_service.id)
def test_create_update_and_delete_tenant(self):
scenario = basic.KeystoneBasic()
fake_tenant = mock.MagicMock()
scenario._tenant_create = mock.MagicMock(return_value=fake_tenant)
scenario._update_tenant = mock.MagicMock()
scenario._resource_delete = mock.MagicMock()
scenario.create_update_and_delete_tenant()
scenario._update_tenant.assert_called_once_with(fake_tenant)
scenario._resource_delete.assert_called_once_with(fake_tenant)
def test_create_and_list_services(self):
scenario = basic.KeystoneBasic()
name = "Rally_test_service"

View File

@ -271,9 +271,27 @@ class KeystoneScenarioTestCase(test.TestCase):
self._test_atomic_action_timer(scenario.atomic_actions(),
"keystone.get_service")
def test_update_tenant(self):
tenant = mock.MagicMock()
description = tenant.name + "_description_updated_test"
name = tenant.name + "test_updated_test"
fake_keystone = fakes.FakeKeystoneClient()
fake_keystone.tenants.update = mock.MagicMock()
fake_clients = fakes.FakeClients()
fake_clients._keystone = fake_keystone
scenario = utils.KeystoneScenario(admin_clients=fake_clients)
scenario._update_tenant(tenant=tenant, name=name,
description=description)
fake_keystone.tenants.update.assert_called_once_with(tenant.id, name,
description)
self._test_atomic_action_timer(scenario.atomic_actions(),
"keystone.update_tenant")
def test_get_service_by_name(self):
scenario = utils.KeystoneScenario()
svc_foo, svc_bar = mock.Mock(), mock.Mock()
scenario._list_services = mock.Mock(return_value=[svc_foo, svc_bar])
self.assertEqual(scenario._get_service_by_name(svc_bar.name), svc_bar)
self.assertIsNone(scenario._get_service_by_name("spam"))
self.assertIsNone(scenario._get_service_by_name("spam"))

View File

@ -449,6 +449,14 @@ class FakeTenantsManager(FakeManager):
def create(self, name):
return self._cache(FakeTenant(self, name))
def update(self, tenant_id, name=None, description=None):
tenant = self.get(tenant_id)
name = name or (tenant.name + "_updated")
desc = description or (tenant.name + "_description_updated")
tenant.name = name
tenant.description = desc
return self._cache(tenant)
class FakeNetworkManager(FakeManager):