diff options
| author | Arata Notsu <notsu@virtualtech.jp> | 2012-11-24 02:09:25 +0900 |
|---|---|---|
| committer | Gerrit Code Review <review@openstack.org> | 2012-11-28 01:47:58 +0000 |
| commit | f87c2e8334306cb7ef78b64a4bf5949b73d87617 (patch) | |
| tree | 07cee3f70b089fbf63cfd38ac146b2c31a52bcc5 /nova/tests | |
| parent | 39e5e4853c1c8c6696e4028fbc5102b70441687e (diff) | |
RetryFilter checks 'node' as well as 'host'
FilterScheduler and RetryFilter use "(host, node)" instead of "host" to
filter candidates. It makes rescheduling on different nodes in the same
host possible.
Fix bug 1081370
Change-Id: Id51b262de7b47b5f9215463eca5ae07a29109c3f
Diffstat (limited to 'nova/tests')
| -rw-r--r-- | nova/tests/scheduler/test_filter_scheduler.py | 15 | ||||
| -rw-r--r-- | nova/tests/scheduler/test_host_filters.py | 14 |
2 files changed, 18 insertions, 11 deletions
diff --git a/nova/tests/scheduler/test_filter_scheduler.py b/nova/tests/scheduler/test_filter_scheduler.py index e9412ba60..fcac8b923 100644 --- a/nova/tests/scheduler/test_filter_scheduler.py +++ b/nova/tests/scheduler/test_filter_scheduler.py @@ -280,16 +280,17 @@ class FilterSchedulerTestCase(test_scheduler.SchedulerTestCase): retry = dict(num_attempts=1, hosts=[]) filter_properties = dict(retry=retry) host = "fakehost" + node = "fakenode" sched = fakes.FakeFilterScheduler() - sched._add_retry_host(filter_properties, host) + sched._add_retry_host(filter_properties, host, node) hosts = filter_properties['retry']['hosts'] self.assertEqual(1, len(hosts)) - self.assertEqual(host, hosts[0]) + self.assertEqual((host, node), hosts[0]) def test_post_select_populate(self): - """Test addition of certain filter props after a host is selected""" + """Test addition of certain filter props after a node is selected""" retry = {'hosts': [], 'num_attempts': 1} filter_properties = {'retry': retry} sched = fakes.FakeFilterScheduler() @@ -299,12 +300,13 @@ class FilterSchedulerTestCase(test_scheduler.SchedulerTestCase): sched._post_select_populate_filter_properties(filter_properties, host_state) - self.assertEqual('host', filter_properties['retry']['hosts'][0]) + self.assertEqual(('host', 'node'), + filter_properties['retry']['hosts'][0]) self.assertEqual({'vcpus': 5}, host_state.limits) def test_prep_resize_post_populates_retry(self): - """Prep resize should add a 'host' entry to the retry dict""" + """Prep resize should add a ('host', 'node') entry to the retry dict""" sched = fakes.FakeFilterScheduler() image = 'image' @@ -335,4 +337,5 @@ class FilterSchedulerTestCase(test_scheduler.SchedulerTestCase): sched.schedule_prep_resize(self.context, image, request_spec, filter_properties, instance, instance_type, reservations) - self.assertEqual(['host'], filter_properties['retry']['hosts']) + self.assertEqual([('host', 'node')], + filter_properties['retry']['hosts']) diff --git a/nova/tests/scheduler/test_host_filters.py b/nova/tests/scheduler/test_host_filters.py index 9a0abb83c..1da29a7a7 100644 --- a/nova/tests/scheduler/test_host_filters.py +++ b/nova/tests/scheduler/test_host_filters.py @@ -1269,18 +1269,22 @@ class HostFiltersTestCase(test.TestCase): self.assertTrue(filt_cls.host_passes(host, filter_properties)) def test_retry_filter_pass(self): - """Host not previously tried""" + """Node not previously tried""" filt_cls = self.class_map['RetryFilter']() - host = fakes.FakeHostState('host1', 'node1', {}) - retry = dict(num_attempts=1, hosts=['host2', 'host3']) + host = fakes.FakeHostState('host1', 'nodeX', {}) + retry = dict(num_attempts=2, + hosts=[('host1', 'node1'), # same host, different node + ('host2', 'node2'), # different host and node + ]) filter_properties = dict(retry=retry) self.assertTrue(filt_cls.host_passes(host, filter_properties)) def test_retry_filter_fail(self): - """Host was already tried""" + """Node was already tried""" filt_cls = self.class_map['RetryFilter']() host = fakes.FakeHostState('host1', 'node1', {}) - retry = dict(num_attempts=1, hosts=['host3', 'host1']) + retry = dict(num_attempts=1, + hosts=[('host1', 'node1')]) filter_properties = dict(retry=retry) self.assertFalse(filt_cls.host_passes(host, filter_properties)) |
