diff --git a/rally/benchmark/scenarios/keystone/basic.py b/rally/benchmark/scenarios/keystone/basic.py index c895cc3406..a5e49b9e4a 100644 --- a/rally/benchmark/scenarios/keystone/basic.py +++ b/rally/benchmark/scenarios/keystone/basic.py @@ -16,6 +16,7 @@ from rally.benchmark.context import cleaner as context_cleaner from rally.benchmark.scenarios import base from rally.benchmark.scenarios.keystone import utils as kutils +from rally.benchmark import validation as valid class KeystoneBasic(kutils.KeystoneScenario): @@ -36,9 +37,10 @@ class KeystoneBasic(kutils.KeystoneScenario): self._tenant_create(name_length=name_length, **kwargs) @base.scenario(admin_only=True) + @valid.add_validator(valid.required_parameters(['users_per_tenant'])) @context_cleaner.cleanup([]) - def create_tenant_with_users(self, name_length=10, - users_per_tenant=10, **kwargs): + def create_tenant_with_users(self, users_per_tenant, name_length=10, + **kwargs): tenant = self._tenant_create(name_length=name_length, **kwargs) - self._users_create(tenant, name_length=name_length, - users_per_tenant=users_per_tenant, **kwargs) + self._users_create(tenant, users_per_tenant, name_length=name_length, + **kwargs) diff --git a/rally/benchmark/scenarios/keystone/utils.py b/rally/benchmark/scenarios/keystone/utils.py index 4511b243bc..554129897b 100644 --- a/rally/benchmark/scenarios/keystone/utils.py +++ b/rally/benchmark/scenarios/keystone/utils.py @@ -74,11 +74,11 @@ class KeystoneScenario(base.Scenario): return self.admin_clients("keystone").tenants.create(name, **kwargs) @scenario_utils.atomic_action_timer('keystone.create_users') - def _users_create(self, tenant, name_length=10, users_per_tenant=10): + def _users_create(self, tenant, users_per_tenant, name_length=10): """Adds users to a tenant. - :param name_length: length of generated (random) part of name for user :param users_per_tenant: number of users in per tenant + :param name_length: length of generated (random) part of name for user """ for i in range(users_per_tenant): name = generate_keystone_name(length=name_length) diff --git a/rally/benchmark/validation.py b/rally/benchmark/validation.py index 950408979e..d94c3ef3d3 100644 --- a/rally/benchmark/validation.py +++ b/rally/benchmark/validation.py @@ -130,3 +130,18 @@ def image_valid_on_flavor(flavor_name, image_name): return ValidationResult() return image_valid_on_flavor_validator + + +def required_parameters(params): + """Returns validator for required parameters + + :param params: list of required parameters + """ + def required_parameters_validator(**kwargs): + missing = set(params) - set(kwargs) + if missing: + message = _("%s parameters are not defined in " + "the benchmark config file") % ", ".join(missing) + return ValidationResult(False, message) + return ValidationResult() + return required_parameters_validator diff --git a/tests/benchmark/scenarios/keystone/test_utils.py b/tests/benchmark/scenarios/keystone/test_utils.py index 3a69ba3421..4e383e7722 100644 --- a/tests/benchmark/scenarios/keystone/test_utils.py +++ b/tests/benchmark/scenarios/keystone/test_utils.py @@ -115,7 +115,7 @@ class KeystoneScenarioTestCase(test.TestCase): fake_clients._keystone = fake_keystone scenario = utils.KeystoneScenario(admin_clients=fake_clients) - scenario._users_create(tenant, 10, 1) + scenario._users_create(tenant, users_per_tenant=1, name_length=10) fake_keystone.users.create.assert_called_once_with(name, name, name + "@rally.me",