Renaming in validation system

Rename add_validator to add.
Use "import validation" instead of "import validation as valid".

Change-Id: Id343f65da03c321da276e8395743a616a872f871
This commit is contained in:
Olga Kopylova 2014-06-11 13:12:26 +03:00
parent fdefc97cfe
commit ce16046a3a
8 changed files with 27 additions and 31 deletions

View File

@ -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):

View File

@ -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,

View File

@ -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)

View File

@ -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):

View File

@ -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):

View File

@ -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": {}})

View File

@ -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 = []

View File

@ -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