Add `extra` parameter to ExistingCloud deployment
Sometimes user needs to specify some extra options related to deployment. Previously it was possible, but after we merged strict json validation, users are not able to do it. Let's provide the way to do it. Also, this patch extends json schema with domain_name variable, since it is used in several places. Change-Id: I675086c97f2f34cf67b86576031f90bb13818ac3
This commit is contained in:
parent
cec6f3a4c5
commit
d0af642906
|
@ -59,6 +59,25 @@ class ExistingCloud(engine.Engine):
|
|||
"https_insecure": False,
|
||||
"https_cacert": "",
|
||||
}
|
||||
|
||||
To specify extra options use can use special "extra" parameter:
|
||||
|
||||
.. code-block:: json
|
||||
|
||||
{
|
||||
"type": "ExistingCloud",
|
||||
"auth_url": "http://localhost:5000/v2.0/",
|
||||
"region_name": "RegionOne",
|
||||
"endpoint_type": "public",
|
||||
"admin": {
|
||||
"username": "admin",
|
||||
"password": "password",
|
||||
"tenant_name": "demo"
|
||||
},
|
||||
"https_insecure": False,
|
||||
"https_cacert": "",
|
||||
"extra": {"some_var": "some_value"}
|
||||
}
|
||||
"""
|
||||
|
||||
CONFIG_SCHEMA = {
|
||||
|
@ -83,6 +102,7 @@ class ExistingCloud(engine.Engine):
|
|||
"properties": {
|
||||
"username": {"type": "string"},
|
||||
"password": {"type": "string"},
|
||||
"domain_name": {"type": "string"},
|
||||
"user_domain_name": {"type": "string"},
|
||||
"admin_domain_name": {"type": "string"},
|
||||
"project_name": {"type": "string"},
|
||||
|
@ -110,7 +130,8 @@ class ExistingCloud(engine.Engine):
|
|||
"users": {
|
||||
"type": "array",
|
||||
"items": {"$ref": "#/definitions/user"}
|
||||
}
|
||||
},
|
||||
"extra": {"type": "object", "additionalProperties": True}
|
||||
},
|
||||
"required": ["type", "auth_url", "admin"],
|
||||
"additionalProperties": False
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
|
||||
"""Test ExistingCloud."""
|
||||
|
||||
import ddt
|
||||
import jsonschema
|
||||
|
||||
from rally import consts
|
||||
|
@ -23,53 +24,111 @@ from rally.deployment.engines import existing
|
|||
from tests.unit import test
|
||||
|
||||
|
||||
@ddt.ddt
|
||||
class TestExistingCloud(test.TestCase):
|
||||
def setUp(self):
|
||||
super(TestExistingCloud, self).setUp()
|
||||
self.deployment = {
|
||||
self.deployments = {
|
||||
"v2.0": {
|
||||
"config": {
|
||||
"type": "ExistingCloud",
|
||||
"auth_url": "http://example.net:5000/v2.0/",
|
||||
"region_name": "RegionOne",
|
||||
"endpoint_type": consts.EndpointType.INTERNAL,
|
||||
"https_insecure": False,
|
||||
"https_cacert": None,
|
||||
"https_cacert": "cacert",
|
||||
"admin": {
|
||||
"username": "admin",
|
||||
"password": "myadminpass",
|
||||
"tenant_name": "demo",
|
||||
"domain_name": None,
|
||||
"tenant_name": "demo"
|
||||
}
|
||||
}
|
||||
},
|
||||
"v3": {
|
||||
"config": {
|
||||
"type": "ExistingCloud",
|
||||
"auth_url": "http://example.net:5000/v3/",
|
||||
"region_name": "RegionOne",
|
||||
"endpoint_type": consts.EndpointType.INTERNAL,
|
||||
"https_insecure": False,
|
||||
"https_cacert": "cacert",
|
||||
"admin": {
|
||||
"username": "admin",
|
||||
"password": "myadminpass",
|
||||
"domain_name": "domain",
|
||||
"project_name": "demo",
|
||||
"project_domain_name": "Default",
|
||||
"user_domain_name": "Default",
|
||||
"admin_domain_name": "Default",
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
def test_init(self):
|
||||
existing.ExistingCloud(self.deployment)
|
||||
@ddt.data("v2.0", "v3")
|
||||
def test_init_and_valid_config(self, keystone_version):
|
||||
engine = existing.ExistingCloud(self.deployments[keystone_version])
|
||||
engine.validate()
|
||||
|
||||
def test_invalid_config(self):
|
||||
self.deployment["config"]["admin"] = 42
|
||||
engine = existing.ExistingCloud(self.deployment)
|
||||
@ddt.data("v2.0", "v3")
|
||||
def test_invalid_config(self, keystone_version):
|
||||
deployment = self.deployments[keystone_version]
|
||||
deployment["config"]["admin"] = 42
|
||||
engine = existing.ExistingCloud(deployment)
|
||||
self.assertRaises(jsonschema.ValidationError,
|
||||
engine.validate)
|
||||
|
||||
def test_deploy(self):
|
||||
engine = existing.ExistingCloud(self.deployment)
|
||||
@ddt.data("v2.0", "v3")
|
||||
def test_additional_vars(self, keystone_version):
|
||||
deployment = self.deployments[keystone_version]
|
||||
deployment["extra"] = {}
|
||||
existing.ExistingCloud(deployment).validate()
|
||||
|
||||
deployment["extra"] = {"some_var": "some_value"}
|
||||
existing.ExistingCloud(deployment).validate()
|
||||
|
||||
deployment["extra"] = ["item1", "item2"]
|
||||
existing.ExistingCloud(deployment).validate()
|
||||
|
||||
@ddt.data("v2.0", "v3")
|
||||
def test_deploy(self, keystone_version):
|
||||
deployment = self.deployments[keystone_version]
|
||||
engine = existing.ExistingCloud(deployment)
|
||||
credentials = engine.deploy()
|
||||
admin_credential = self.deployment["config"].copy()
|
||||
admin_credential = deployment["config"].copy()
|
||||
admin_credential.pop("type")
|
||||
admin_credential["endpoint"] = None
|
||||
admin_credential.update(admin_credential.pop("admin"))
|
||||
self.assertEqual(admin_credential, credentials["admin"].to_dict())
|
||||
|
||||
actual_credentials = credentials["admin"].to_dict()
|
||||
|
||||
if keystone_version == "v3":
|
||||
# NOTE(andreykurilin): credentials obj uses `tenant_name` for both
|
||||
# keystone v2 and v3. It works perfectly for rally code (no
|
||||
# contradictions and misunderstandings ), but in case of checking
|
||||
# credentials.to_dict with data from database (where we use
|
||||
# project_name for keystone v3 config and tenant_name for
|
||||
# keystone v2), we need to transform vars.
|
||||
admin_credential["tenant_name"] = admin_credential.pop(
|
||||
"project_name")
|
||||
else:
|
||||
# NOTE(andreykurilin): there are no domain related variables in v2,
|
||||
# so we need to pop them from credentials.to_dict()
|
||||
actual_credentials.pop("domain_name")
|
||||
actual_credentials.pop("user_domain_name")
|
||||
actual_credentials.pop("admin_domain_name")
|
||||
actual_credentials.pop("project_domain_name")
|
||||
|
||||
self.assertEqual(admin_credential, actual_credentials)
|
||||
self.assertEqual([], credentials["users"])
|
||||
|
||||
def test_cleanup(self):
|
||||
existing.ExistingCloud(self.deployment).cleanup()
|
||||
@ddt.data("v2.0", "v3")
|
||||
def test_cleanup(self, keystone_version):
|
||||
existing.ExistingCloud(self.deployments[keystone_version]).cleanup()
|
||||
|
||||
def test_is_in_factory(self):
|
||||
name = self.deployment["config"]["type"]
|
||||
engine = deploy_engine.Engine.get_engine(name,
|
||||
self.deployment)
|
||||
@ddt.data("v2.0", "v3")
|
||||
def test_is_in_factory(self, keystone_version):
|
||||
name = self.deployments[keystone_version]["config"]["type"]
|
||||
engine = deploy_engine.Engine.get_engine(
|
||||
name, self.deployments[keystone_version])
|
||||
self.assertIsInstance(engine, existing.ExistingCloud)
|
||||
|
|
Loading…
Reference in New Issue