From fbb1a49424e72aece397026efa1d494034c3d474 Mon Sep 17 00:00:00 2001 From: Sergey Kraynev Date: Fri, 12 Feb 2016 05:04:01 -0500 Subject: [PATCH] Add test for performance in constraint validation There are follow important changes in patch: - New constraint was added. This constraint emulate delay during resolving custom constraint for property. - New property was added for TestResource. This property uses new constraint. - Added Rally scenario create-delete, which uses template with ResourceGroup of TestResources with custom constraint. Depends-On: I06183138d54c1cb971a58a158a15f3f5b25cba4d Change-Id: I53d83f59be9bd27db451f87aaae2d8446f287c17 --- heat/engine/constraint/common_constraints.py | 7 +++++++ .../resources/openstack/heat/test_resource.py | 13 +++++++++++++ .../extra/rg_template_with_constraint.yaml | 19 +++++++++++++++++++ rally-scenarios/heat-fakevirt.yaml | 12 ++++++++++++ setup.cfg | 1 + 5 files changed, 52 insertions(+) create mode 100644 rally-scenarios/extra/rg_template_with_constraint.yaml 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 a827224f89..41b8ef4111 100644 --- a/rally-scenarios/heat-fakevirt.yaml +++ b/rally-scenarios/heat-fakevirt.yaml @@ -20,3 +20,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 dffe6b4a2b..c1afd63aba 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