From 354ebd35cc5b4bcf7dca4c0facb73f0e5e2c1c6d Mon Sep 17 00:00:00 2001 From: aditi Date: Fri, 12 Jan 2018 15:41:11 +0530 Subject: [PATCH] Fix compute scope test bug We were excluding 'INSTANCE_6'from scope, which belongs to 'NODE_3' in scenerio_1.xml [1]. But NODE_3 is removed from model before only as it is not in scope. So, This Patch adds 'AZ3' in fake_scope. [1] https://github.com/openstack/watcher/blob/master/watcher/tests/decision_engine/model/data/scenario_1.xml Closes-Bug: #1737901 Change-Id: Ib1aaca7045908418ad0c23b718887cd89db98a83 --- watcher/tests/decision_engine/scope/fake_scopes.py | 3 ++- watcher/tests/decision_engine/scope/test_compute.py | 7 +++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/watcher/tests/decision_engine/scope/fake_scopes.py b/watcher/tests/decision_engine/scope/fake_scopes.py index aab3cba8d..78e1ffb5d 100644 --- a/watcher/tests/decision_engine/scope/fake_scopes.py +++ b/watcher/tests/decision_engine/scope/fake_scopes.py @@ -14,7 +14,8 @@ # See the License for the specific language governing permissions and # limitations under the License. -fake_scope_1 = [{'compute': [{'availability_zones': [{'name': 'AZ1'}]}, +fake_scope_1 = [{'compute': [{'availability_zones': [{'name': 'AZ1'}, + {'name': 'AZ3'}]}, {'exclude': [ {'instances': [ {'uuid': 'INSTANCE_6'}]}, diff --git a/watcher/tests/decision_engine/scope/test_compute.py b/watcher/tests/decision_engine/scope/test_compute.py index f3b01556a..e714b8bac 100644 --- a/watcher/tests/decision_engine/scope/test_compute.py +++ b/watcher/tests/decision_engine/scope/test_compute.py @@ -40,10 +40,13 @@ class TestComputeScope(base.TestCase): mock_zone_list.return_value = [ mock.Mock(zone='AZ{0}'.format(i), host={'Node_{0}'.format(i): {}}) - for i in range(2)] + for i in range(4)] model = compute.ComputeScope(audit_scope, mock.Mock(), osc=mock.Mock()).get_scoped_model(cluster) - expected_edges = [('INSTANCE_2', 'Node_1')] + + # NOTE(adisky):INSTANCE_6 is not excluded from model it will be tagged + # as 'exclude' TRUE, blueprint compute-cdm-include-all-instances + expected_edges = [('INSTANCE_2', 'Node_1'), (u'INSTANCE_6', u'Node_3')] self.assertEqual(sorted(expected_edges), sorted(model.edges())) @mock.patch.object(nova_helper.NovaHelper, 'get_service_list')