Add keystone.CreateAndUpdateUser scenario

Create user and update the user.

Change-Id: Ic523b7b2d225f9eece076c7263eb87915f2b4301
This commit is contained in:
zhangzhang 2016-09-29 00:43:03 -04:00
parent 2558a22a80
commit 50e87cea24
6 changed files with 126 additions and 0 deletions

View File

@ -186,6 +186,24 @@
failure_rate: failure_rate:
max: 0 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: KeystoneBasic.create_update_and_delete_tenant:
- -
args: {} args: {}

View File

@ -200,6 +200,24 @@
failure_rate: failure_rate:
max: 0 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: KeystoneBasic.create_update_and_delete_tenant:
- -
args: {} args: {}

View File

@ -388,3 +388,28 @@ class CreateAddListRoles(KeystoneBasic):
msg = ("Created role is not in the" msg = ("Created role is not in the"
" list of all available roles") " list of all available roles")
self.assertIn(role, all_roles, err_msg=msg) 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)

View File

@ -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
}
}
}
]
}

View File

@ -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

View File

@ -305,6 +305,25 @@ class KeystoneBasicTestCase(test.ScenarioTestCase):
identity_service.update_user.assert_called_once_with( identity_service.update_user.assert_called_once_with(
fake_user.id, password=fake_password) 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): def test_create_and_list_services(self):
identity_service = self.mock_identity.return_value identity_service = self.mock_identity.return_value