From 7109468b2f729fe7b66fffcb47cca1df4086271c Mon Sep 17 00:00:00 2001 From: Thomas Herve Date: Mon, 10 Apr 2017 23:44:26 +0200 Subject: [PATCH] Wait for the policy to be done in tests As observed in the amqp job, we sometimes signal scale policy too fast, without waiting for the medata to be set. It creates a timeout. We can check the metadata of the policy before signaling again, to make sure that we can move forward. Change-Id: I9857803ef960efbd034f05985ec8fcc7272e2f70 --- heat_integrationtests/common/test.py | 8 ++++++-- .../functional/test_heat_autoscaling.py | 9 ++++++--- heat_integrationtests/scenario/test_autoscaling_lb.py | 2 +- heat_integrationtests/scenario/test_autoscaling_lbv2.py | 2 +- 4 files changed, 14 insertions(+), 7 deletions(-) diff --git a/heat_integrationtests/common/test.py b/heat_integrationtests/common/test.py index f52cda388d..f2e7dd75c2 100644 --- a/heat_integrationtests/common/test.py +++ b/heat_integrationtests/common/test.py @@ -655,10 +655,14 @@ class HeatIntegrationTest(testscenarios.WithScenarios, return matched time.sleep(build_interval) - def check_autoscale_complete(self, stack_id, expected_num): + def check_autoscale_complete(self, stack_id, expected_num, parent_stack, + policy): res_list = self.client.resources.list(stack_id) all_res_complete = all(res.resource_status in ('UPDATE_COMPLETE', 'CREATE_COMPLETE') for res in res_list) all_res = len(res_list) == expected_num - return all_res and all_res_complete + if all_res and all_res_complete: + metadata = self.client.resources.metadata(parent_stack, policy) + return not metadata.get('scaling_in_progress') + return False diff --git a/heat_integrationtests/functional/test_heat_autoscaling.py b/heat_integrationtests/functional/test_heat_autoscaling.py index 096c427353..608fd1d61f 100644 --- a/heat_integrationtests/functional/test_heat_autoscaling.py +++ b/heat_integrationtests/functional/test_heat_autoscaling.py @@ -119,7 +119,8 @@ outputs: self.conf.build_interval, self.check_autoscale_complete, asg.physical_resource_id, - expected_resources)) + expected_resources, stack_id, + 'scale_up_policy')) def test_asg_scale_down_min_size(self): stack_id = self.stack_create(template=self.template, @@ -140,7 +141,8 @@ outputs: self.conf.build_interval, self.check_autoscale_complete, asg.physical_resource_id, - expected_resources)) + expected_resources, stack_id, + 'scale_down_policy')) def test_asg_cooldown(self): cooldown_tmpl = self.template.replace('cooldown: 0', @@ -162,7 +164,8 @@ outputs: self.conf.build_interval, self.check_autoscale_complete, asg.physical_resource_id, - expected_resources)) + expected_resources, stack_id, + 'scale_up_policy')) def test_path_attrs(self): stack_id = self.stack_create(template=self.template) diff --git a/heat_integrationtests/scenario/test_autoscaling_lb.py b/heat_integrationtests/scenario/test_autoscaling_lb.py index 833e9a8087..5e8ad272d1 100644 --- a/heat_integrationtests/scenario/test_autoscaling_lb.py +++ b/heat_integrationtests/scenario/test_autoscaling_lb.py @@ -104,7 +104,7 @@ class AutoscalingLoadBalancerTest(scenario_base.ScenarioTestsBase): test.call_until_true(self.conf.build_timeout, self.conf.build_interval, self.check_autoscale_complete, - asg.physical_resource_id, 2) + asg.physical_resource_id, 2, sid, 'scale_up') # Check number of distinctive responses, must now be 2 self.check_num_responses(lb_url, 2) diff --git a/heat_integrationtests/scenario/test_autoscaling_lbv2.py b/heat_integrationtests/scenario/test_autoscaling_lbv2.py index 78cde531a7..4ddc21ea32 100644 --- a/heat_integrationtests/scenario/test_autoscaling_lbv2.py +++ b/heat_integrationtests/scenario/test_autoscaling_lbv2.py @@ -104,7 +104,7 @@ class AutoscalingLoadBalancerv2Test(scenario_base.ScenarioTestsBase): test.call_until_true(self.conf.build_timeout, self.conf.build_interval, self.check_autoscale_complete, - asg.physical_resource_id, 2) + asg.physical_resource_id, 2, sid, 'scale_up') # Check number of distinctive responses, must now be 2 self.check_num_responses(lb_url, 2)