diff options
| author | Hans Lindgren <hanlind@kth.se> | 2013-01-27 21:19:16 +0100 |
|---|---|---|
| committer | Hans Lindgren <hanlind@kth.se> | 2013-01-28 10:52:09 +0100 |
| commit | 8bc80cab3c134d64953b4f6493cab80b5bdc1b69 (patch) | |
| tree | dc74540ab0b741467c78cedc50d9af56aad43f46 /nova/tests | |
| parent | e1ce3878b951ea491548c129453bb84a77205649 (diff) | |
Fix an error in affinity filters
Fix a call to compute_api.get_all to properly exclude deleted instances.
Add tests to prohibit this error in the future.
After some thought, this can be further optimized to let the instance
query do all the filtering/matching.
Resolves bug 1107156.
Change-Id: I6d6a6ba44d38d363489853d0407ad4cc94046656
Diffstat (limited to 'nova/tests')
| -rw-r--r-- | nova/tests/scheduler/test_host_filters.py | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/nova/tests/scheduler/test_host_filters.py b/nova/tests/scheduler/test_host_filters.py index 6fcd19d92..230e2ea03 100644 --- a/nova/tests/scheduler/test_host_filters.py +++ b/nova/tests/scheduler/test_host_filters.py @@ -337,6 +337,20 @@ class HostFiltersTestCase(test.TestCase): self.assertTrue(filt_cls.host_passes(host, filter_properties)) + def test_affinity_different_filter_handles_deleted_instance(self): + filt_cls = self.class_map['DifferentHostFilter']() + host = fakes.FakeHostState('host1', 'node1', {}) + instance = fakes.FakeInstance(context=self.context, + params={'host': 'host1'}) + instance_uuid = instance.uuid + db.instance_destroy(self.context, instance_uuid) + + filter_properties = {'context': self.context.elevated(), + 'scheduler_hints': { + 'different_host': [instance_uuid], }} + + self.assertTrue(filt_cls.host_passes(host, filter_properties)) + def test_affinity_same_filter_no_list_passes(self): filt_cls = self.class_map['SameHostFilter']() host = fakes.FakeHostState('host1', 'node1', {}) @@ -388,6 +402,20 @@ class HostFiltersTestCase(test.TestCase): self.assertTrue(filt_cls.host_passes(host, filter_properties)) + def test_affinity_same_filter_handles_deleted_instance(self): + filt_cls = self.class_map['SameHostFilter']() + host = fakes.FakeHostState('host1', 'node1', {}) + instance = fakes.FakeInstance(context=self.context, + params={'host': 'host1'}) + instance_uuid = instance.uuid + db.instance_destroy(self.context, instance_uuid) + + filter_properties = {'context': self.context.elevated(), + 'scheduler_hints': { + 'same_host': [instance_uuid], }} + + self.assertFalse(filt_cls.host_passes(host, filter_properties)) + def test_affinity_simple_cidr_filter_passes(self): filt_cls = self.class_map['SimpleCIDRAffinityFilter']() host = fakes.FakeHostState('host1', 'node1', {}) |
