Merge "Add keystone create_and_delete_service scenario"
This commit is contained in:
commit
bcb891086c
@ -98,6 +98,16 @@
|
|||||||
failure_rate:
|
failure_rate:
|
||||||
max: 0
|
max: 0
|
||||||
|
|
||||||
|
KeystoneBasic.create_and_delete_service:
|
||||||
|
-
|
||||||
|
runner:
|
||||||
|
type: "constant"
|
||||||
|
times: 10
|
||||||
|
concurrency: 5
|
||||||
|
sla:
|
||||||
|
failure_rate:
|
||||||
|
max: 0
|
||||||
|
|
||||||
CeilometerAlarms.create_alarm:
|
CeilometerAlarms.create_alarm:
|
||||||
-
|
-
|
||||||
args:
|
args:
|
||||||
|
@ -111,3 +111,16 @@ class KeystoneBasic(kutils.KeystoneScenario):
|
|||||||
self._get_role(role.id)
|
self._get_role(role.id)
|
||||||
service = self._get_service_by_name("keystone")
|
service = self._get_service_by_name("keystone")
|
||||||
self._get_service(service.id)
|
self._get_service(service.id)
|
||||||
|
|
||||||
|
@validation.required_openstack(admin=True)
|
||||||
|
@base.scenario(context={"admin_cleanup": ["keystone"]})
|
||||||
|
def create_and_delete_service(self, name=None, service_type=None,
|
||||||
|
description=None):
|
||||||
|
"""Create and delete service.
|
||||||
|
|
||||||
|
:param name: name of the service
|
||||||
|
:param service_type: type of the service
|
||||||
|
:param description: description of the service
|
||||||
|
"""
|
||||||
|
service = self._service_create(name, service_type, description)
|
||||||
|
self._delete_service(service.id)
|
||||||
|
@ -62,6 +62,23 @@ class KeystoneScenario(base.Scenario):
|
|||||||
name = self._generate_random_name(length=name_length)
|
name = self._generate_random_name(length=name_length)
|
||||||
return self.admin_clients("keystone").tenants.create(name, **kwargs)
|
return self.admin_clients("keystone").tenants.create(name, **kwargs)
|
||||||
|
|
||||||
|
@base.atomic_action_timer("keystone.create_service")
|
||||||
|
def _service_create(self, name=None, service_type="rally_test_type",
|
||||||
|
description=None):
|
||||||
|
"""Creates keystone service with random name.
|
||||||
|
|
||||||
|
:param name: name of the service
|
||||||
|
:param service_type: type of the service
|
||||||
|
:param description: description of the service
|
||||||
|
:returns: keystone service instance
|
||||||
|
"""
|
||||||
|
name = name or self._generate_random_name(prefix="rally_test_service_")
|
||||||
|
description = description or self._generate_random_name(
|
||||||
|
prefix="rally_test_service_description_")
|
||||||
|
return self.admin_clients("keystone").services.create(name,
|
||||||
|
service_type,
|
||||||
|
description)
|
||||||
|
|
||||||
@base.atomic_action_timer("keystone.create_users")
|
@base.atomic_action_timer("keystone.create_users")
|
||||||
def _users_create(self, tenant, users_per_tenant, name_length=10):
|
def _users_create(self, tenant, users_per_tenant, name_length=10):
|
||||||
"""Adds users to a tenant.
|
"""Adds users to a tenant.
|
||||||
@ -139,3 +156,11 @@ class KeystoneScenario(base.Scenario):
|
|||||||
for i in self._list_services():
|
for i in self._list_services():
|
||||||
if i.name == name:
|
if i.name == name:
|
||||||
return i
|
return i
|
||||||
|
|
||||||
|
@base.atomic_action_timer("keystone.delete_service")
|
||||||
|
def _delete_service(self, service_id):
|
||||||
|
"""Delete service.
|
||||||
|
|
||||||
|
:param service_id: service to be deleted
|
||||||
|
"""
|
||||||
|
self.admin_clients("keystone").services.delete(service_id)
|
||||||
|
@ -0,0 +1,16 @@
|
|||||||
|
{
|
||||||
|
"KeystoneBasic.create_and_delete_service": [
|
||||||
|
{
|
||||||
|
"args": {
|
||||||
|
"name": "Rally_test_service",
|
||||||
|
"service_type": "Really_test_type",
|
||||||
|
"description": "test_description"
|
||||||
|
},
|
||||||
|
"runner": {
|
||||||
|
"type": "constant",
|
||||||
|
"times": 100,
|
||||||
|
"concurrency": 10
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
@ -0,0 +1,11 @@
|
|||||||
|
---
|
||||||
|
KeystoneBasic.create_and_delete_service:
|
||||||
|
-
|
||||||
|
args:
|
||||||
|
name: "Rally_test_service"
|
||||||
|
service_type: "Really_test_type"
|
||||||
|
description: "test_description"
|
||||||
|
runner:
|
||||||
|
type: "constant"
|
||||||
|
times: 100
|
||||||
|
concurrency: 10
|
@ -124,3 +124,19 @@ class KeystoneBasicTestCase(test.TestCase):
|
|||||||
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")
|
scenario._get_service_by_name("keystone")
|
||||||
scenario._get_service.assert_called_once_with(fake_service.id)
|
scenario._get_service.assert_called_once_with(fake_service.id)
|
||||||
|
|
||||||
|
def test_create_and_delete_service(self):
|
||||||
|
scenario = basic.KeystoneBasic()
|
||||||
|
name = "Rally_test_service"
|
||||||
|
service_type = "rally_test_type"
|
||||||
|
description = "test_description"
|
||||||
|
fake_service = mock.MagicMock()
|
||||||
|
scenario._service_create = mock.MagicMock(return_value=fake_service)
|
||||||
|
scenario._delete_service = mock.MagicMock()
|
||||||
|
scenario.create_and_delete_service(name=name,
|
||||||
|
service_type=service_type,
|
||||||
|
description=description)
|
||||||
|
scenario._service_create.assert_called_once_with(name,
|
||||||
|
service_type,
|
||||||
|
description)
|
||||||
|
scenario._delete_service.assert_called_once_with(fake_service.id)
|
||||||
|
@ -121,6 +121,31 @@ class KeystoneScenarioTestCase(test.TestCase):
|
|||||||
self._test_atomic_action_timer(scenario.atomic_actions(),
|
self._test_atomic_action_timer(scenario.atomic_actions(),
|
||||||
"keystone.create_tenant")
|
"keystone.create_tenant")
|
||||||
|
|
||||||
|
@mock.patch(UTILS + "KeystoneScenario._generate_random_name")
|
||||||
|
def test_service_create(self, mock_gen_name):
|
||||||
|
name = "abc"
|
||||||
|
mock_gen_name.return_value = name
|
||||||
|
service_type = name + "service_type"
|
||||||
|
description = name + "_description"
|
||||||
|
|
||||||
|
service = {}
|
||||||
|
fake_keystone = fakes.FakeKeystoneClient()
|
||||||
|
fake_keystone.services.create = mock.MagicMock(return_value=service)
|
||||||
|
fake_clients = fakes.FakeClients()
|
||||||
|
fake_clients._keystone = fake_keystone
|
||||||
|
scenario = utils.KeystoneScenario(admin_clients=fake_clients)
|
||||||
|
|
||||||
|
result = scenario._service_create(name=name,
|
||||||
|
service_type=service_type,
|
||||||
|
description=description)
|
||||||
|
|
||||||
|
self.assertEqual(service, result)
|
||||||
|
fake_keystone.services.create.assert_called_once_with(name,
|
||||||
|
service_type,
|
||||||
|
description)
|
||||||
|
self._test_atomic_action_timer(scenario.atomic_actions(),
|
||||||
|
"keystone.create_service")
|
||||||
|
|
||||||
@mock.patch(UTILS + "KeystoneScenario._generate_random_name")
|
@mock.patch(UTILS + "KeystoneScenario._generate_random_name")
|
||||||
def test_tenant_create_with_users(self, mock_gen_name):
|
def test_tenant_create_with_users(self, mock_gen_name):
|
||||||
name = "abc"
|
name = "abc"
|
||||||
@ -163,6 +188,33 @@ class KeystoneScenarioTestCase(test.TestCase):
|
|||||||
self._test_atomic_action_timer(scenario.atomic_actions(),
|
self._test_atomic_action_timer(scenario.atomic_actions(),
|
||||||
"keystone.list_tenants")
|
"keystone.list_tenants")
|
||||||
|
|
||||||
|
def test_list_services(self):
|
||||||
|
fake_keystone = fakes.FakeKeystoneClient()
|
||||||
|
fake_keystone.services.list = mock.MagicMock()
|
||||||
|
fake_clients = fakes.FakeClients()
|
||||||
|
fake_clients._keystone = fake_keystone
|
||||||
|
scenario = utils.KeystoneScenario(admin_clients=fake_clients)
|
||||||
|
|
||||||
|
scenario._list_services()
|
||||||
|
|
||||||
|
fake_keystone.services.list.assert_called_once_with()
|
||||||
|
self._test_atomic_action_timer(scenario.atomic_actions(),
|
||||||
|
"keystone.service_list")
|
||||||
|
|
||||||
|
def test_delete_service(self):
|
||||||
|
service = mock.MagicMock()
|
||||||
|
fake_keystone = fakes.FakeKeystoneClient()
|
||||||
|
fake_keystone.services.delete = mock.MagicMock()
|
||||||
|
fake_clients = fakes.FakeClients()
|
||||||
|
fake_clients._keystone = fake_keystone
|
||||||
|
scenario = utils.KeystoneScenario(admin_clients=fake_clients)
|
||||||
|
|
||||||
|
scenario._delete_service(service_id=service.id)
|
||||||
|
|
||||||
|
fake_keystone.services.delete.assert_called_once_with(service.id)
|
||||||
|
self._test_atomic_action_timer(scenario.atomic_actions(),
|
||||||
|
"keystone.delete_service")
|
||||||
|
|
||||||
def test_get_tenant(self):
|
def test_get_tenant(self):
|
||||||
tenant = mock.MagicMock()
|
tenant = mock.MagicMock()
|
||||||
fake_keystone = fakes.FakeKeystoneClient()
|
fake_keystone = fakes.FakeKeystoneClient()
|
||||||
|
Loading…
Reference in New Issue
Block a user