Applied host_cpu_usable_by_vms, fixed tests

This commit is contained in:
Anton Beloglazov 2012-10-19 17:10:58 +11:00
parent 30f3299e9d
commit ab23b5bcec
4 changed files with 10 additions and 8 deletions

View File

@ -78,7 +78,7 @@ data_collector_data_length = 100
# The threshold on the overall (all cores) utilization of the physical
# CPU of a host, above which the host is considered to be overloaded.
# This is used for logging host overloads into the database.
host_cpu_overload_threshold = 0.7
host_cpu_overload_threshold = 0.95
# The threshold on the overall (all cores) utilization of the physical
# CPU of a host that can be allocated to VMs.
@ -129,4 +129,4 @@ algorithm_vm_placement_factory = neat.globals.vm_placement.bin_packing.best_fit_
# A JSON encoded parameters, which will be parsed and passed to the
# specified VM placement algorithm factory
algorithm_vm_placement_parameters = {"cpu_threshold": 0.6, "ram_threshold": 0.95}
algorithm_vm_placement_parameters = {"cpu_threshold": 0.8, "ram_threshold": 0.95}

View File

@ -168,7 +168,8 @@ def init_state(config):
'vir_connection': vir_connection,
'hostname': hostname,
'host_cpu_overload_threshold':
float(config['host_cpu_overload_threshold']),
float(config['host_cpu_overload_threshold']) * \
float(config['host_cpu_usable_by_vms']),
'physical_cpus': physical_cpus,
'physical_cpu_mhz': host_cpu_mhz,
'physical_core_mhz': host_cpu_mhz / physical_cpus,

View File

@ -52,8 +52,7 @@ class Collector(TestCase):
time_interval).and_return(state).once()
assert collector.start() == state
@qc(1)
def init_state():
def test_init_state(self):
with MockTransaction:
vir_connection = mock('virConnect')
expect(libvirt).openReadOnly(None). \
@ -62,7 +61,8 @@ class Collector(TestCase):
expect(common).physical_cpu_count(vir_connection). \
and_return(physical_cpus).once()
config = {'sql_connection': 'db',
'host_cpu_overload_threshold': '0.95'}
'host_cpu_overload_threshold': '0.95',
'host_cpu_usable_by_vms': '0.75'}
hostname = 'host1'
mhz = 13540
@ -81,7 +81,8 @@ class Collector(TestCase):
assert isinstance(state['previous_cpu_time'], dict)
assert state['vir_connection'] == vir_connection
assert state['hostname'] == hostname
assert state['host_cpu_overload_threshold'] == 0.95
self.assertAlmostEqual(state['host_cpu_overload_threshold'],
0.7125, 3)
assert state['physical_cpus'] == physical_cpus
assert state['physical_cpu_mhz'] == mhz
assert state['physical_core_mhz'] == mhz / physical_cpus

View File

@ -56,7 +56,7 @@ class LocalManager(TestCase):
with MockTransaction:
vir_connection = mock('virConnect')
db = mock('db')
mhz = mock('mhz')
mhz = 3000
expect(libvirt).openReadOnly(None). \
and_return(vir_connection).once()
expect(manager).init_db('db'). \