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
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
|
from rally.common import utils
|
||||||
from rally.plugins.openstack.scenarios.keystone import utils as kutils
|
from rally.plugins.openstack.scenarios.keystone import utils as kutils
|
||||||
from rally.task.scenarios import base
|
from rally.task.scenarios import base
|
||||||
from rally.task import validation
|
from rally.task import validation
|
||||||
@ -155,16 +156,18 @@ class KeystoneBasic(kutils.KeystoneScenario):
|
|||||||
self._get_service(service.id)
|
self._get_service(service.id)
|
||||||
|
|
||||||
@validation.required_openstack(admin=True)
|
@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"]})
|
@base.scenario(context={"admin_cleanup": ["keystone"]})
|
||||||
def create_and_delete_service(self, name=None, service_type=None,
|
def create_and_delete_service(self, name=None, service_type=None,
|
||||||
description=None):
|
description=None):
|
||||||
"""Create and delete service.
|
"""Create and delete service.
|
||||||
|
|
||||||
:param name: name of the service
|
|
||||||
:param service_type: type of the service
|
:param service_type: type of the service
|
||||||
:param description: description 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)
|
self._delete_service(service.id)
|
||||||
|
|
||||||
@validation.number("name_length", minval=10)
|
@validation.number("name_length", minval=10)
|
||||||
@ -195,16 +198,18 @@ class KeystoneBasic(kutils.KeystoneScenario):
|
|||||||
self._update_user_password(user.id, password)
|
self._update_user_password(user.id, password)
|
||||||
|
|
||||||
@validation.required_openstack(admin=True)
|
@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"]})
|
@base.scenario(context={"admin_cleanup": ["keystone"]})
|
||||||
def create_and_list_services(self, name=None, service_type=None,
|
def create_and_list_services(self, name=None, service_type=None,
|
||||||
description=None):
|
description=None):
|
||||||
"""Create and list services.
|
"""Create and list services.
|
||||||
|
|
||||||
:param name: name of the service
|
|
||||||
:param service_type: type of the service
|
:param service_type: type of the service
|
||||||
:param description: description 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()
|
self._list_services()
|
||||||
|
|
||||||
@validation.required_openstack(users=True)
|
@validation.required_openstack(users=True)
|
||||||
|
@ -63,7 +63,7 @@ class KeystoneScenario(base.Scenario):
|
|||||||
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")
|
@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):
|
description=None):
|
||||||
"""Creates keystone service with random name.
|
"""Creates keystone service with random name.
|
||||||
|
|
||||||
@ -72,12 +72,11 @@ class KeystoneScenario(base.Scenario):
|
|||||||
:param description: description of the service
|
:param description: description of the service
|
||||||
:returns: keystone service instance
|
:returns: keystone service instance
|
||||||
"""
|
"""
|
||||||
name = name or self._generate_random_name(prefix="rally_test_service_")
|
|
||||||
description = description or self._generate_random_name(
|
description = description or self._generate_random_name(
|
||||||
prefix="rally_test_service_description_")
|
prefix="rally_test_service_description_")
|
||||||
return self.admin_clients("keystone").services.create(name,
|
return self.admin_clients("keystone").services.create(
|
||||||
service_type,
|
self._generate_random_name(),
|
||||||
description)
|
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):
|
||||||
|
@ -2,8 +2,7 @@
|
|||||||
"KeystoneBasic.create_and_delete_service": [
|
"KeystoneBasic.create_and_delete_service": [
|
||||||
{
|
{
|
||||||
"args": {
|
"args": {
|
||||||
"name": "Rally_test_service",
|
"service_type": "Rally_test_type",
|
||||||
"service_type": "Really_test_type",
|
|
||||||
"description": "test_description"
|
"description": "test_description"
|
||||||
},
|
},
|
||||||
"runner": {
|
"runner": {
|
||||||
|
@ -2,8 +2,7 @@
|
|||||||
KeystoneBasic.create_and_delete_service:
|
KeystoneBasic.create_and_delete_service:
|
||||||
-
|
-
|
||||||
args:
|
args:
|
||||||
name: "Rally_test_service"
|
service_type: "Rally_test_type"
|
||||||
service_type: "Really_test_type"
|
|
||||||
description: "test_description"
|
description: "test_description"
|
||||||
runner:
|
runner:
|
||||||
type: "constant"
|
type: "constant"
|
||||||
|
@ -2,8 +2,7 @@
|
|||||||
"KeystoneBasic.create_and_list_services": [
|
"KeystoneBasic.create_and_list_services": [
|
||||||
{
|
{
|
||||||
"args": {
|
"args": {
|
||||||
"name": "Rally_test_service",
|
"service_type": "Rally_test_type",
|
||||||
"service_type": "Really_test_type",
|
|
||||||
"description": "test_description"
|
"description": "test_description"
|
||||||
},
|
},
|
||||||
"runner": {
|
"runner": {
|
||||||
|
@ -2,8 +2,7 @@
|
|||||||
KeystoneBasic.create_and_list_services:
|
KeystoneBasic.create_and_list_services:
|
||||||
-
|
-
|
||||||
args:
|
args:
|
||||||
name: "Rally_test_service"
|
service_type: "Rally_test_type"
|
||||||
service_type: "Really_test_type"
|
|
||||||
description: "test_description"
|
description: "test_description"
|
||||||
runner:
|
runner:
|
||||||
type: "constant"
|
type: "constant"
|
||||||
|
@ -194,17 +194,14 @@ class KeystoneBasicTestCase(test.TestCase):
|
|||||||
|
|
||||||
def test_create_and_delete_service(self):
|
def test_create_and_delete_service(self):
|
||||||
scenario = basic.KeystoneBasic()
|
scenario = basic.KeystoneBasic()
|
||||||
name = "Rally_test_service"
|
service_type = "test_service_type"
|
||||||
service_type = "rally_test_type"
|
|
||||||
description = "test_description"
|
description = "test_description"
|
||||||
fake_service = mock.MagicMock()
|
fake_service = mock.MagicMock()
|
||||||
scenario._service_create = mock.MagicMock(return_value=fake_service)
|
scenario._service_create = mock.MagicMock(return_value=fake_service)
|
||||||
scenario._delete_service = mock.MagicMock()
|
scenario._delete_service = mock.MagicMock()
|
||||||
scenario.create_and_delete_service(name=name,
|
scenario.create_and_delete_service(service_type=service_type,
|
||||||
service_type=service_type,
|
|
||||||
description=description)
|
description=description)
|
||||||
scenario._service_create.assert_called_once_with(name,
|
scenario._service_create.assert_called_once_with(service_type,
|
||||||
service_type,
|
|
||||||
description)
|
description)
|
||||||
scenario._delete_service.assert_called_once_with(fake_service.id)
|
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):
|
def test_create_and_list_services(self):
|
||||||
scenario = basic.KeystoneBasic()
|
scenario = basic.KeystoneBasic()
|
||||||
name = "Rally_test_service"
|
service_type = "test_service_type"
|
||||||
service_type = "rally_test_type"
|
|
||||||
description = "test_description"
|
description = "test_description"
|
||||||
fake_service = mock.MagicMock()
|
fake_service = mock.MagicMock()
|
||||||
scenario._service_create = mock.MagicMock(return_value=fake_service)
|
scenario._service_create = mock.MagicMock(return_value=fake_service)
|
||||||
scenario._list_services = mock.MagicMock()
|
scenario._list_services = mock.MagicMock()
|
||||||
scenario.create_and_list_services(name=name,
|
scenario.create_and_list_services(service_type=service_type,
|
||||||
service_type=service_type,
|
|
||||||
description=description)
|
description=description)
|
||||||
scenario._service_create.assert_called_once_with(name,
|
scenario._service_create.assert_called_once_with(service_type,
|
||||||
service_type,
|
|
||||||
description)
|
description)
|
||||||
scenario._list_services.assert_called_once_with()
|
scenario._list_services.assert_called_once_with()
|
||||||
|
|
||||||
|
@ -142,21 +142,21 @@ class KeystoneScenarioTestCase(test.ScenarioTestCase):
|
|||||||
"keystone.create_tenant")
|
"keystone.create_tenant")
|
||||||
|
|
||||||
def test_service_create(self):
|
def test_service_create(self):
|
||||||
name = "abc"
|
service_type = "service_type"
|
||||||
service_type = name + "_service_type"
|
description = "_description"
|
||||||
description = name + "_description"
|
|
||||||
|
|
||||||
scenario = utils.KeystoneScenario()
|
scenario = utils.KeystoneScenario()
|
||||||
|
scenario._generate_random_name = mock.Mock()
|
||||||
|
|
||||||
result = scenario._service_create(name=name,
|
result = scenario._service_create(service_type=service_type,
|
||||||
service_type=service_type,
|
|
||||||
description=description)
|
description=description)
|
||||||
|
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
self.admin_clients("keystone").services.create.return_value,
|
self.admin_clients("keystone").services.create.return_value,
|
||||||
result)
|
result)
|
||||||
self.admin_clients("keystone").services.create.assert_called_once_with(
|
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(),
|
self._test_atomic_action_timer(scenario.atomic_actions(),
|
||||||
"keystone.create_service")
|
"keystone.create_service")
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user