diff options
| author | Kevin L. Mitchell <kevin.mitchell@rackspace.com> | 2011-09-07 13:37:29 -0500 |
|---|---|---|
| committer | Kevin L. Mitchell <kevin.mitchell@rackspace.com> | 2011-09-07 13:37:29 -0500 |
| commit | 262b5cf6e8bd577d2b08fb92e6da56f8bcdecd57 (patch) | |
| tree | e3566f1164faf570f4447d08bd2edd8a57f68c2f /nova/tests | |
| parent | 560698829e4c7168053775e7e5e9f1e92bb98fa8 (diff) | |
weigh_hosts() needs to return a list of hosts for the instances, not just a list of hosts
Diffstat (limited to 'nova/tests')
| -rw-r--r-- | nova/tests/scheduler/test_abstract_scheduler.py | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/nova/tests/scheduler/test_abstract_scheduler.py b/nova/tests/scheduler/test_abstract_scheduler.py index aa97e2344..f47699048 100644 --- a/nova/tests/scheduler/test_abstract_scheduler.py +++ b/nova/tests/scheduler/test_abstract_scheduler.py @@ -65,6 +65,11 @@ class FakeAbstractScheduler(abstract_scheduler.AbstractScheduler): pass +class FakeBaseScheduler(base_scheduler.BaseScheduler): + # No need to stub anything at the moment + pass + + class FakeZoneManager(zone_manager.ZoneManager): def __init__(self): self.service_states = { @@ -365,3 +370,30 @@ class AbstractSchedulerTestCase(test.TestCase): self.assertEqual(fixture._decrypt_blob(test_data), json.dumps(test_data)) + + +class BaseSchedulerTestCase(test.TestCase): + """Test case for Base Scheduler.""" + + def test_weigh_hosts(self): + """ + Try to weigh a short list of hosts and make sure enough + entries for a larger number instances are returned. + """ + + sched = FakeBaseScheduler() + + # Fake out a list of hosts + zm = FakeZoneManager() + hostlist = [(host, services['compute']) + for host, services in zm.service_states + if 'compute' in services] + + # Call weigh_hosts() + num_instances = len(hostlist) * 2 + len(hostlist) / 2 + instlist = sched.weigh_hosts('compute', + dict(num_instances=num_instances), + hostlist) + + # Should be enough entries to cover all instances + self.assertEqual(len(instlist), num_instances) |
