Merge "tempests changes"
This commit is contained in:
commit
c0f87a3a45
@ -39,15 +39,18 @@ class AlarmTransformerBase(tbase.TransformerBase):
|
||||
def _extract_action_type(self, entity_event):
|
||||
# TODO(ifat_afek): this method should reside together with the cache,
|
||||
# in the transformer code
|
||||
if DSProps.EVENT_TYPE in entity_event:
|
||||
if DSProps.EVENT_TYPE in entity_event and \
|
||||
entity_event[DSProps.EVENT_TYPE] == EventAction.DELETE_ENTITY:
|
||||
return entity_event[DSProps.EVENT_TYPE]
|
||||
|
||||
sync_mode = entity_event[DSProps.SYNC_MODE]
|
||||
if sync_mode in (SyncMode.UPDATE, SyncMode.SNAPSHOT):
|
||||
return EventAction.DELETE_ENTITY if self._ok_status(entity_event) \
|
||||
else EventAction.UPDATE_ENTITY
|
||||
|
||||
if SyncMode.INIT_SNAPSHOT == sync_mode:
|
||||
return EventAction.CREATE_ENTITY
|
||||
|
||||
raise VitrageTransformerError('Invalid sync mode: (%s)' % sync_mode)
|
||||
|
||||
def _key_values(self, *args):
|
||||
|
@ -60,9 +60,9 @@ class InstanceDriver(NovaDriverBase):
|
||||
'compute.instance.rebuild.end',
|
||||
'compute.instance.resize.end',
|
||||
'compute.instance.resize.revert.end',
|
||||
'compute.instance.resume',
|
||||
'compute.instance.resume.end',
|
||||
'compute.instance.shutdown.end',
|
||||
'compute.instance.suspend',
|
||||
'compute.instance.suspend.end',
|
||||
'compute.instance.volume.attach',
|
||||
'compute.instance.volume.detach',
|
||||
'compute.instance.pause.end',
|
||||
|
@ -58,14 +58,15 @@ class BaseApiTest(base.BaseTestCase):
|
||||
def _create_volume_and_attach(self, name, size, instance_id, mount_point):
|
||||
volume = self.cinder_client.volumes.create(display_name=name,
|
||||
size=size)
|
||||
time.sleep(3)
|
||||
time.sleep(2)
|
||||
self.cinder_client.volumes.attach(volume=volume,
|
||||
instance_uuid=instance_id,
|
||||
mountpoint=mount_point)
|
||||
|
||||
self._wait_for_status(20,
|
||||
self._wait_for_status(30,
|
||||
self._check_num_volumes,
|
||||
num_volumes=1)
|
||||
num_volumes=1,
|
||||
state='in-use')
|
||||
|
||||
time.sleep(2)
|
||||
|
||||
@ -80,9 +81,10 @@ class BaseApiTest(base.BaseTestCase):
|
||||
flavor=flavors_list[0],
|
||||
image=images_list[0]) for index in range(num_instances)]
|
||||
|
||||
self._wait_for_status(20,
|
||||
self._wait_for_status(30,
|
||||
self._check_num_instances,
|
||||
num_instances=num_instances)
|
||||
num_instances=num_instances,
|
||||
state='active')
|
||||
time.sleep(2)
|
||||
|
||||
return resources
|
||||
@ -95,7 +97,7 @@ class BaseApiTest(base.BaseTestCase):
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
self._wait_for_status(20,
|
||||
self._wait_for_status(30,
|
||||
self._check_num_instances,
|
||||
num_instances=0)
|
||||
|
||||
@ -116,11 +118,20 @@ class BaseApiTest(base.BaseTestCase):
|
||||
|
||||
time.sleep(2)
|
||||
|
||||
def _check_num_instances(self, num_instances=0):
|
||||
return len(self.nova_client.servers.list()) == num_instances
|
||||
def _check_num_instances(self, num_instances=0, state=''):
|
||||
if len(self.nova_client.servers.list()) != num_instances:
|
||||
return False
|
||||
|
||||
def _check_num_volumes(self, num_volumes=0):
|
||||
return len(self.cinder_client.volumes.list()) == num_volumes
|
||||
return all(instance.__dict__['status'].upper() == state.upper()
|
||||
for instance in self.nova_client.servers.list())
|
||||
|
||||
def _check_num_volumes(self, num_volumes=0, state=''):
|
||||
if len(self.cinder_client.volumes.list()) != num_volumes:
|
||||
return False
|
||||
|
||||
return all(volume.__dict__['status'].upper() == state.upper() and
|
||||
len(volume.__dict__['attachments']) == 1
|
||||
for volume in self.cinder_client.volumes.list())
|
||||
|
||||
@staticmethod
|
||||
def _create_graph_from_graph_dictionary(api_graph):
|
||||
|
@ -42,6 +42,8 @@ class TestAodhAlarm(BaseApiTest):
|
||||
instance_entities=1, instance_edges=2,
|
||||
aodh_entities=1, aodh_edges=1)
|
||||
self._validate_graph_correctness(graph, 5, 4, entities)
|
||||
except Exception as e:
|
||||
LOG.exception(e)
|
||||
finally:
|
||||
self._delete_ceilometer_alarms()
|
||||
self._delete_instances()
|
||||
@ -56,28 +58,35 @@ class TestAodhAlarm(BaseApiTest):
|
||||
host_entities=1, host_edges=1,
|
||||
aodh_entities=1, aodh_edges=0)
|
||||
self._validate_graph_correctness(graph, 4, 2, entities)
|
||||
except Exception as e:
|
||||
LOG.exception(e)
|
||||
finally:
|
||||
self._delete_ceilometer_alarms()
|
||||
|
||||
def _create_ceilometer_alarm(self, resource_id=None):
|
||||
aodh_request = self._aodh_request(resource_id=resource_id)
|
||||
self.ceilometer_client.alarms.create(**aodh_request)
|
||||
self._wait_for_status(20,
|
||||
self._wait_for_status(30,
|
||||
self._check_num_alarms,
|
||||
num_alarms=1)
|
||||
num_alarms=1,
|
||||
state='alarm')
|
||||
time.sleep(25)
|
||||
|
||||
def _delete_ceilometer_alarms(self):
|
||||
alarms = self.ceilometer_client.alarms.list()
|
||||
for alarm in alarms:
|
||||
self.ceilometer_client.alarms.delete(alarm.alarm_id)
|
||||
self._wait_for_status(20,
|
||||
self._wait_for_status(30,
|
||||
self._check_num_alarms,
|
||||
num_alarms=0)
|
||||
time.sleep(25)
|
||||
|
||||
def _check_num_alarms(self, num_alarms=0):
|
||||
return len(self.ceilometer_client.alarms.list()) == num_alarms
|
||||
def _check_num_alarms(self, num_alarms=0, state=''):
|
||||
if len(self.ceilometer_client.alarms.list()) != num_alarms:
|
||||
return False
|
||||
|
||||
return all(alarm.__dict__['state'].upper() == state.upper()
|
||||
for alarm in self.ceilometer_client.alarms.list())
|
||||
|
||||
def _aodh_request(self, resource_id=None):
|
||||
query = []
|
||||
|
@ -35,5 +35,7 @@ class TestCinderVolume(BaseTopologyTest):
|
||||
instance_entities=3, instance_edges=4,
|
||||
volume_entities=1, volume_edges=1)
|
||||
self._validate_graph_correctness(graph, 7, 6, entities)
|
||||
except Exception as e:
|
||||
LOG.exception(e)
|
||||
finally:
|
||||
self._rollback_to_default()
|
||||
|
@ -34,5 +34,7 @@ class TestNova(BaseTopologyTest):
|
||||
host_entities=1, host_edges=4,
|
||||
instance_entities=3, instance_edges=3)
|
||||
self._validate_graph_correctness(graph, 6, 5, entities)
|
||||
except Exception as e:
|
||||
LOG.exception(e)
|
||||
finally:
|
||||
self._rollback_to_default()
|
||||
|
@ -39,6 +39,8 @@ class TestStaticPhysical(BaseApiTest):
|
||||
host_entities=1, host_edges=3,
|
||||
switch_entities=2, switch_edges=2)
|
||||
self._validate_graph_correctness(graph, 5, 4, entities)
|
||||
except Exception as e:
|
||||
LOG.exception(e)
|
||||
finally:
|
||||
self._delete_switches()
|
||||
|
||||
|
@ -45,6 +45,7 @@ class BaseTopologyTest(BaseApiTest):
|
||||
self._create_volume_and_attach('volume-1', 1,
|
||||
resources[0].__dict__['id'],
|
||||
'/tmp/vda')
|
||||
|
||||
# waiting until all the entities creation were processed by the
|
||||
# entity graph processor
|
||||
time.sleep(end_sleep)
|
||||
@ -55,7 +56,7 @@ class BaseTopologyTest(BaseApiTest):
|
||||
|
||||
# waiting until all the entities deletion were processed by the
|
||||
# entity graph processor
|
||||
time.sleep(5)
|
||||
time.sleep(2)
|
||||
|
||||
@staticmethod
|
||||
def _compare_graphs(api_graph, cli_graph):
|
||||
|
@ -45,6 +45,8 @@ class TestTopology(BaseTopologyTest):
|
||||
instance_entities=3, instance_edges=4,
|
||||
volume_entities=1, volume_edges=1)
|
||||
self._validate_graph_correctness(graph, 7, 6, entities)
|
||||
except Exception as e:
|
||||
LOG.exception(e)
|
||||
finally:
|
||||
self._rollback_to_default()
|
||||
|
||||
@ -59,6 +61,8 @@ class TestTopology(BaseTopologyTest):
|
||||
host_entities=1, host_edges=4,
|
||||
instance_entities=3, instance_edges=3)
|
||||
self._validate_graph_correctness(graph, 6, 5, entities)
|
||||
except Exception as e:
|
||||
LOG.exception(e)
|
||||
finally:
|
||||
self._rollback_to_default()
|
||||
|
||||
@ -72,18 +76,22 @@ class TestTopology(BaseTopologyTest):
|
||||
host_entities=1, host_edges=4,
|
||||
instance_entities=3, instance_edges=3)
|
||||
self._validate_graph_correctness(graph, 6, 5, entities)
|
||||
except Exception as e:
|
||||
LOG.exception(e)
|
||||
finally:
|
||||
self._rollback_to_default()
|
||||
|
||||
def test_tree_with_query(self):
|
||||
try:
|
||||
# create entities
|
||||
self._create_entities(num_instances=3, end_sleep=10)
|
||||
self._create_entities(num_instances=3)
|
||||
api_graph = self.vitrage_client.topology.get(
|
||||
graph_type='tree', query=self._tree_query())
|
||||
graph = self._create_graph_from_tree_dictionary(api_graph)
|
||||
entities = self._entities_validation_data(
|
||||
host_entities=1, host_edges=1)
|
||||
self._validate_graph_correctness(graph, 3, 2, entities)
|
||||
except Exception as e:
|
||||
LOG.exception(e)
|
||||
finally:
|
||||
self._rollback_to_default()
|
||||
|
Loading…
Reference in New Issue
Block a user