def test_gnocchi_aggregation_by_metrics_threshold_alarm(self): try: # Action nova_utils.create_instances(num_instances=self.NUM_INSTANCE) aodh_utils.create_aodh_metrics_threshold_alarm() api_graph = self.vitrage_client.topology.get(all_tenants=True) graph = self._create_graph_from_graph_dictionary(api_graph) entities = self._entities_validation_data( host_entities=1, host_edges=1 + self.NUM_INSTANCE, instance_entities=self.NUM_INSTANCE, instance_edges=2 * self.NUM_INSTANCE, aodh_entities=self.NUM_ALARM, aodh_edges=0) num_entities = self.num_default_entities + \ 2 * self.NUM_INSTANCE + self.NUM_ALARM + \ self.num_default_networks + self.num_default_ports num_edges = self.num_default_edges + 3 * self.NUM_INSTANCE + \ self.num_default_ports self._validate_graph_correctness(graph, num_entities, num_edges, entities) except Exception as e: self._handle_exception(e) raise finally: aodh_utils.delete_all_aodh_alarms() aodh_utils.delete_all_gnocchi_metrics() nova_utils.delete_all_instances()
def _delete_entities(): cinder_utils.delete_all_volumes() nova_utils.delete_all_instances() # waiting until all the entities deletion were processed by the # entity graph processor time.sleep(2)
def test_alarm_with_resource_id(self): try: # Action nova_utils.create_instances(num_instances=self.NUM_INSTANCE) aodh_utils.create_aodh_alarm(self._find_instance_resource_id()) # Calculate expected results api_graph = self.vitrage_client.topology.get(all_tenants=True) graph = self._create_graph_from_graph_dictionary(api_graph) entities = self._entities_validation_data( host_entities=1, host_edges=1 + self.NUM_INSTANCE, instance_entities=self.NUM_INSTANCE, instance_edges=2 * self.NUM_INSTANCE + self.NUM_ALARM, aodh_entities=self.NUM_ALARM, aodh_edges=self.NUM_ALARM) num_entities = self.num_default_entities + \ 2 * self.NUM_INSTANCE + self.NUM_ALARM + \ self.num_default_networks + self.num_default_ports num_edges = self.num_default_edges + 3 * self.NUM_INSTANCE + \ self.NUM_ALARM + self.num_default_ports # Test Assertions self._validate_graph_correctness(graph, num_entities, num_edges, entities) except Exception as e: self._handle_exception(e) raise finally: aodh_utils.delete_all_aodh_alarms() nova_utils.delete_all_instances()
def test_action_set_state_instance(self): vm_id = "" try: vm_id = nova_utils.create_instances(set_public_network=True)[0].id # Do orig_instance = v_utils.get_first_instance(id=vm_id) self._trigger_do_action(TRIGGER_ALARM_3) curr_instance = v_utils.get_first_instance(id=vm_id) self.assertEqual( 'ERROR', curr_instance.get(VProps.VITRAGE_AGGREGATED_STATE), 'state should change after set_state action') # Undo self._trigger_undo_action(TRIGGER_ALARM_3) curr_instance = v_utils.get_first_instance(id=vm_id) self.assertEqual( orig_instance.get(VProps.VITRAGE_AGGREGATED_STATE), curr_instance.get(VProps.VITRAGE_AGGREGATED_STATE), 'state should change after undo set_state action') except Exception as e: self._handle_exception(e) raise finally: self._trigger_undo_action(TRIGGER_ALARM_3) nova_utils.delete_all_instances(id=vm_id)
def tearDownClass(cls): if cls._templates is not None: v_utils.delete_template(cls._templates[0]['uuid']) v_utils.delete_template(cls._templates[1]['uuid']) v_utils.delete_template(cls._templates[2]['uuid']) # Delete the workflow cls.mistral_client.workflows.delete(WF_NAME) nova_utils.delete_all_instances()
def test_resource_show_with_no_existing_resource(self): """resource_show test no existing resource""" try: self.assertRaises(ClientException, self.vitrage_client.resource.get, 'test_for_no_existing') finally: nova_utils.delete_all_instances()
def _do_test_action_mark_down_instance(self, trigger_name): vm_id = "" try: vm_id = nova_utils.create_instances(set_public_network=True)[0].id # Do self._trigger_do_action(trigger_name) nova_instance = TempestClients.nova().servers.get(vm_id) self.assertEqual("ERROR", nova_instance.status) # Undo self._trigger_undo_action(trigger_name) nova_instance = TempestClients.nova().servers.get(vm_id) self.assertEqual("ACTIVE", nova_instance.status) finally: self._trigger_undo_action(trigger_name) nova_utils.delete_all_instances(id=vm_id)
def test_resource_list_with_no_existing_type(self): """resource list with no existing type""" try: instances = nova_utils.create_instances(num_instances=1, set_public_network=True) self.assertThat(instances, IsNotEmpty(), 'The instances list is empty') resources = self.vitrage_client.resource.list( resource_type=CINDER_VOLUME_DATASOURCE, all_tenants=True) self.assertThat(resources, IsEmpty()) except Exception as e: self._handle_exception(e) raise finally: nova_utils.delete_all_instances()
def test_default_resource_list(self): """resource list with default query get the resources: network, instance, port """ try: instances = nova_utils.create_instances(num_instances=1, set_public_network=True) self.assertThat(instances, IsNotEmpty(), 'The instances list is empty') resources = self.vitrage_client.resource.list(all_tenants=False) self.assertThat(resources, matchers.HasLength(3)) except Exception as e: self._handle_exception(e) raise finally: nova_utils.delete_all_instances()
def test_resource_list_with_existing_type(self): """resource list with existing type get the resource: one instance """ try: instances = nova_utils.create_instances(num_instances=1, set_public_network=True) self.assertThat(instances, IsNotEmpty(), 'The instances list is empty') resources = self.vitrage_client.resource.list( resource_type=NOVA_INSTANCE_DATASOURCE, all_tenants=True) self.assertThat(resources, matchers.HasLength(1)) except Exception as e: self._handle_exception(e) raise finally: nova_utils.delete_all_instances()
def test_action_mark_down_instance(self): vm_id = "" try: vm_id = nova_utils.create_instances(set_public_network=True)[0].id # Do self._trigger_do_action(TRIGGER_ALARM_5) nova_instance = TempestClients.nova().servers.get(vm_id) self.assertEqual("ERROR", str(nova_instance.status)) # Undo self._trigger_undo_action(TRIGGER_ALARM_5) nova_instance = TempestClients.nova().servers.get(vm_id) self.assertEqual("ACTIVE", str(nova_instance.status)) except Exception as e: self._handle_exception(e) raise finally: pass self._trigger_undo_action(TRIGGER_ALARM_5) nova_utils.delete_all_instances(id=vm_id)
def test_resource_list_with_all_tenants(self): """resource list with all tenants get the resources: """ try: resources_before = self.vitrage_client.resource.list( all_tenants=True) instances = nova_utils.create_instances(num_instances=1, set_public_network=True) self.assertThat(instances, IsNotEmpty(), 'The instances list is empty') resources = self.vitrage_client.resource.list(all_tenants=True) self.assertEqual(len(resources_before) + 2, len(resources)) except Exception as e: self._handle_exception(e) raise finally: nova_utils.delete_all_instances()
def test_compare_cli_vs_api_resource_list(self): """resource list """ try: instances = nova_utils.create_instances(num_instances=1, set_public_network=True) self.assertThat(instances, IsNotEmpty(), 'The instances list is empty') api_resources = self.vitrage_client.resource.list( all_tenants=True) LOG.info("api_resources = %s", api_resources) cli_resources = utils.run_vitrage_command( 'vitrage resource list --all -f json', self.conf) self._compare_resources(api_resources, cli_resources) except Exception as e: self._handle_exception(e) raise finally: nova_utils.delete_all_instances()
def test_compare_cli_vs_api_alarms(self): """Wrapper that returns a test graph.""" try: instances = nova_utils.create_instances(num_instances=1, set_public_network=True) self.assertThat(instances, IsNotEmpty(), 'The instances list is empty') aodh_utils.create_aodh_alarm(resource_id=instances[0].id, name='tempest_aodh_test') api_alarms = TempestClients.vitrage().alarm.list(vitrage_id='all', all_tenants=True) cli_alarms = utils.run_vitrage_command('vitrage alarm list', self.conf) self._compare_alarms_lists(api_alarms, cli_alarms, AODH_DATASOURCE, instances[0].id) except Exception as e: self._handle_exception(e) raise finally: aodh_utils.delete_all_aodh_alarms() nova_utils.delete_all_instances()
def test_neutron(self): """neutron test This test validate correctness topology graph with neutron module """ try: # Action nova_utils.create_instances(num_instances=self.NUM_INSTANCE, set_public_network=True) # Calculate expected results api_graph = self.vitrage_client.topology.get(all_tenants=True) graph = self._create_graph_from_graph_dictionary(api_graph) entities = self._entities_validation_data( host_entities=1, host_edges=1 + self.NUM_INSTANCE, instance_entities=self.NUM_INSTANCE, instance_edges=2 * self.NUM_INSTANCE, network_entities=self.num_default_networks, network_edges=self.num_default_ports + self.NUM_INSTANCE, port_entities=self.num_default_ports + self.NUM_INSTANCE, port_edges=self.num_default_ports + 2 * self.NUM_INSTANCE) num_entities = self.num_default_entities + \ 2 * self.NUM_INSTANCE + \ self.num_default_networks + self.num_default_ports num_edges = self.num_default_edges + 3 * self.NUM_INSTANCE + \ self.num_default_ports # Test Assertions self._validate_graph_correctness(graph, num_entities, num_edges, entities) except Exception as e: self._handle_exception(e) raise finally: nova_utils.delete_all_instances()
def _do_test_action_set_state_instance(self, trigger_name): vm_id = "" try: vm_id = nova_utils.create_instances(set_public_network=True)[0].id # Do orig_instance = v_utils.get_first_instance(id=vm_id) self._trigger_do_action(trigger_name) curr_instance = v_utils.get_first_instance(id=vm_id) self.assertEqual( 'ERROR', curr_instance.get(VProps.VITRAGE_AGGREGATED_STATE), 'state should change after set_state action') # Undo self._trigger_undo_action(trigger_name) curr_instance = v_utils.get_first_instance(id=vm_id) self.assertEqual( orig_instance.get(VProps.VITRAGE_AGGREGATED_STATE), curr_instance.get(VProps.VITRAGE_AGGREGATED_STATE), 'state should change after undo set_state action') finally: self._trigger_undo_action(trigger_name) nova_utils.delete_all_instances(id=vm_id)
def tearDown(self): super(TestAodhAlarm, self).tearDown() aodh_utils.delete_all_aodh_alarms() aodh_utils.delete_all_gnocchi_metrics() nova_utils.delete_all_instances()
def tearDown(self): super(TestNeutron, self).tearDown() nova_utils.delete_all_instances()
def _clean_all(): nova_utils.delete_all_instances() aodh_utils.delete_all_aodh_alarms()