diff options
| author | Chris Behrens <cbehrens@codestud.com> | 2012-01-20 10:36:00 -0800 |
|---|---|---|
| committer | Chris Behrens <cbehrens@codestud.com> | 2012-01-20 14:41:46 -0800 |
| commit | 1bf066c59bbfe40a30e498f2b24fdddd82fb2508 (patch) | |
| tree | 3428a589a6b6dda3c63e1dce4f2f7c10c0ec2d31 /nova/tests | |
| parent | fd1aa4613b9a644ad2d702ac2d15cf12cef589c5 (diff) | |
pass filter_properties into scheduling requests for run_instance
Cleans up the resize stuff for avoiding a host
Allows for user-specified or compute-specified filters.
Change-Id: I0c6066240f602788eff1e0b5856ac52c03a4ebf0
Diffstat (limited to 'nova/tests')
| -rw-r--r-- | nova/tests/scheduler/test_distributed_scheduler.py | 38 | ||||
| -rw-r--r-- | nova/tests/test_compute.py | 6 |
2 files changed, 9 insertions, 35 deletions
diff --git a/nova/tests/scheduler/test_distributed_scheduler.py b/nova/tests/scheduler/test_distributed_scheduler.py index 05c5d18e1..3e909d005 100644 --- a/nova/tests/scheduler/test_distributed_scheduler.py +++ b/nova/tests/scheduler/test_distributed_scheduler.py @@ -234,7 +234,8 @@ class DistributedSchedulerTestCase(test.TestCase): def test_schedule_local_zone(self): """Test to make sure _schedule makes no call out to zones if - local_zone in the request spec is True.""" + local_zone_only in the filter_properties is True. + """ self.next_weight = 1.0 @@ -259,11 +260,11 @@ class DistributedSchedulerTestCase(test.TestCase): 'instance_type': {'memory_mb': 512, 'local_gb': 512}, 'instance_properties': {'project_id': 1, 'memory_mb': 512, - 'local_gb': 512}, - 'local_zone': True} + 'local_gb': 512}} + filter_properties = {'local_zone_only': True} self.mox.ReplayAll() weighted_hosts = sched._schedule(fake_context, 'compute', - request_spec) + request_spec, filter_properties=filter_properties) self.mox.VerifyAll() self.assertEquals(len(weighted_hosts), 10) for weighted_host in weighted_hosts: @@ -300,32 +301,3 @@ class DistributedSchedulerTestCase(test.TestCase): hostinfo.update_from_compute_node(dict(memory_mb=1000, local_gb=0)) self.assertEquals(1000 - 128, fn(hostinfo, {})) - - def test_populate_filter_properties(self): - request_spec = {'instance_properties': {}} - fixture = fakes.FakeDistributedScheduler() - filter_properties = {'ignore_hosts': []} - fixture.populate_filter_properties(request_spec, filter_properties) - self.assertEqual(len(filter_properties['ignore_hosts']), 0) - - # No original host results in not ignoring - request_spec = {'instance_properties': {}, - 'avoid_original_host': True} - fixture = fakes.FakeDistributedScheduler() - fixture.populate_filter_properties(request_spec, filter_properties) - self.assertEqual(len(filter_properties['ignore_hosts']), 0) - - # Original host but avoid is False should not ignore it - request_spec = {'instance_properties': {'host': 'foo'}, - 'avoid_original_host': False} - fixture = fakes.FakeDistributedScheduler() - fixture.populate_filter_properties(request_spec, filter_properties) - self.assertEqual(len(filter_properties['ignore_hosts']), 0) - - # Original host but avoid is True should ignore it - request_spec = {'instance_properties': {'host': 'foo'}, - 'avoid_original_host': True} - fixture = fakes.FakeDistributedScheduler() - fixture.populate_filter_properties(request_spec, filter_properties) - self.assertEqual(len(filter_properties['ignore_hosts']), 1) - self.assertEqual(filter_properties['ignore_hosts'][0], 'foo') diff --git a/nova/tests/test_compute.py b/nova/tests/test_compute.py index 77daa4564..992b1076f 100644 --- a/nova/tests/test_compute.py +++ b/nova/tests/test_compute.py @@ -2171,9 +2171,10 @@ class ComputeAPITestCase(BaseTestCase): def test_resize_request_spec(self): def _fake_cast(context, args): request_spec = args['args']['request_spec'] + filter_properties = args['args']['filter_properties'] instance_properties = request_spec['instance_properties'] self.assertEqual(instance_properties['host'], 'host2') - self.assertEqual(request_spec['avoid_original_host'], True) + self.assertIn('host2', filter_properties['ignore_hosts']) self.stubs.Set(self.compute_api, '_cast_scheduler_message', _fake_cast) @@ -2190,9 +2191,10 @@ class ComputeAPITestCase(BaseTestCase): def test_resize_request_spec_noavoid(self): def _fake_cast(context, args): request_spec = args['args']['request_spec'] + filter_properties = args['args']['filter_properties'] instance_properties = request_spec['instance_properties'] self.assertEqual(instance_properties['host'], 'host2') - self.assertEqual(request_spec['avoid_original_host'], False) + self.assertNotIn('host2', filter_properties['ignore_hosts']) self.stubs.Set(self.compute_api, '_cast_scheduler_message', _fake_cast) |
