Merge "Keystone: Add scenarios to benchmark user disable/enable"

This commit is contained in:
Jenkins 2015-07-16 04:00:20 +00:00 committed by Gerrit Code Review
commit bcba82c643
7 changed files with 114 additions and 0 deletions

View File

@ -23,6 +23,28 @@
failure_rate:
max: 0
KeystoneBasic.create_user_set_enabled_and_delete:
-
args:
enabled: true
runner:
type: "constant"
times: 10
concurrency: 10
sla:
failure_rate:
max: 0
-
args:
enabled: false
runner:
type: "constant"
times: 10
concurrency: 10
sla:
failure_rate:
max: 0
KeystoneBasic.create_and_list_tenants:
-
args:

View File

@ -47,6 +47,20 @@ class KeystoneBasic(kutils.KeystoneScenario):
user = self._user_create(name_length=name_length, **kwargs)
self._resource_delete(user)
@validation.required_openstack(admin=True)
@base.scenario(context={"admin_cleanup": ["keystone"]})
def create_user_set_enabled_and_delete(self, enabled=True, **kwargs):
"""Create a keystone user, enable or disable it, and delete it.
:param enabled: Initial state of user 'enabled' flag. The user
will be created with 'enabled' set to this
value, and then it will be toggled.
:param kwargs: Other optional parameters to create user.
"""
user = self._user_create(enabled=enabled, **kwargs)
self._update_user_enabled(user, not enabled)
self._resource_delete(user)
@validation.number("name_length", minval=10)
@validation.required_openstack(admin=True)
@base.scenario(context={"admin_cleanup": ["keystone"]})

View File

@ -46,6 +46,16 @@ class KeystoneScenario(scenario.OpenStackScenario):
return self.admin_clients("keystone").users.create(
name, password=password, email=email, **kwargs)
@base.atomic_action_timer("keystone.update_user_enabled")
def _update_user_enabled(self, user, enabled):
"""Enable or disable a user.
:param user: The user to enable or disable
:param enabled: Boolean indicating if the user should be
enabled (True) or disabled (False)
"""
self.admin_clients("keystone").users.update_enabled(user, enabled)
def _resource_delete(self, resource):
""""Delete keystone resource."""
r = "keystone.delete_%s" % resource.__class__.__name__.lower()

View File

@ -0,0 +1,24 @@
{
"KeystoneBasic.create_user_set_enabled_and_delete": [
{
"args": {
"enabled": true
},
"runner": {
"type": "constant",
"concurrency": 10,
"times": 100
}
},
{
"args": {
"enabled": false
},
"runner": {
"type": "constant",
"concurrency": 10,
"times": 100
}
}
]
}

View File

@ -0,0 +1,16 @@
---
KeystoneBasic.create_user_set_enabled_and_delete:
-
args:
enabled: true
runner:
type: "constant"
times: 100
concurrency: 10
-
args:
enabled: false
runner:
type: "constant"
times: 100
concurrency: 10

View File

@ -58,6 +58,21 @@ class KeystoneBasicTestCase(test.TestCase):
enabled=True)
scenario._resource_delete.assert_called_once_with(create_result)
def test_create_user_set_enabled_and_delete(self):
scenario = basic.KeystoneBasic()
scenario._user_create = mock.Mock()
scenario._update_user_enabled = mock.Mock()
scenario._resource_delete = mock.Mock()
scenario.create_user_set_enabled_and_delete(enabled=True,
email="abcd")
scenario._user_create.assert_called_once_with(email="abcd",
enabled=True)
scenario._update_user_enabled.assert_called_once_with(
scenario._user_create.return_value, False)
scenario._resource_delete.assert_called_once_with(
scenario._user_create.return_value)
@mock.patch("rally.common.utils.generate_random_name")
def test_create_tenant(self, mock_generate_random_name):
scenario = basic.KeystoneBasic()

View File

@ -64,6 +64,19 @@ class KeystoneScenarioTestCase(test.ScenarioTestCase):
self._test_atomic_action_timer(scenario.atomic_actions(),
"keystone.create_user")
def test_update_user_enabled(self):
user = mock.Mock()
enabled = mock.Mock()
scenario = utils.KeystoneScenario()
scenario._update_user_enabled(user, enabled)
self.admin_clients(
"keystone").users.update_enabled.assert_called_once_with(user,
enabled)
self._test_atomic_action_timer(scenario.atomic_actions(),
"keystone.update_user_enabled")
@mock.patch("rally.common.utils.generate_random_name")
def test_role_create(self, mock_generate_random_name):
scenario = utils.KeystoneScenario()