Merge "Update vm_workload_consolidation job"
This commit is contained in:
commit
7552c51df8
@ -11,6 +11,8 @@
|
||||
voting: false
|
||||
- watcher-tempest-basic_optim:
|
||||
voting: false
|
||||
- watcher-tempest-vm_workload_consolidation:
|
||||
voting: false
|
||||
- watcher-tempest-host_maintenance:
|
||||
voting: false
|
||||
- watcher-tempest-storage_balance:
|
||||
|
@ -57,7 +57,7 @@ class GnocchiClientJSON(base.BaseClient):
|
||||
'/search/resource/generic', kwargs, headers=self.json_header)
|
||||
|
||||
@base.handle_errors
|
||||
def show_measures(self, metric_uuid, aggregation='last'):
|
||||
def show_measures(self, metric_uuid, aggregation='mean'):
|
||||
return self._list_request(
|
||||
'/metric/{metric_uuid}/measures?aggregation={aggregation}&'
|
||||
'refresh=true'.format(metric_uuid=metric_uuid,
|
||||
|
@ -165,11 +165,13 @@ class BaseInfraOptimScenarioTest(manager.ScenarioTest):
|
||||
**kwargs)
|
||||
return body
|
||||
|
||||
def _create_one_instance_per_host(self):
|
||||
def _create_one_instance_per_host(self, metrics=dict()):
|
||||
"""Create 1 instance per compute node
|
||||
|
||||
This goes up to the min_compute_nodes threshold so that things don't
|
||||
get crazy if you have 1000 compute nodes but set min to 3.
|
||||
|
||||
:param metrics: The metrics add to resource when using Gnocchi
|
||||
"""
|
||||
host_client = self.mgr.hosts_client
|
||||
all_hosts = host_client.list_hosts()['hosts']
|
||||
@ -186,7 +188,7 @@ class BaseInfraOptimScenarioTest(manager.ScenarioTest):
|
||||
instance = self.mgr.servers_client.show_server(
|
||||
instance['id'])['server']
|
||||
created_instances.append(instance)
|
||||
self.make_instance_statistic(instance)
|
||||
self.make_instance_statistic(instance, metrics=metrics)
|
||||
|
||||
return created_instances
|
||||
|
||||
@ -213,14 +215,15 @@ class BaseInfraOptimScenarioTest(manager.ScenarioTest):
|
||||
search_body = {"=": {"original_resource_id": kwargs['id']}}
|
||||
resp, body = self.gnocchi.search_resource(**search_body)
|
||||
body = body[0]
|
||||
if body['metrics'].get('cpu_util'):
|
||||
self.gnocchi.delete_metric(body['metrics']['cpu_util'])
|
||||
metric_body = {
|
||||
"archive_policy_name": "bool",
|
||||
"resource_id": body['id'],
|
||||
"name": "cpu_util"
|
||||
}
|
||||
self.gnocchi.create_metric(**metric_body)
|
||||
for metric_name in kwargs['metrics'].keys():
|
||||
metric_body = {
|
||||
"archive_policy_name": "low",
|
||||
"resource_id": body['id'],
|
||||
"name": metric_name
|
||||
}
|
||||
if body['metrics'].get(metric_name, None):
|
||||
self.gnocchi.delete_metric(body['metrics'][metric_name])
|
||||
self.gnocchi.create_metric(**metric_body)
|
||||
resp, body = self.gnocchi.search_resource(**search_body)
|
||||
body = body[0]
|
||||
return resp, body
|
||||
@ -244,21 +247,26 @@ class BaseInfraOptimScenarioTest(manager.ScenarioTest):
|
||||
)
|
||||
return measures_body
|
||||
|
||||
def make_host_statistic(self):
|
||||
"""Create host resource and its measures in Gnocchi DB"""
|
||||
def make_host_statistic(self, metrics=dict()):
|
||||
"""Create host resource and its measures in Gnocchi DB
|
||||
|
||||
:param metrics: The metrics add to resource when using Gnocchi
|
||||
"""
|
||||
hypervisors_client = self.mgr.hypervisor_client
|
||||
hypervisors = hypervisors_client.list_hypervisors(
|
||||
detail=True)['hypervisors']
|
||||
if metrics == dict():
|
||||
metrics = {
|
||||
'compute.node.cpu.percent': {
|
||||
'archive_policy_name': 'low'
|
||||
}
|
||||
}
|
||||
for h in hypervisors:
|
||||
host_name = "%s_%s" % (h['hypervisor_hostname'],
|
||||
h['hypervisor_hostname'])
|
||||
resource_params = {
|
||||
'type': 'host',
|
||||
'metrics': {
|
||||
'compute.node.cpu.percent': {
|
||||
'archive_policy_name': 'bool'
|
||||
}
|
||||
},
|
||||
'metrics': metrics,
|
||||
'host_name': host_name,
|
||||
'id': host_name
|
||||
}
|
||||
@ -274,20 +282,23 @@ class BaseInfraOptimScenarioTest(manager.ScenarioTest):
|
||||
if len(res) > 0:
|
||||
return True
|
||||
|
||||
def make_instance_statistic(self, instance):
|
||||
def make_instance_statistic(self, instance, metrics=dict()):
|
||||
"""Create instance resource and its measures in Gnocchi DB
|
||||
|
||||
:param instance: Instance response body
|
||||
:param metrics: The metrics add to resource when using Gnocchi
|
||||
"""
|
||||
flavor = self.flavors_client.show_flavor(instance['flavor']['id'])
|
||||
flavor_name = flavor['flavor']['name']
|
||||
if metrics == dict():
|
||||
metrics = {
|
||||
'cpu_util': {
|
||||
'archive_policy_name': 'low'
|
||||
}
|
||||
}
|
||||
resource_params = {
|
||||
'type': 'instance',
|
||||
'metrics': {
|
||||
'cpu_util': {
|
||||
'archive_policy_name': 'bool'
|
||||
}
|
||||
},
|
||||
'metrics': metrics,
|
||||
'host': instance.get('OS-EXT-SRV-ATTR:hypervisor_hostname'),
|
||||
'display_name': instance.get('OS-EXT-SRV-ATTR:instance_name'),
|
||||
'image_ref': instance['image']['id'],
|
||||
|
@ -84,9 +84,9 @@ class TestExecuteBasicStrategy(base.BaseInfraOptimScenarioTest):
|
||||
_, audit = self.create_audit(
|
||||
audit_template['uuid'],
|
||||
parameters={
|
||||
"granularity": 1,
|
||||
"granularity": 300,
|
||||
"period": 72000,
|
||||
"aggregation_method": {"instance": "last", "node": "last"}
|
||||
"aggregation_method": {"instance": "mean", "node": "mean"}
|
||||
}
|
||||
)
|
||||
|
||||
|
@ -66,9 +66,21 @@ class TestExecuteVmWorkloadBalanceStrategy(base.BaseInfraOptimScenarioTest):
|
||||
- get results and make sure it succeeded
|
||||
"""
|
||||
self.addCleanup(self.rollback_compute_nodes_status)
|
||||
instances = self._create_one_instance_per_host()
|
||||
self._pack_all_created_instances_on_one_host(instances)
|
||||
self._create_one_instance_per_host()
|
||||
metrics = {
|
||||
'cpu_util': {
|
||||
'archive_policy_name': 'low'
|
||||
},
|
||||
'memory.resident': {
|
||||
'archive_policy_name': 'low'
|
||||
},
|
||||
'memory': {
|
||||
'archive_policy_name': 'low'
|
||||
},
|
||||
'disk.root.size': {
|
||||
'archive_policy_name': 'low'
|
||||
}
|
||||
}
|
||||
self._create_one_instance_per_host(metrics)
|
||||
|
||||
_, goal = self.client.show_goal(self.GOAL_NAME)
|
||||
_, strategy = self.client.show_strategy("vm_workload_consolidation")
|
||||
|
@ -71,8 +71,8 @@ class TestExecuteWorkloadBalancingStrategy(base.BaseInfraOptimScenarioTest):
|
||||
"weights": {"cpu_util_weight": 1.0},
|
||||
"periods": {"instance": 72000, "node": 60000},
|
||||
"instance_metrics": {"cpu_util": "compute.node.cpu.percent"},
|
||||
"granularity": 1,
|
||||
"aggregation_method": {"instance": "last", "node": "last"}}
|
||||
"granularity": 300,
|
||||
"aggregation_method": {"instance": "mean", "node": "mean"}}
|
||||
|
||||
_, goal = self.client.show_goal(self.GOAL)
|
||||
_, strategy = self.client.show_strategy("workload_stabilization")
|
||||
|
Loading…
x
Reference in New Issue
Block a user