Added tenant create benchmark for keystone
Change-Id: I04d49fb30ed1a32f5eeb234d594198e62ea556d3
This commit is contained in:
14
doc/samples/tasks/keystone/create-tenant.json
Normal file
14
doc/samples/tasks/keystone/create-tenant.json
Normal file
@@ -0,0 +1,14 @@
|
||||
{
|
||||
"KeystoneBasic.create_tenant": [
|
||||
{
|
||||
"args": {
|
||||
"name_length": 10
|
||||
},
|
||||
"runner":{
|
||||
"type": "continuous",
|
||||
"times": 100,
|
||||
"active_users": 10
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
9
doc/samples/tasks/keystone/create-tenant.yaml
Normal file
9
doc/samples/tasks/keystone/create-tenant.yaml
Normal file
@@ -0,0 +1,9 @@
|
||||
---
|
||||
KeystoneBasic.create_tenant:
|
||||
-
|
||||
args:
|
||||
name_length: 10
|
||||
runner:
|
||||
type: "continuous"
|
||||
times: 100
|
||||
active_users: 10
|
||||
@@ -24,3 +24,6 @@ class KeystoneBasic(kutils.KeystoneScenario):
|
||||
def create_delete_user(self, name_length=10, **kwargs):
|
||||
user = self._user_create(name_length=name_length, **kwargs)
|
||||
self._resource_delete(user)
|
||||
|
||||
def create_tenant(self, name_length=10, **kwargs):
|
||||
self._tenant_create(name_length=name_length, **kwargs)
|
||||
|
||||
@@ -43,7 +43,7 @@ class KeystoneScenario(base.Scenario):
|
||||
**kwargs):
|
||||
"""Creates keystone user with random name.
|
||||
|
||||
:param name_length: length of generated (ranodm) part of name
|
||||
:param name_length: length of generated (random) part of name
|
||||
:param **kwargs: Other optional parameters to create users like
|
||||
"tenant_id", "enabled".
|
||||
:return: keystone user instance
|
||||
@@ -61,3 +61,14 @@ class KeystoneScenario(base.Scenario):
|
||||
def _resource_delete(self, resource):
|
||||
""""Delete keystone resource."""
|
||||
resource.delete()
|
||||
|
||||
@scenario_utils.atomic_action_timer('keystone.create_tenant')
|
||||
def _tenant_create(self, name_length=10, **kwargs):
|
||||
"""Creates keystone tenant with random name.
|
||||
|
||||
:param name_length: length of generated (random) part of name
|
||||
:param **kwargs: Other optional parameters
|
||||
:return: keystone tenant instance
|
||||
"""
|
||||
name = generate_keystone_name(length=name_length)
|
||||
return self.admin_clients("keystone").tenants.create(name, **kwargs)
|
||||
|
||||
@@ -53,3 +53,12 @@ class KeystoneBasicTestCase(test.TestCase):
|
||||
email="abcd",
|
||||
**{"enabled": True})
|
||||
scenario._resource_delete.assert_called_once_with(create_result)
|
||||
|
||||
@mock.patch(KEYSTONE_UTILS + "generate_keystone_name")
|
||||
def test_create_tenant(self, mock_gen_name):
|
||||
scenario = basic.KeystoneBasic()
|
||||
mock_gen_name.return_value = "teeeest"
|
||||
scenario._tenant_create = mock.MagicMock()
|
||||
scenario.create_tenant(name_length=20, **{"enabled": True})
|
||||
scenario._tenant_create.assert_called_once_with(name_length=20,
|
||||
**{"enabled": True})
|
||||
|
||||
@@ -83,3 +83,22 @@ class KeystoneScenarioTestCase(test.TestCase):
|
||||
resource.delete.assert_called_once_with()
|
||||
self._test_atomic_action_timer(scenario.atomic_actions_time(),
|
||||
'keystone.delete_resource')
|
||||
|
||||
@mock.patch(UTILS + "generate_keystone_name")
|
||||
def test_tenant_create(self, mock_gen_name):
|
||||
name = "abc"
|
||||
mock_gen_name.return_value = name
|
||||
|
||||
tenant = {}
|
||||
fake_keystone = fakes.FakeKeystoneClient()
|
||||
fake_keystone.tenants.create = mock.MagicMock(return_value=tenant)
|
||||
fake_clients = fakes.FakeClients()
|
||||
fake_clients._keystone = fake_keystone
|
||||
scenario = utils.KeystoneScenario(admin_clients=fake_clients)
|
||||
|
||||
result = scenario._tenant_create()
|
||||
|
||||
self.assertEqual(tenant, result)
|
||||
fake_keystone.tenants.create.assert_called_once_with(name)
|
||||
self._test_atomic_action_timer(scenario.atomic_actions_time(),
|
||||
'keystone.create_tenant')
|
||||
|
||||
Reference in New Issue
Block a user