Keystone: do not allow specifying service names
This fixes service cleanup. Keystone resources are only cleaned up if they have the correct magic prefix, but services were not reliably created with that prefix. This also adds some logging that made it easier to discover this issue, and fixes a few minor typos. Closes-Bug: #1474322 Change-Id: Ic58271bbc9a84feff4f60229a66e0ca00834a79c
This commit is contained in:
parent
557f1ef21e
commit
1ece21931e
@ -13,6 +13,7 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from rally.common import utils
|
||||
from rally.plugins.openstack.scenarios.keystone import utils as kutils
|
||||
from rally.task.scenarios import base
|
||||
from rally.task import validation
|
||||
@ -155,16 +156,18 @@ class KeystoneBasic(kutils.KeystoneScenario):
|
||||
self._get_service(service.id)
|
||||
|
||||
@validation.required_openstack(admin=True)
|
||||
@utils.log_deprecated_args(
|
||||
"The 'name' argument to create_and_delete_service will be ignored",
|
||||
"0.0.5", ["name"])
|
||||
@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)
|
||||
service = self._service_create(service_type, description)
|
||||
self._delete_service(service.id)
|
||||
|
||||
@validation.number("name_length", minval=10)
|
||||
@ -195,16 +198,18 @@ class KeystoneBasic(kutils.KeystoneScenario):
|
||||
self._update_user_password(user.id, password)
|
||||
|
||||
@validation.required_openstack(admin=True)
|
||||
@utils.log_deprecated_args(
|
||||
"The 'name' argument to create_and_list_services will be ignored",
|
||||
"0.0.5", ["name"])
|
||||
@base.scenario(context={"admin_cleanup": ["keystone"]})
|
||||
def create_and_list_services(self, name=None, service_type=None,
|
||||
description=None):
|
||||
"""Create and list services.
|
||||
|
||||
:param name: name of the service
|
||||
:param service_type: type of the service
|
||||
:param description: description of the service
|
||||
"""
|
||||
self._service_create(name, service_type, description)
|
||||
self._service_create(service_type, description)
|
||||
self._list_services()
|
||||
|
||||
@validation.required_openstack(users=True)
|
||||
|
@ -63,7 +63,7 @@ class KeystoneScenario(base.Scenario):
|
||||
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",
|
||||
def _service_create(self, service_type="rally_test_type",
|
||||
description=None):
|
||||
"""Creates keystone service with random name.
|
||||
|
||||
@ -72,12 +72,11 @@ class KeystoneScenario(base.Scenario):
|
||||
: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)
|
||||
return self.admin_clients("keystone").services.create(
|
||||
self._generate_random_name(),
|
||||
service_type, description)
|
||||
|
||||
@base.atomic_action_timer("keystone.create_users")
|
||||
def _users_create(self, tenant, users_per_tenant, name_length=10):
|
||||
|
@ -2,8 +2,7 @@
|
||||
"KeystoneBasic.create_and_delete_service": [
|
||||
{
|
||||
"args": {
|
||||
"name": "Rally_test_service",
|
||||
"service_type": "Really_test_type",
|
||||
"service_type": "Rally_test_type",
|
||||
"description": "test_description"
|
||||
},
|
||||
"runner": {
|
||||
|
@ -2,8 +2,7 @@
|
||||
KeystoneBasic.create_and_delete_service:
|
||||
-
|
||||
args:
|
||||
name: "Rally_test_service"
|
||||
service_type: "Really_test_type"
|
||||
service_type: "Rally_test_type"
|
||||
description: "test_description"
|
||||
runner:
|
||||
type: "constant"
|
||||
|
@ -2,8 +2,7 @@
|
||||
"KeystoneBasic.create_and_list_services": [
|
||||
{
|
||||
"args": {
|
||||
"name": "Rally_test_service",
|
||||
"service_type": "Really_test_type",
|
||||
"service_type": "Rally_test_type",
|
||||
"description": "test_description"
|
||||
},
|
||||
"runner": {
|
||||
|
@ -2,8 +2,7 @@
|
||||
KeystoneBasic.create_and_list_services:
|
||||
-
|
||||
args:
|
||||
name: "Rally_test_service"
|
||||
service_type: "Really_test_type"
|
||||
service_type: "Rally_test_type"
|
||||
description: "test_description"
|
||||
runner:
|
||||
type: "constant"
|
||||
|
@ -194,17 +194,14 @@ class KeystoneBasicTestCase(test.TestCase):
|
||||
|
||||
def test_create_and_delete_service(self):
|
||||
scenario = basic.KeystoneBasic()
|
||||
name = "Rally_test_service"
|
||||
service_type = "rally_test_type"
|
||||
service_type = "test_service_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,
|
||||
scenario.create_and_delete_service(service_type=service_type,
|
||||
description=description)
|
||||
scenario._service_create.assert_called_once_with(name,
|
||||
service_type,
|
||||
scenario._service_create.assert_called_once_with(service_type,
|
||||
description)
|
||||
scenario._delete_service.assert_called_once_with(fake_service.id)
|
||||
|
||||
@ -235,17 +232,14 @@ class KeystoneBasicTestCase(test.TestCase):
|
||||
|
||||
def test_create_and_list_services(self):
|
||||
scenario = basic.KeystoneBasic()
|
||||
name = "Rally_test_service"
|
||||
service_type = "rally_test_type"
|
||||
service_type = "test_service_type"
|
||||
description = "test_description"
|
||||
fake_service = mock.MagicMock()
|
||||
scenario._service_create = mock.MagicMock(return_value=fake_service)
|
||||
scenario._list_services = mock.MagicMock()
|
||||
scenario.create_and_list_services(name=name,
|
||||
service_type=service_type,
|
||||
scenario.create_and_list_services(service_type=service_type,
|
||||
description=description)
|
||||
scenario._service_create.assert_called_once_with(name,
|
||||
service_type,
|
||||
scenario._service_create.assert_called_once_with(service_type,
|
||||
description)
|
||||
scenario._list_services.assert_called_once_with()
|
||||
|
||||
|
@ -142,21 +142,21 @@ class KeystoneScenarioTestCase(test.ScenarioTestCase):
|
||||
"keystone.create_tenant")
|
||||
|
||||
def test_service_create(self):
|
||||
name = "abc"
|
||||
service_type = name + "_service_type"
|
||||
description = name + "_description"
|
||||
service_type = "service_type"
|
||||
description = "_description"
|
||||
|
||||
scenario = utils.KeystoneScenario()
|
||||
scenario._generate_random_name = mock.Mock()
|
||||
|
||||
result = scenario._service_create(name=name,
|
||||
service_type=service_type,
|
||||
result = scenario._service_create(service_type=service_type,
|
||||
description=description)
|
||||
|
||||
self.assertEqual(
|
||||
self.admin_clients("keystone").services.create.return_value,
|
||||
result)
|
||||
self.admin_clients("keystone").services.create.assert_called_once_with(
|
||||
name, service_type, description)
|
||||
scenario._generate_random_name.return_value,
|
||||
service_type, description)
|
||||
self._test_atomic_action_timer(scenario.atomic_actions(),
|
||||
"keystone.create_service")
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user