dist scheduler flag setting fixes

This commit is contained in:
Chris Behrens
2011-08-03 14:11:37 -07:00
parent 899dbbf71b
commit 20b351cbdc
2 changed files with 11 additions and 23 deletions

View File

@@ -19,12 +19,9 @@ Tests For Scheduler Host Filters.
import json import json
from nova import exception from nova import exception
from nova import flags
from nova import test from nova import test
from nova.scheduler import host_filter from nova.scheduler import host_filter
FLAGS = flags.FLAGS
class FakeZoneManager: class FakeZoneManager:
pass pass
@@ -57,9 +54,8 @@ class HostFilterTestCase(test.TestCase):
'host_name-label': 'xs-%s' % multiplier} 'host_name-label': 'xs-%s' % multiplier}
def setUp(self): def setUp(self):
self.old_flag = FLAGS.default_host_filter default_host_filter = 'nova.scheduler.host_filter.AllHostsFilter'
FLAGS.default_host_filter = \ self.flags(default_host_filter=default_host_filter)
'nova.scheduler.host_filter.AllHostsFilter'
self.instance_type = dict(name='tiny', self.instance_type = dict(name='tiny',
memory_mb=50, memory_mb=50,
vcpus=10, vcpus=10,
@@ -98,9 +94,6 @@ class HostFilterTestCase(test.TestCase):
host09['xpu_arch'] = 'fermi' host09['xpu_arch'] = 'fermi'
host09['xpu_info'] = 'Tesla 2150' host09['xpu_info'] = 'Tesla 2150'
def tearDown(self):
FLAGS.default_host_filter = self.old_flag
def test_choose_filter(self): def test_choose_filter(self):
# Test default filter ... # Test default filter ...
hf = host_filter.choose_host_filter() hf = host_filter.choose_host_filter()

View File

@@ -16,13 +16,11 @@
Tests For Least Cost Scheduler Tests For Least Cost Scheduler
""" """
from nova import flags
from nova import test from nova import test
from nova.scheduler import least_cost from nova.scheduler import least_cost
from nova.tests.scheduler import test_zone_aware_scheduler from nova.tests.scheduler import test_zone_aware_scheduler
MB = 1024 * 1024 MB = 1024 * 1024
FLAGS = flags.FLAGS
class FakeHost(object): class FakeHost(object):
@@ -95,10 +93,9 @@ class LeastCostSchedulerTestCase(test.TestCase):
self.assertWeights(expected, num, request_spec, hosts) self.assertWeights(expected, num, request_spec, hosts)
def test_noop_cost_fn(self): def test_noop_cost_fn(self):
FLAGS.least_cost_scheduler_cost_functions = [ self.flags(least_cost_scheduler_cost_functions=[
'nova.scheduler.least_cost.noop_cost_fn', 'nova.scheduler.least_cost.noop_cost_fn'],
] noop_cost_fn_weight=1)
FLAGS.noop_cost_fn_weight = 1
num = 1 num = 1
request_spec = {} request_spec = {}
@@ -109,10 +106,9 @@ class LeastCostSchedulerTestCase(test.TestCase):
self.assertWeights(expected, num, request_spec, hosts) self.assertWeights(expected, num, request_spec, hosts)
def test_cost_fn_weights(self): def test_cost_fn_weights(self):
FLAGS.least_cost_scheduler_cost_functions = [ self.flags(least_cost_scheduler_cost_functions=[
'nova.scheduler.least_cost.noop_cost_fn', 'nova.scheduler.least_cost.noop_cost_fn'],
] noop_cost_fn_weight=2)
FLAGS.noop_cost_fn_weight = 2
num = 1 num = 1
request_spec = {} request_spec = {}
@@ -123,10 +119,9 @@ class LeastCostSchedulerTestCase(test.TestCase):
self.assertWeights(expected, num, request_spec, hosts) self.assertWeights(expected, num, request_spec, hosts)
def test_compute_fill_first_cost_fn(self): def test_compute_fill_first_cost_fn(self):
FLAGS.least_cost_scheduler_cost_functions = [ self.flags(least_cost_scheduler_cost_functions=[
'nova.scheduler.least_cost.compute_fill_first_cost_fn', 'nova.scheduler.least_cost.compute_fill_first_cost_fn'],
] compute_fill_first_cost_fn_weight=1)
FLAGS.compute_fill_first_cost_fn_weight = 1
num = 1 num = 1
instance_type = {'memory_mb': 1024} instance_type = {'memory_mb': 1024}