Skip to content

Commit

Permalink
Add keystone update_user_password scenario
Browse files Browse the repository at this point in the history
API covered users.update_password

Change-Id: Ie947d7aa59b3b9151d94a6958fc4eab6c4521385
  • Loading branch information
Serhii Vasheka committed Apr 22, 2015
1 parent 6bb572e commit 5a8b980
Show file tree
Hide file tree
Showing 7 changed files with 93 additions and 0 deletions.
13 changes: 13 additions & 0 deletions rally-jobs/rally.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,19 @@
failure_rate:
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:
-
args:
Expand Down
14 changes: 14 additions & 0 deletions rally/benchmark/scenarios/keystone/basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,20 @@ def create_update_and_delete_tenant(self, name_length=10, **kwargs):
self._update_tenant(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)
@base.scenario(context={"admin_cleanup": ["keystone"]})
def create_and_list_services(self, name=None, service_type=None,
Expand Down
10 changes: 10 additions & 0 deletions rally/benchmark/scenarios/keystone/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,3 +177,13 @@ def _update_tenant(self, tenant, name=None, description=None):
description = description or (tenant.name + "_description_updated")
self.admin_clients("keystone").tenants.update(tenant.id,
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)
15 changes: 15 additions & 0 deletions samples/tasks/scenarios/keystone/create_user_update_password.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"KeystoneBasic.create_user_update_password": [
{
"args": {
"name_length": 10,
"password_length": 10
},
"runner": {
"type": "constant",
"times": 100,
"concurrency": 10
}
}
]
}
10 changes: 10 additions & 0 deletions samples/tasks/scenarios/keystone/create_user_update_password.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
KeystoneBasic.create_user_update_password:
-
args:
name_length: 10
password_length: 10
runner:
type: "constant"
times: 100
concurrency: 10
15 changes: 15 additions & 0 deletions tests/unit/benchmark/scenarios/keystone/test_basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,21 @@ def test_create_update_and_delete_tenant(self):
scenario._update_tenant.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):
scenario = basic.KeystoneBasic()
name = "Rally_test_service"
Expand Down
16 changes: 16 additions & 0 deletions tests/unit/benchmark/scenarios/keystone/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,22 @@ def test_update_tenant(self):
self._test_atomic_action_timer(scenario.atomic_actions(),
"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):
scenario = utils.KeystoneScenario()
svc_foo, svc_bar = mock.Mock(), mock.Mock()
Expand Down

0 comments on commit 5a8b980

Please sign in to comment.