diff --git a/rally/benchmark/scenarios/dummy/dummy.py b/rally/benchmark/scenarios/dummy/dummy.py index 7e3cb0e4eb..f9b56613cf 100644 --- a/rally/benchmark/scenarios/dummy/dummy.py +++ b/rally/benchmark/scenarios/dummy/dummy.py @@ -14,7 +14,7 @@ import random import time from rally.benchmark.scenarios import base -from rally.benchmark import validation as valid +from rally.benchmark import validation from rally import exceptions @@ -34,10 +34,8 @@ class Dummy(base.Scenario): if sleep: time.sleep(sleep) - @valid.add_validator(valid.number("size_of_message", - minval=1, - integer_only=True, - nullable=True)) + @validation.add(validation.number("size_of_message", minval=1, + integer_only=True, nullable=True)) @base.scenario() def dummy_exception(self, size_of_message=1): """Test if exceptions are processed properly. @@ -51,10 +49,8 @@ class Dummy(base.Scenario): raise exceptions.DummyScenarioException("M" * size_of_message) - @valid.add_validator(valid.number("exception_probability", - minval=0, - maxval=1, - integer_only=False, + @validation.add(validation.number("exception_probability", minval=0, + maxval=1, integer_only=False, nullable=True)) @base.scenario() def dummy_exception_probability(self, exception_probability=0.5): diff --git a/rally/benchmark/scenarios/glance/images.py b/rally/benchmark/scenarios/glance/images.py index ce74157ee8..4ab92ba258 100644 --- a/rally/benchmark/scenarios/glance/images.py +++ b/rally/benchmark/scenarios/glance/images.py @@ -59,7 +59,7 @@ class GlanceImages(utils.GlanceScenario, nova_utils.NovaScenario): self._delete_image(image) @types.set(flavor=types.FlavorResourceType) - @validation.add_validator(validation.flavor_exists("flavor")) + @validation.add(validation.flavor_exists("flavor")) @base.scenario(context={"cleanup": ["glance", "nova"]}) def create_image_and_boot_instances(self, container_format, image_location, disk_format, diff --git a/rally/benchmark/scenarios/keystone/basic.py b/rally/benchmark/scenarios/keystone/basic.py index 86582f6371..e59c1de47e 100644 --- a/rally/benchmark/scenarios/keystone/basic.py +++ b/rally/benchmark/scenarios/keystone/basic.py @@ -15,7 +15,7 @@ from rally.benchmark.scenarios import base from rally.benchmark.scenarios.keystone import utils as kutils -from rally.benchmark import validation as valid +from rally.benchmark import validation class KeystoneBasic(kutils.KeystoneScenario): @@ -34,7 +34,7 @@ class KeystoneBasic(kutils.KeystoneScenario): self._tenant_create(name_length=name_length, **kwargs) @base.scenario(admin_only=True, context={"cleanup": []}) - @valid.add_validator(valid.required_parameters(['users_per_tenant'])) + @validation.add(validation.required_parameters(['users_per_tenant'])) def create_tenant_with_users(self, users_per_tenant, name_length=10, **kwargs): tenant = self._tenant_create(name_length=name_length, **kwargs) diff --git a/rally/benchmark/scenarios/nova/servers.py b/rally/benchmark/scenarios/nova/servers.py index d8819c19c7..166abc5e65 100644 --- a/rally/benchmark/scenarios/nova/servers.py +++ b/rally/benchmark/scenarios/nova/servers.py @@ -21,7 +21,7 @@ from rally.benchmark.scenarios.cinder import utils as cinder_utils from rally.benchmark.scenarios.nova import utils from rally.benchmark.scenarios import utils as scenario_utils from rally.benchmark import types as types -from rally.benchmark import validation as valid +from rally.benchmark import validation from rally import exceptions as rally_exceptions from rally.openstack.common.gettextutils import _ # noqa from rally.openstack.common import log as logging @@ -41,7 +41,7 @@ class NovaServers(utils.NovaScenario, @types.set(image=types.ImageResourceType, flavor=types.FlavorResourceType) - @valid.add_validator(valid.image_valid_on_flavor("flavor", "image")) + @validation.add(validation.image_valid_on_flavor("flavor", "image")) @base.scenario(context={"cleanup": ["nova"]}) def boot_and_list_server(self, image, flavor, detailed=True, **kwargs): @@ -62,7 +62,7 @@ class NovaServers(utils.NovaScenario, @types.set(image=types.ImageResourceType, flavor=types.FlavorResourceType) - @valid.add_validator(valid.image_valid_on_flavor("flavor", "image")) + @validation.add(validation.image_valid_on_flavor("flavor", "image")) @base.scenario(context={"cleanup": ["nova"]}) def boot_and_delete_server(self, image, flavor, min_sleep=0, max_sleep=0, **kwargs): @@ -74,7 +74,7 @@ class NovaServers(utils.NovaScenario, @types.set(image=types.ImageResourceType, flavor=types.FlavorResourceType) - @valid.add_validator(valid.image_valid_on_flavor("flavor", "image")) + @validation.add(validation.image_valid_on_flavor("flavor", "image")) @base.scenario(context={"cleanup": ["nova", "cinder"]}) def boot_server_from_volume_and_delete(self, image, flavor, volume_size, @@ -91,7 +91,7 @@ class NovaServers(utils.NovaScenario, @types.set(image=types.ImageResourceType, flavor=types.FlavorResourceType) - @valid.add_validator(valid.image_valid_on_flavor("flavor", "image")) + @validation.add(validation.image_valid_on_flavor("flavor", "image")) @base.scenario(context={"cleanup": ["nova"]}) def boot_and_bounce_server(self, image, flavor, **kwargs): """Tests booting a server then performing stop/start or hard/soft @@ -113,7 +113,7 @@ class NovaServers(utils.NovaScenario, @types.set(image=types.ImageResourceType, flavor=types.FlavorResourceType) - @valid.add_validator(valid.image_valid_on_flavor("flavor", "image")) + @validation.add(validation.image_valid_on_flavor("flavor", "image")) @base.scenario(context={"cleanup": ["nova", "glance"]}) def snapshot_server(self, image, flavor, **kwargs): """Tests Nova instance snapshotting.""" @@ -129,7 +129,7 @@ class NovaServers(utils.NovaScenario, @types.set(image=types.ImageResourceType, flavor=types.FlavorResourceType) - @valid.add_validator(valid.image_valid_on_flavor("flavor", "image")) + @validation.add(validation.image_valid_on_flavor("flavor", "image")) @base.scenario(context={"cleanup": ["nova"]}) def boot_server(self, image, flavor, **kwargs): """Test VM boot - assumed clean-up is done elsewhere.""" @@ -143,7 +143,7 @@ class NovaServers(utils.NovaScenario, @types.set(image=types.ImageResourceType, flavor=types.FlavorResourceType) - @valid.add_validator(valid.image_valid_on_flavor("flavor", "image")) + @validation.add(validation.image_valid_on_flavor("flavor", "image")) @base.scenario(context={"cleanup": ["nova", "cinder"]}) def boot_server_from_volume(self, image, flavor, volume_size, **kwargs): diff --git a/rally/benchmark/scenarios/tempest/tempest.py b/rally/benchmark/scenarios/tempest/tempest.py index 4b8605dc28..b82f38d32b 100644 --- a/rally/benchmark/scenarios/tempest/tempest.py +++ b/rally/benchmark/scenarios/tempest/tempest.py @@ -15,13 +15,13 @@ from rally.benchmark.scenarios import base from rally.benchmark.scenarios.tempest import utils -from rally.benchmark import validation as valid +from rally.benchmark import validation from rally import consts class TempestScenario(base.Scenario): - @valid.add_validator(valid.tempest_tests_exists()) + @validation.add(validation.tempest_tests_exists()) @base.scenario(context={"tempest": {}}) @utils.tempest_log_wrapper def single_test(self, test_name, log_file): @@ -46,7 +46,7 @@ class TempestScenario(base.Scenario): self.context()["verifier"].run("", log_file) - @valid.add_validator(valid.tempest_set_exists()) + @validation.add(validation.tempest_set_exists()) @base.scenario(context={"tempest": {}}) @utils.tempest_log_wrapper def set(self, set_name, log_file): @@ -65,7 +65,7 @@ class TempestScenario(base.Scenario): self._context["verifier"].run(testr_arg, log_file) - @valid.add_validator(valid.tempest_tests_exists()) + @validation.add(validation.tempest_tests_exists()) @base.scenario(context={"tempest": {}}) @utils.tempest_log_wrapper def list_of_tests(self, test_names, log_file): diff --git a/rally/benchmark/scenarios/vm/vmtasks.py b/rally/benchmark/scenarios/vm/vmtasks.py index dd6648b6bb..103a32e6f6 100644 --- a/rally/benchmark/scenarios/vm/vmtasks.py +++ b/rally/benchmark/scenarios/vm/vmtasks.py @@ -19,7 +19,7 @@ from rally.benchmark.scenarios import base from rally.benchmark.scenarios.nova import utils as nova_utils from rally.benchmark.scenarios.vm import utils as vm_utils from rally.benchmark import types as types -from rally.benchmark import validation as valid +from rally.benchmark import validation from rally.openstack.common.gettextutils import _ # noqa from rally.openstack.common import log as logging @@ -34,9 +34,9 @@ class VMTasks(nova_utils.NovaScenario, vm_utils.VMScenario): @types.set(image=types.ImageResourceType, flavor=types.FlavorResourceType) - @valid.add_validator(valid.image_valid_on_flavor("flavor", "image")) - @valid.add_validator(valid.file_exists("script")) - @valid.add_validator(valid.number("port", minval=1, maxval=65535, + @validation.add(validation.image_valid_on_flavor("flavor", "image")) + @validation.add(validation.file_exists("script")) + @validation.add(validation.number("port", minval=1, maxval=65535, nullable=True, integer_only=True)) @base.scenario(context={"cleanup": ["nova"], "keypair": {}, "allow_ssh": {}}) diff --git a/rally/benchmark/validation.py b/rally/benchmark/validation.py index 0c9b1a1fe6..07f5a3fedd 100644 --- a/rally/benchmark/validation.py +++ b/rally/benchmark/validation.py @@ -32,7 +32,7 @@ class ValidationResult(object): self.msg = msg -def add_validator(validator): +def add(validator): def wrapper(func): if not getattr(func, 'validators', None): func.validators = [] diff --git a/tests/benchmark/test_validation.py b/tests/benchmark/test_validation.py index 709226cd19..63d787e101 100644 --- a/tests/benchmark/test_validation.py +++ b/tests/benchmark/test_validation.py @@ -30,11 +30,11 @@ TEMPEST = "rally.verification.verifiers.tempest.tempest" class ValidationUtilsTestCase(test.TestCase): - def test_add_validator(self): + def test_add(self): def test_validator(): pass - @validation.add_validator(test_validator) + @validation.add(test_validator) def test_function(): pass