Clean up scheduler tests

Removed some unused variables in the scheduler tests.
Fixed a docstring that did not make sense.
Added an assert to make a test actually test something.

Change-Id: I6ddb1075924375b38df82aa9a54e03a67316d8f6
This commit is contained in:
Andrew Laski
2013-06-19 10:34:24 -04:00
parent 6808e052db
commit 750379828b
4 changed files with 6 additions and 24 deletions

View File

@@ -68,15 +68,11 @@ class ChanceSchedulerTestCase(test_scheduler.SchedulerTestCase):
def test_basic_schedule_run_instance(self):
ctxt = context.RequestContext('fake', 'fake', False)
ctxt_elevated = 'fake-context-elevated'
fake_args = (1, 2, 3)
instance_opts = {'fake_opt1': 'meow', 'launch_index': -1}
instance1 = {'uuid': 'fake-uuid1'}
instance2 = {'uuid': 'fake-uuid2'}
request_spec = {'instance_uuids': ['fake-uuid1', 'fake-uuid2'],
'instance_properties': instance_opts}
instance1_encoded = {'uuid': 'fake-uuid1', '_is_precooked': False}
instance2_encoded = {'uuid': 'fake-uuid2', '_is_precooked': False}
reservations = ['resv1', 'resv2']
def inc_launch_index(*args):
request_spec['instance_properties']['launch_index'] = (
@@ -118,7 +114,6 @@ class ChanceSchedulerTestCase(test_scheduler.SchedulerTestCase):
def test_basic_schedule_run_instance_no_hosts(self):
ctxt = context.RequestContext('fake', 'fake', False)
ctxt_elevated = 'fake-context-elevated'
fake_args = (1, 2, 3)
uuid = 'fake-uuid1'
instance_opts = {'fake_opt1': 'meow', 'launch_index': -1}
request_spec = {'instance_uuids': [uuid],
@@ -170,10 +165,7 @@ class ChanceSchedulerTestCase(test_scheduler.SchedulerTestCase):
def test_select_hosts(self):
ctxt = context.RequestContext('fake', 'fake', False)
ctxt_elevated = 'fake-context-elevated'
fake_args = (1, 2, 3)
instance_opts = {'fake_opt1': 'meow', 'launch_index': -1}
instance1 = {'uuid': 'fake-uuid1'}
instance2 = {'uuid': 'fake-uuid2'}
request_spec = {'instance_uuids': ['fake-uuid1', 'fake-uuid2'],
'instance_properties': instance_opts}

View File

@@ -316,9 +316,6 @@ class HostFiltersTestCase(test.NoDBTestCase):
def test_affinity_different_filter_handles_none(self):
filt_cls = self.class_map['DifferentHostFilter']()
host = fakes.FakeHostState('host1', 'node1', {})
instance = fakes.FakeInstance(context=self.context,
params={'host': 'host2'})
instance_uuid = instance.uuid
filter_properties = {'context': self.context.elevated(),
'scheduler_hints': None}
@@ -381,9 +378,6 @@ class HostFiltersTestCase(test.NoDBTestCase):
def test_affinity_same_filter_handles_none(self):
filt_cls = self.class_map['SameHostFilter']()
host = fakes.FakeHostState('host1', 'node1', {})
instance = fakes.FakeInstance(context=self.context,
params={'host': 'host2'})
instance_uuid = instance.uuid
filter_properties = {'context': self.context.elevated(),
'scheduler_hints': None}
@@ -953,7 +947,6 @@ class HostFiltersTestCase(test.NoDBTestCase):
'local_gb': 200},
'scheduler_hints': {'query': json_query}}
capabilities = {'enabled': True}
service = {'disabled': True}
host = fakes.FakeHostState('host1', 'node1',
{'free_ram_mb': 1024,
'free_disk_mb': 200 * 1024,
@@ -1385,6 +1378,8 @@ class HostFiltersTestCase(test.NoDBTestCase):
filt_cls = self.class_map['IoOpsFilter']()
host = fakes.FakeHostState('host1', 'node1',
{'num_io_ops': 8})
filter_properties = {}
self.assertFalse(filt_cls.host_passes(host, filter_properties))
def test_filter_num_instances_passes(self):
self.flags(max_instances_per_host=5)

View File

@@ -88,7 +88,7 @@ class SchedulerManagerTestCase(test.NoDBTestCase):
self.manager.driver.update_service_capabilities(service_name,
host, {})
self.mox.ReplayAll()
result = self.manager.update_service_capabilities(self.context,
self.manager.update_service_capabilities(self.context,
service_name=service_name, host=host, capabilities={})
self.mox.VerifyAll()
@@ -98,7 +98,7 @@ class SchedulerManagerTestCase(test.NoDBTestCase):
self.manager.driver.update_service_capabilities(
service_name, host, capabilities)
self.mox.ReplayAll()
result = self.manager.update_service_capabilities(self.context,
self.manager.update_service_capabilities(self.context,
service_name=service_name, host=host,
capabilities=capabilities)
@@ -444,7 +444,7 @@ class SchedulerTestCase(test.NoDBTestCase):
self.driver.host_manager.update_service_capabilities(
service_name, host, capabilities)
self.mox.ReplayAll()
result = self.driver.update_service_capabilities(service_name,
self.driver.update_service_capabilities(service_name,
host, capabilities)
def test_hosts_up(self):
@@ -961,12 +961,10 @@ class SchedulerTestCase(test.NoDBTestCase):
class SchedulerDriverBaseTestCase(SchedulerTestCase):
"""Test cases for base scheduler driver class methods
that can't will fail if the driver is changed.
that will fail if the driver is changed.
"""
def test_unimplemented_schedule_run_instance(self):
fake_args = (1, 2, 3)
fake_kwargs = {'cat': 'meow'}
fake_request_spec = {'instance_properties':
{'uuid': 'uuid'}}
@@ -976,8 +974,6 @@ class SchedulerDriverBaseTestCase(SchedulerTestCase):
None, None)
def test_unimplemented_schedule_prep_resize(self):
fake_args = (1, 2, 3)
fake_kwargs = {'cat': 'meow'}
fake_request_spec = {'instance_properties':
{'uuid': 'uuid'}}

View File

@@ -71,7 +71,6 @@ class SchedulerOptionsTestCase(test.NoDBTestCase):
file_old = None
file_now = datetime.datetime(2012, 1, 1, 1, 1, 1)
data = dict(a=1, b=2, c=3)
jdata = ""
fake = FakeSchedulerOptions(last_checked, now, file_old, file_now,