コード例 #1
0
ファイル: test_aodh.py プロジェクト: pczerkas/vitrage
    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()
コード例 #2
0
    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 = vitrage_utils.get_first_instance(id=vm_id)
            self._trigger_do_action(TRIGGER_ALARM_3)
            curr_instance = vitrage_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 = vitrage_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)
コード例 #3
0
ファイル: base.py プロジェクト: pczerkas/vitrage
    def _delete_entities(self):
        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)
コード例 #4
0
    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'))
        except Exception as e:
            self._handle_exception(e)

        finally:
            nova_utils.delete_all_instances()
コード例 #5
0
 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.assertNotEqual(len(instances), 0,
                             'The instances list is empty')
         resources = self.vitrage_client.resource.list(
             resource_type=CINDER_VOLUME_DATASOURCE,
             all_tenants=True)
         self.assertEqual(0, len(resources))
     except Exception as e:
         self._handle_exception(e)
         raise
     finally:
         nova_utils.delete_all_instances()
コード例 #6
0
    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.assertNotEqual(len(instances), 0,
                                'The instances list is empty')
            resources = self.vitrage_client.resource.list(all_tenants=False)
            self.assertEqual(3, len(resources))
        except Exception as e:
            self._handle_exception(e)
            raise
        finally:
            nova_utils.delete_all_instances()
コード例 #7
0
    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.assertNotEqual(len(instances), 0,
                                'The instances list is empty')
            api_resources = self.vitrage_client.resource.list(
                all_tenants=True)
            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()
コード例 #8
0
    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_3)
            nova_instance = TempestClients.nova().servers.get(vm_id)
            self.assertEqual("ERROR", str(nova_instance.status))

            # Undo
            self._trigger_undo_action(TRIGGER_ALARM_3)
            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_3)
            nova_utils.delete_all_instances(id=vm_id)
コード例 #9
0
    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.assertNotEqual(len(instances), 0,
                                '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()
コード例 #10
0
ファイル: test_alarms.py プロジェクト: pczerkas/vitrage
    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.assertNotEqual(len(instances), 0,
                                '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()
コード例 #11
0
    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()
コード例 #12
0
ファイル: test_persistor.py プロジェクト: pczerkas/vitrage
    def test_create_instance(self):
        """This function validates creating instance events.

        Create instance generates three ordered events.
        1. neutron port is created.
        2. the port is updated to the created instance.
        3. nova instance is created with the given hostname.
        """
        try:

            # Action
            time_before_action = datetime.datetime.utcnow()
            nova_utils.create_instances(num_instances=1,
                                        name=INSTANCE_NAME,
                                        set_public_network=True)

            writen_events = self._load_db_events(time_before_action)

            port_create_event = get_first_match(writen_events,
                                                PORT_CREATE_EVENT)

            self.assertIsNotNone(port_create_event,
                                 "port.create.end event is not writen to db")

            port_update_event = get_first_match(writen_events,
                                                PORT_UPDATE_EVENT)

            self.assertIsNotNone(port_update_event,
                                 "port.update.end event is not writen to db")

            instance_create_event = get_first_match(writen_events,
                                                    INSTANCE_CREATE_EVENT)

            self.assertIsNotNone(
                instance_create_event,
                "compute.instance.create.end event is not "
                "writen to db")

            # Check correct timestamp order
            events_timestamp_list = \
                [port_create_event.collector_timestamp,
                 port_update_event.collector_timestamp,
                 instance_create_event.collector_timestamp]

            self.assertEqual(sorted(events_timestamp_list),
                             events_timestamp_list,
                             "Events Timestamp order is wrong")

            # Check correct event_id order
            events_id_list = \
                [port_create_event.event_id,
                 port_update_event.event_id,
                 instance_create_event.event_id]

            self.assertEqual(sorted(events_id_list), events_id_list,
                             "Events id order is wrong")

        except Exception as e:
            self._handle_exception(e)
            raise

        finally:
            nova_utils.delete_all_instances()
コード例 #13
0
ファイル: base.py プロジェクト: pczerkas/vitrage
 def _clean_all(self):
     nova_utils.delete_all_instances()
     aodh_utils.delete_all_aodh_alarms()