diff --git a/rally-jobs/rally-keystone-api-v2.yaml b/rally-jobs/rally-keystone-api-v2.yaml index 88b25a02b8..30d7a20851 100644 --- a/rally-jobs/rally-keystone-api-v2.yaml +++ b/rally-jobs/rally-keystone-api-v2.yaml @@ -186,6 +186,24 @@ failure_rate: max: 0 + KeystoneBasic.create_and_update_user: + - + args: + create_user_kwargs: {} + update_user_kwargs: + email: "newemail@rally.me" + runner: + type: "constant" + times: 10 + concurrency: 2 + context: + users: + tenants: 3 + users_per_tenant: 2 + sla: + failure_rate: + max: 0 + KeystoneBasic.create_update_and_delete_tenant: - args: {} diff --git a/rally-jobs/rally.yaml b/rally-jobs/rally.yaml index d96f41b41d..d8af8b2151 100644 --- a/rally-jobs/rally.yaml +++ b/rally-jobs/rally.yaml @@ -200,6 +200,24 @@ failure_rate: max: 0 + KeystoneBasic.create_and_update_user: + - + args: + create_user_kwargs: {} + update_user_kwargs: + enabled: False + runner: + type: "constant" + times: 10 + concurrency: 2 + context: + users: + tenants: 2 + users_per_tenant: 2 + sla: + failure_rate: + max: 0 + KeystoneBasic.create_update_and_delete_tenant: - args: {} diff --git a/rally/plugins/openstack/scenarios/keystone/basic.py b/rally/plugins/openstack/scenarios/keystone/basic.py index eaa3f4194d..f150b24c53 100755 --- a/rally/plugins/openstack/scenarios/keystone/basic.py +++ b/rally/plugins/openstack/scenarios/keystone/basic.py @@ -388,3 +388,28 @@ class CreateAddListRoles(KeystoneBasic): msg = ("Created role is not in the" " list of all available roles") self.assertIn(role, all_roles, err_msg=msg) + + +@validation.required_openstack(admin=True) +@scenario.configure(context={"admin_cleanup": ["keystone"]}, + name="KeystoneBasic.create_and_update_user") +class CreateAndUpdateUser(KeystoneBasic): + + def run(self, create_user_kwargs=None, update_user_kwargs=None): + """Create user and update the user. + + :param create_user_kwargs: Optional additional arguments for user + creation + :param update_user_kwargs: Optional additional arguments for user + updation + """ + create_user_kwargs = create_user_kwargs or {} + + user = self.admin_keystone.create_user(**create_user_kwargs) + self.admin_keystone.update_user(user.id, **update_user_kwargs) + user_data = self.admin_clients("keystone").users.get(user.id) + + for args in update_user_kwargs: + msg = ("%s isn't updated" % args) + self.assertEqual(getattr(user_data, str(args)), + update_user_kwargs[args], err_msg=msg) diff --git a/samples/tasks/scenarios/keystone/create-and-update-user.json b/samples/tasks/scenarios/keystone/create-and-update-user.json new file mode 100644 index 0000000000..04a74de468 --- /dev/null +++ b/samples/tasks/scenarios/keystone/create-and-update-user.json @@ -0,0 +1,28 @@ +{ + "KeystoneBasic.create_and_update_user": [ + { + "args": { + "create_user_kwargs": {}, + "update_user_kwargs": { + "enabled": false + } + }, + "runner": { + "type": "constant", + "times": 10, + "concurrency": 2 + }, + "context": { + "users": { + "tenants": 2, + "users_per_tenant": 2 + } + }, + "sla": { + "failure_rate": { + "max": 0 + } + } + } + ] +} diff --git a/samples/tasks/scenarios/keystone/create-and-update-user.yaml b/samples/tasks/scenarios/keystone/create-and-update-user.yaml new file mode 100644 index 0000000000..d9a7d1b94b --- /dev/null +++ b/samples/tasks/scenarios/keystone/create-and-update-user.yaml @@ -0,0 +1,18 @@ +--- + KeystoneBasic.create_and_update_user: + - + args: + create_user_kwargs: {} + update_user_kwargs: + enabled: false + runner: + type: "constant" + times: 10 + concurrency: 2 + context: + users: + tenants: 2 + users_per_tenant: 2 + sla: + failure_rate: + max: 0 diff --git a/tests/unit/plugins/openstack/scenarios/keystone/test_basic.py b/tests/unit/plugins/openstack/scenarios/keystone/test_basic.py index b1f6d764bd..fe1f9b9b6d 100755 --- a/tests/unit/plugins/openstack/scenarios/keystone/test_basic.py +++ b/tests/unit/plugins/openstack/scenarios/keystone/test_basic.py @@ -305,6 +305,25 @@ class KeystoneBasicTestCase(test.ScenarioTestCase): identity_service.update_user.assert_called_once_with( fake_user.id, password=fake_password) + def test_create_and_update_user(self): + identity_service = self.mock_identity.return_value + + scenario = basic.CreateAndUpdateUser(self.context) + scenario.admin_clients("keystone").users.get = mock.MagicMock() + fake_user = identity_service.create_user.return_value + + create_args = {"fakearg1": "f"} + update_args = {"fakearg1": "fakearg"} + setattr(self.admin_clients("keystone").users.get.return_value, + "fakearg1", "fakearg") + + scenario.run(create_user_kwargs=create_args, + update_user_kwargs=update_args) + + identity_service.create_user.assert_called_once_with(**create_args) + identity_service.update_user.assert_called_once_with( + fake_user.id, **update_args) + def test_create_and_list_services(self): identity_service = self.mock_identity.return_value