Keystone: Add scenarios to benchmark user disable/enable
Adds a new scenario to create a user and toggle the enabled flag. Change-Id: I0b8d8e57c95cced72b6615f8120ec41879c414be
This commit is contained in:
parent
3760f40ec1
commit
89ee87de89
@ -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:
|
||||
|
@ -46,6 +46,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"]})
|
||||
|
@ -45,6 +45,16 @@ class KeystoneScenario(base.Scenario):
|
||||
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()
|
||||
|
@ -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
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
@ -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
|
@ -55,6 +55,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()
|
||||
|
@ -64,6 +64,19 @@ class KeystoneScenarioTestCase(test.ClientsTestCase):
|
||||
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()
|
||||
|
Loading…
Reference in New Issue
Block a user