Merge "Add keystone update_user_password scenario"

This commit is contained in:
Jenkins 2015-04-22 14:49:06 +00:00 committed by Gerrit Code Review
commit c70cdc80b3
7 changed files with 93 additions and 0 deletions

View File

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

View File

@ -138,6 +138,20 @@ class KeystoneBasic(kutils.KeystoneScenario):
self._update_tenant(tenant) self._update_tenant(tenant)
self._resource_delete(tenant) self._resource_delete(tenant)
@validation.number("password_length", minval=10)
@validation.number("name_length", minval=10)
@validation.required_openstack(admin=True)
@base.scenario(context={"admin_cleanup": ["keystone"]})
def create_user_update_password(self, name_length=10, password_length=10):
"""Create user and update password for that user.
:param name_length: length of the user name
:param password_length: length of the password
"""
password = self._generate_random_name(length=password_length)
user = self._user_create(name_length=name_length)
self._update_user_password(user.id, password)
@validation.required_openstack(admin=True) @validation.required_openstack(admin=True)
@base.scenario(context={"admin_cleanup": ["keystone"]}) @base.scenario(context={"admin_cleanup": ["keystone"]})
def create_and_list_services(self, name=None, service_type=None, def create_and_list_services(self, name=None, service_type=None,

View File

@ -177,3 +177,13 @@ class KeystoneScenario(base.Scenario):
description = description or (tenant.name + "_description_updated") description = description or (tenant.name + "_description_updated")
self.admin_clients("keystone").tenants.update(tenant.id, self.admin_clients("keystone").tenants.update(tenant.id,
name, description) name, description)
@base.atomic_action_timer("keystone.update_user_password")
def _update_user_password(self, user_id, password):
"""Update user password.
:param user_id: id of the user
:param password: new password
"""
self.admin_clients("keystone").users.update_password(user_id,
password)

View File

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

View File

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

View File

@ -151,6 +151,21 @@ class KeystoneBasicTestCase(test.TestCase):
scenario._update_tenant.assert_called_once_with(fake_tenant) scenario._update_tenant.assert_called_once_with(fake_tenant)
scenario._resource_delete.assert_called_once_with(fake_tenant) scenario._resource_delete.assert_called_once_with(fake_tenant)
def test_create_user_update_password(self):
scenario = basic.KeystoneBasic()
fake_password = "pswd"
fake_user = mock.MagicMock()
scenario._user_create = mock.MagicMock(return_value=fake_user)
scenario._generate_random_name = mock.MagicMock(
return_value=fake_password)
scenario._update_user_password = mock.MagicMock()
scenario.create_user_update_password(name_length=9, password_length=9)
scenario._generate_random_name.assert_called_once_with(length=9)
scenario._user_create.assert_called_once_with(name_length=9)
scenario._update_user_password.assert_called_once_with(fake_user.id,
fake_password)
def test_create_and_list_services(self): def test_create_and_list_services(self):
scenario = basic.KeystoneBasic() scenario = basic.KeystoneBasic()
name = "Rally_test_service" name = "Rally_test_service"

View File

@ -289,6 +289,22 @@ class KeystoneScenarioTestCase(test.TestCase):
self._test_atomic_action_timer(scenario.atomic_actions(), self._test_atomic_action_timer(scenario.atomic_actions(),
"keystone.update_tenant") "keystone.update_tenant")
def test_update_user_password(self):
password = "pswd"
user = mock.MagicMock()
fake_keystone = fakes.FakeKeystoneClient()
fake_keystone.users.update_password = mock.MagicMock()
fake_clients = fakes.FakeClients()
fake_clients._keystone = fake_keystone
scenario = utils.KeystoneScenario(admin_clients=fake_clients)
scenario._update_user_password(password=password, user_id=user.id)
fake_keystone.users.update_password.assert_called_once_with(user.id,
password)
self._test_atomic_action_timer(scenario.atomic_actions(),
"keystone.update_user_password")
def test_get_service_by_name(self): def test_get_service_by_name(self):
scenario = utils.KeystoneScenario() scenario = utils.KeystoneScenario()
svc_foo, svc_bar = mock.Mock(), mock.Mock() svc_foo, svc_bar = mock.Mock(), mock.Mock()