diff --git a/rally-jobs/rally.yaml b/rally-jobs/rally.yaml index bb7b75f934..3a5c185508 100755 --- a/rally-jobs/rally.yaml +++ b/rally-jobs/rally.yaml @@ -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: diff --git a/rally/benchmark/scenarios/keystone/basic.py b/rally/benchmark/scenarios/keystone/basic.py index fee5e946d6..8c2ca97223 100644 --- a/rally/benchmark/scenarios/keystone/basic.py +++ b/rally/benchmark/scenarios/keystone/basic.py @@ -138,6 +138,20 @@ class KeystoneBasic(kutils.KeystoneScenario): 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, diff --git a/rally/benchmark/scenarios/keystone/utils.py b/rally/benchmark/scenarios/keystone/utils.py index 0311b896c3..1139e53d74 100644 --- a/rally/benchmark/scenarios/keystone/utils.py +++ b/rally/benchmark/scenarios/keystone/utils.py @@ -177,3 +177,13 @@ class KeystoneScenario(base.Scenario): 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) diff --git a/samples/tasks/scenarios/keystone/create_user_update_password.json b/samples/tasks/scenarios/keystone/create_user_update_password.json new file mode 100644 index 0000000000..8d5b3063a5 --- /dev/null +++ b/samples/tasks/scenarios/keystone/create_user_update_password.json @@ -0,0 +1,15 @@ +{ + "KeystoneBasic.create_user_update_password": [ + { + "args": { + "name_length": 10, + "password_length": 10 + }, + "runner": { + "type": "constant", + "times": 100, + "concurrency": 10 + } + } + ] +} \ No newline at end of file diff --git a/samples/tasks/scenarios/keystone/create_user_update_password.yaml b/samples/tasks/scenarios/keystone/create_user_update_password.yaml new file mode 100644 index 0000000000..cf414a3530 --- /dev/null +++ b/samples/tasks/scenarios/keystone/create_user_update_password.yaml @@ -0,0 +1,10 @@ +--- + KeystoneBasic.create_user_update_password: + - + args: + name_length: 10 + password_length: 10 + runner: + type: "constant" + times: 100 + concurrency: 10 \ No newline at end of file diff --git a/tests/unit/benchmark/scenarios/keystone/test_basic.py b/tests/unit/benchmark/scenarios/keystone/test_basic.py index 3e5899d64b..b9c5f76870 100644 --- a/tests/unit/benchmark/scenarios/keystone/test_basic.py +++ b/tests/unit/benchmark/scenarios/keystone/test_basic.py @@ -151,6 +151,21 @@ class KeystoneBasicTestCase(test.TestCase): 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" diff --git a/tests/unit/benchmark/scenarios/keystone/test_utils.py b/tests/unit/benchmark/scenarios/keystone/test_utils.py index 8c97190814..df303d09f9 100644 --- a/tests/unit/benchmark/scenarios/keystone/test_utils.py +++ b/tests/unit/benchmark/scenarios/keystone/test_utils.py @@ -289,6 +289,22 @@ class KeystoneScenarioTestCase(test.TestCase): 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()