Add fix for hardware.cpu.util meter in sd-strategy
This patch set removes normalizing for hardware.cpu.util meter since the values that comes from ceilometer hardware.cpu.util are already normalized. Closes-Bug: #1588257 Change-Id: I9494f2cc9bbaa6dfd168fb515f679eb6d7f2398a
This commit is contained in:
parent
46091385d8
commit
ca37358cac
@ -192,9 +192,6 @@ class WorkloadStabilization(base.WorkloadStabilizationBaseStrategy):
|
|||||||
def normalize_hosts_load(self, hosts, current_model):
|
def normalize_hosts_load(self, hosts, current_model):
|
||||||
normalized_hosts = deepcopy(hosts)
|
normalized_hosts = deepcopy(hosts)
|
||||||
for host in normalized_hosts:
|
for host in normalized_hosts:
|
||||||
if 'cpu_util' in normalized_hosts[host]:
|
|
||||||
normalized_hosts[host]['cpu_util'] /= float(100)
|
|
||||||
|
|
||||||
if 'memory.resident' in normalized_hosts[host]:
|
if 'memory.resident' in normalized_hosts[host]:
|
||||||
h_memory = current_model.get_resource_from_id(
|
h_memory = current_model.get_resource_from_id(
|
||||||
resource.ResourceType.memory).get_capacity(
|
resource.ResourceType.memory).get_capacity(
|
||||||
|
@ -103,11 +103,11 @@ class FakerMetricsCollector(object):
|
|||||||
# node 4
|
# node 4
|
||||||
mock['VM_7_hostname_7'] = 4
|
mock['VM_7_hostname_7'] = 4
|
||||||
|
|
||||||
mock['Node_0'] = 7
|
mock['Node_0'] = 0.07
|
||||||
mock['Node_1'] = 5
|
mock['Node_1'] = 0.05
|
||||||
mock['Node_2'] = 10
|
mock['Node_2'] = 0.1
|
||||||
mock['Node_3'] = 4
|
mock['Node_3'] = 0.04
|
||||||
mock['Node_4'] = 2
|
mock['Node_4'] = 0.02
|
||||||
|
|
||||||
if uuid not in mock.keys():
|
if uuid not in mock.keys():
|
||||||
# mock[uuid] = random.randint(1, 4)
|
# mock[uuid] = random.randint(1, 4)
|
||||||
|
@ -35,19 +35,19 @@ class TestWorkloadStabilization(base.BaseTestCase):
|
|||||||
fake_cluster = faker_cluster_state.FakerModelCollector()
|
fake_cluster = faker_cluster_state.FakerModelCollector()
|
||||||
|
|
||||||
hosts_load_assert = {'Node_0':
|
hosts_load_assert = {'Node_0':
|
||||||
{'cpu_util': 7.0, 'memory.resident': 7.0,
|
{'cpu_util': 0.07, 'memory.resident': 7.0,
|
||||||
'vcpus': 40},
|
'vcpus': 40},
|
||||||
'Node_1':
|
'Node_1':
|
||||||
{'cpu_util': 5.0, 'memory.resident': 5,
|
{'cpu_util': 0.05, 'memory.resident': 5,
|
||||||
'vcpus': 40},
|
'vcpus': 40},
|
||||||
'Node_2':
|
'Node_2':
|
||||||
{'cpu_util': 10.0, 'memory.resident': 29,
|
{'cpu_util': 0.1, 'memory.resident': 29,
|
||||||
'vcpus': 40},
|
'vcpus': 40},
|
||||||
'Node_3':
|
'Node_3':
|
||||||
{'cpu_util': 4.0, 'memory.resident': 8,
|
{'cpu_util': 0.04, 'memory.resident': 8,
|
||||||
'vcpus': 40},
|
'vcpus': 40},
|
||||||
'Node_4':
|
'Node_4':
|
||||||
{'cpu_util': 2.0, 'memory.resident': 4,
|
{'cpu_util': 0.02, 'memory.resident': 4,
|
||||||
'vcpus': 40}}
|
'vcpus': 40}}
|
||||||
|
|
||||||
def test_get_vm_load(self):
|
def test_get_vm_load(self):
|
||||||
@ -62,8 +62,8 @@ class TestWorkloadStabilization(base.BaseTestCase):
|
|||||||
def test_normalize_hosts_load(self):
|
def test_normalize_hosts_load(self):
|
||||||
model = self.fake_cluster.generate_scenario_1()
|
model = self.fake_cluster.generate_scenario_1()
|
||||||
sd = strategies.WorkloadStabilization()
|
sd = strategies.WorkloadStabilization()
|
||||||
fake_hosts = {'Node_0': {'cpu_util': 7.0, 'memory.resident': 7},
|
fake_hosts = {'Node_0': {'cpu_util': 0.07, 'memory.resident': 7},
|
||||||
'Node_1': {'cpu_util': 5.0, 'memory.resident': 5}}
|
'Node_1': {'cpu_util': 0.05, 'memory.resident': 5}}
|
||||||
normalized_hosts = {'Node_0':
|
normalized_hosts = {'Node_0':
|
||||||
{'cpu_util': 0.07,
|
{'cpu_util': 0.07,
|
||||||
'memory.resident': 0.05303030303030303},
|
'memory.resident': 0.05303030303030303},
|
||||||
@ -83,10 +83,10 @@ class TestWorkloadStabilization(base.BaseTestCase):
|
|||||||
|
|
||||||
def test_get_sd(self):
|
def test_get_sd(self):
|
||||||
sd = strategies.WorkloadStabilization()
|
sd = strategies.WorkloadStabilization()
|
||||||
test_cpu_sd = 2.7
|
test_cpu_sd = 0.027
|
||||||
test_ram_sd = 9.3
|
test_ram_sd = 9.3
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
round(sd.get_sd(self.hosts_load_assert, 'cpu_util'), 1),
|
round(sd.get_sd(self.hosts_load_assert, 'cpu_util'), 3),
|
||||||
test_cpu_sd)
|
test_cpu_sd)
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
round(sd.get_sd(self.hosts_load_assert, 'memory.resident'), 1),
|
round(sd.get_sd(self.hosts_load_assert, 'memory.resident'), 1),
|
||||||
@ -105,7 +105,7 @@ class TestWorkloadStabilization(base.BaseTestCase):
|
|||||||
self.assertEqual(sd.calculate_migration_case(
|
self.assertEqual(sd.calculate_migration_case(
|
||||||
self.hosts_load_assert, "VM_5", "Node_2", "Node_1",
|
self.hosts_load_assert, "VM_5", "Node_2", "Node_1",
|
||||||
model)[-1]["Node_1"],
|
model)[-1]["Node_1"],
|
||||||
{'cpu_util': 7.5, 'memory.resident': 21, 'vcpus': 40})
|
{'cpu_util': 2.55, 'memory.resident': 21, 'vcpus': 40})
|
||||||
|
|
||||||
def test_simulate_migrations(self):
|
def test_simulate_migrations(self):
|
||||||
sd = strategies.WorkloadStabilization()
|
sd = strategies.WorkloadStabilization()
|
||||||
@ -143,7 +143,7 @@ class TestWorkloadStabilization(base.BaseTestCase):
|
|||||||
def test_execute_multiply_migrations(self):
|
def test_execute_multiply_migrations(self):
|
||||||
sd = strategies.WorkloadStabilization()
|
sd = strategies.WorkloadStabilization()
|
||||||
model = self.fake_cluster.generate_scenario_1()
|
model = self.fake_cluster.generate_scenario_1()
|
||||||
sd.thresholds = {'cpu_util': 0.022, 'memory.resident': 0.0001}
|
sd.thresholds = {'cpu_util': 0.00001, 'memory.resident': 0.0001}
|
||||||
sd.ceilometer = mock.MagicMock(
|
sd.ceilometer = mock.MagicMock(
|
||||||
statistic_aggregation=self.fake_metrics.mock_get_statistics)
|
statistic_aggregation=self.fake_metrics.mock_get_statistics)
|
||||||
sd.simulate_migrations = mock.Mock(return_value=[{'vm': 'VM_4',
|
sd.simulate_migrations = mock.Mock(return_value=[{'vm': 'VM_4',
|
||||||
@ -151,10 +151,10 @@ class TestWorkloadStabilization(base.BaseTestCase):
|
|||||||
'host': 'Node_1'},
|
'host': 'Node_1'},
|
||||||
{'vm': 'VM_3',
|
{'vm': 'VM_3',
|
||||||
's_host': 'Node_2',
|
's_host': 'Node_2',
|
||||||
'host': 'Node_3'}])
|
'host': 'Node_4'}])
|
||||||
with mock.patch.object(sd, 'migrate') as mock_migrate:
|
with mock.patch.object(sd, 'migrate') as mock_migrate:
|
||||||
sd.execute(model)
|
sd.execute(model)
|
||||||
self.assertEqual(mock_migrate.call_count, 2)
|
self.assertEqual(mock_migrate.call_count, 1)
|
||||||
|
|
||||||
def test_execute_nothing_to_migrate(self):
|
def test_execute_nothing_to_migrate(self):
|
||||||
sd = strategies.WorkloadStabilization()
|
sd = strategies.WorkloadStabilization()
|
||||||
|
Loading…
Reference in New Issue
Block a user