diff --git a/heat/engine/constraint/common_constraints.py b/heat/engine/constraint/common_constraints.py index dc0604891f..2be78f3bc4 100644 --- a/heat/engine/constraint/common_constraints.py +++ b/heat/engine/constraint/common_constraints.py @@ -12,6 +12,7 @@ # under the License. import croniter +import eventlet import netaddr import pytz import six @@ -23,6 +24,12 @@ from heat.common.i18n import _ from heat.engine import constraints +class TestConstraintDelay(constraints.BaseCustomConstraint): + + def validate_with_client(self, client, value): + eventlet.sleep(value) + + class IPConstraint(constraints.BaseCustomConstraint): def validate(self, value, context): diff --git a/heat/engine/resources/openstack/heat/test_resource.py b/heat/engine/resources/openstack/heat/test_resource.py index 2a6aff7bcc..0b21026e82 100644 --- a/heat/engine/resources/openstack/heat/test_resource.py +++ b/heat/engine/resources/openstack/heat/test_resource.py @@ -18,6 +18,7 @@ import six from heat.common.i18n import _ from heat.engine import attributes +from heat.engine import constraints from heat.engine import properties from heat.engine import resource from heat.engine import support @@ -44,10 +45,12 @@ class TestResource(resource.Resource): VALUE, UPDATE_REPLACE, FAIL, CLIENT_NAME, ENTITY_NAME, WAIT_SECS, ACTION_WAIT_SECS, ATTR_WAIT_SECS, + CONSTRAINT_PROP_SECS, ) = ( 'value', 'update_replace', 'fail', 'client_name', 'entity_name', 'wait_secs', 'action_wait_secs', 'attr_wait_secs', + 'constraint_prop_secs', ) ATTRIBUTES = ( @@ -57,6 +60,16 @@ class TestResource(resource.Resource): ) properties_schema = { + CONSTRAINT_PROP_SECS: properties.Schema( + properties.Schema.NUMBER, + _('Number value for delay during resolve constraint.'), + default=0, + update_allowed=True, + constraints=[ + constraints.CustomConstraint('test_constr') + ], + support_status=support.SupportStatus(version='6.0.0') + ), ATTR_WAIT_SECS: properties.Schema( properties.Schema.NUMBER, _('Number value for timeout during resolving output value.'), diff --git a/rally-scenarios/extra/rg_template_with_constraint.yaml b/rally-scenarios/extra/rg_template_with_constraint.yaml new file mode 100644 index 0000000000..28f07f8fe9 --- /dev/null +++ b/rally-scenarios/extra/rg_template_with_constraint.yaml @@ -0,0 +1,19 @@ +heat_template_version: 2013-05-23 +description: Template for testing caching. +parameters: + count: + type: number + default: 40 + delay: + type: number + default: 0.3 + +resources: + rg: + type: OS::Heat::ResourceGroup + properties: + count: {get_param: count} + resource_def: + type: OS::Heat::TestResource + properties: + constraint_prop_secs: {get_param: delay} diff --git a/rally-scenarios/heat-fakevirt.yaml b/rally-scenarios/heat-fakevirt.yaml index a7f8f8e769..420b137934 100644 --- a/rally-scenarios/heat-fakevirt.yaml +++ b/rally-scenarios/heat-fakevirt.yaml @@ -24,3 +24,15 @@ users: tenants: 10 users_per_tenant: 3 + + - + args: + template_path: "~/.rally/extra/rg_template_with_constraint.yaml" + runner: + type: "constant" + times: 10 + concurrency: 2 + context: + users: + tenants: 1 + users_per_tenant: 1 diff --git a/setup.cfg b/setup.cfg index a20a83b94f..29c807bf95 100644 --- a/setup.cfg +++ b/setup.cfg @@ -103,6 +103,7 @@ heat.constraints = ip_addr = heat.engine.constraint.common_constraints:IPConstraint mac_addr = heat.engine.constraint.common_constraints:MACConstraint net_cidr = heat.engine.constraint.common_constraints:CIDRConstraint + test_constr = heat.engine.constraint.common_constraints:TestConstraintDelay keystone.role = heat.engine.clients.os.keystone:KeystoneRoleConstraint keystone.domain = heat.engine.clients.os.keystone:KeystoneDomainConstraint keystone.project = heat.engine.clients.os.keystone:KeystoneProjectConstraint