Merge "Keystone get_entities scenario backwards compat"
This commit is contained in:
commit
48e8c56830
@ -44,6 +44,26 @@
|
|||||||
sla:
|
sla:
|
||||||
failure_rate:
|
failure_rate:
|
||||||
max: 0
|
max: 0
|
||||||
|
-
|
||||||
|
args:
|
||||||
|
service_name: null
|
||||||
|
runner:
|
||||||
|
type: "constant"
|
||||||
|
times: 20
|
||||||
|
concurrency: 10
|
||||||
|
sla:
|
||||||
|
failure_rate:
|
||||||
|
max: 0
|
||||||
|
-
|
||||||
|
args:
|
||||||
|
service_name: "nova"
|
||||||
|
runner:
|
||||||
|
type: "constant"
|
||||||
|
times: 20
|
||||||
|
concurrency: 10
|
||||||
|
sla:
|
||||||
|
failure_rate:
|
||||||
|
max: 0
|
||||||
|
|
||||||
KeystoneBasic.add_and_remove_user_role:
|
KeystoneBasic.add_and_remove_user_role:
|
||||||
-
|
-
|
||||||
|
@ -128,15 +128,30 @@ class KeystoneBasic(kutils.KeystoneScenario):
|
|||||||
|
|
||||||
@validation.required_openstack(admin=True)
|
@validation.required_openstack(admin=True)
|
||||||
@base.scenario(context={"admin_cleanup": ["keystone"]})
|
@base.scenario(context={"admin_cleanup": ["keystone"]})
|
||||||
def get_entities(self):
|
def get_entities(self, service_name="keystone"):
|
||||||
"""Get instance of a tenant, user, role and service by id's."""
|
"""Get instance of a tenant, user, role and service by id's.
|
||||||
|
|
||||||
|
An ephemeral tenant, user, and role are each created. By
|
||||||
|
default, fetches the 'keystone' service. This can be
|
||||||
|
overridden (for instance, to get the 'Identity Service'
|
||||||
|
service on older OpenStack), or None can be passed explicitly
|
||||||
|
to service_name to create a new service and then query it by
|
||||||
|
ID.
|
||||||
|
|
||||||
|
:param service_name: The name of the service to get by ID; or
|
||||||
|
None, to create an ephemeral service and
|
||||||
|
get it by ID.
|
||||||
|
"""
|
||||||
tenant = self._tenant_create(name_length=5)
|
tenant = self._tenant_create(name_length=5)
|
||||||
user = self._user_create(name_length=10)
|
user = self._user_create(name_length=10)
|
||||||
role = self._role_create()
|
role = self._role_create()
|
||||||
self._get_tenant(tenant.id)
|
self._get_tenant(tenant.id)
|
||||||
self._get_user(user.id)
|
self._get_user(user.id)
|
||||||
self._get_role(role.id)
|
self._get_role(role.id)
|
||||||
service = self._get_service_by_name("keystone")
|
if service_name is None:
|
||||||
|
service = self._service_create()
|
||||||
|
else:
|
||||||
|
service = self._get_service_by_name(service_name)
|
||||||
self._get_service(service.id)
|
self._get_service(service.id)
|
||||||
|
|
||||||
@validation.required_openstack(admin=True)
|
@validation.required_openstack(admin=True)
|
||||||
|
@ -146,32 +146,52 @@ class KeystoneBasicTestCase(test.TestCase):
|
|||||||
scenario._list_roles_for_user.assert_called_once_with(fake_user,
|
scenario._list_roles_for_user.assert_called_once_with(fake_user,
|
||||||
fake_tenant)
|
fake_tenant)
|
||||||
|
|
||||||
@mock.patch("rally.common.utils.generate_random_name")
|
def _test_get_entities(self, service_name="keystone"):
|
||||||
def test_get_entities(self, mock_generate_random_name):
|
|
||||||
scenario = basic.KeystoneBasic()
|
scenario = basic.KeystoneBasic()
|
||||||
fake_tenant = mock.MagicMock()
|
fake_tenant = mock.MagicMock()
|
||||||
fake_user = mock.MagicMock()
|
fake_user = mock.MagicMock()
|
||||||
fake_role = mock.MagicMock()
|
fake_role = mock.MagicMock()
|
||||||
fake_service = mock.MagicMock()
|
fake_service = mock.MagicMock()
|
||||||
|
|
||||||
scenario._tenant_create = mock.MagicMock(return_value=fake_tenant)
|
scenario._tenant_create = mock.MagicMock(return_value=fake_tenant)
|
||||||
scenario._user_create = mock.MagicMock(return_value=fake_user)
|
scenario._user_create = mock.MagicMock(return_value=fake_user)
|
||||||
scenario._role_create = mock.MagicMock(return_value=fake_role)
|
scenario._role_create = mock.MagicMock(return_value=fake_role)
|
||||||
|
scenario._service_create = mock.MagicMock(return_value=fake_service)
|
||||||
|
|
||||||
scenario._get_tenant = mock.MagicMock(return_value=fake_tenant)
|
scenario._get_tenant = mock.MagicMock(return_value=fake_tenant)
|
||||||
scenario._get_user = mock.MagicMock(return_value=fake_user)
|
scenario._get_user = mock.MagicMock(return_value=fake_user)
|
||||||
scenario._get_role = mock.MagicMock(return_value=fake_role)
|
scenario._get_role = mock.MagicMock(return_value=fake_role)
|
||||||
scenario._get_service_by_name = mock.MagicMock(
|
scenario._get_service_by_name = mock.MagicMock(
|
||||||
return_value=fake_service)
|
return_value=fake_service)
|
||||||
scenario._get_service = mock.MagicMock(return_value=fake_service)
|
scenario._get_service = mock.MagicMock(return_value=fake_service)
|
||||||
scenario.get_entities()
|
|
||||||
|
scenario.get_entities(service_name)
|
||||||
|
|
||||||
scenario._tenant_create.assert_called_once_with(name_length=5)
|
scenario._tenant_create.assert_called_once_with(name_length=5)
|
||||||
scenario._user_create.assert_called_once_with(name_length=10)
|
scenario._user_create.assert_called_once_with(name_length=10)
|
||||||
scenario._role_create.assert_called_once_with()
|
scenario._role_create.assert_called_once_with()
|
||||||
|
|
||||||
scenario._get_tenant.assert_called_once_with(fake_tenant.id)
|
scenario._get_tenant.assert_called_once_with(fake_tenant.id)
|
||||||
scenario._get_user.assert_called_once_with(fake_user.id)
|
scenario._get_user.assert_called_once_with(fake_user.id)
|
||||||
scenario._get_role.assert_called_once_with(fake_role.id)
|
scenario._get_role.assert_called_once_with(fake_role.id)
|
||||||
scenario._get_service_by_name("keystone")
|
|
||||||
|
if service_name is None:
|
||||||
|
scenario._service_create.assert_called_once_with()
|
||||||
|
self.assertFalse(scenario._get_service_by_name.called)
|
||||||
|
else:
|
||||||
|
scenario._get_service_by_name.assert_called_once_with(service_name)
|
||||||
|
self.assertFalse(scenario._service_create.called)
|
||||||
scenario._get_service.assert_called_once_with(fake_service.id)
|
scenario._get_service.assert_called_once_with(fake_service.id)
|
||||||
|
|
||||||
|
def test_get_entities(self):
|
||||||
|
self._test_get_entities()
|
||||||
|
|
||||||
|
def test_get_entities_with_service_name(self):
|
||||||
|
self._test_get_entities(service_name="fooservice")
|
||||||
|
|
||||||
|
def test_get_entities_create_service(self):
|
||||||
|
self._test_get_entities(service_name=None)
|
||||||
|
|
||||||
def test_create_and_delete_service(self):
|
def test_create_and_delete_service(self):
|
||||||
scenario = basic.KeystoneBasic()
|
scenario = basic.KeystoneBasic()
|
||||||
name = "Rally_test_service"
|
name = "Rally_test_service"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user