def create_volume_with_exist_size(vol_name): utils.run_vitrage_command("cinder create --name " + vol_name + " 5") text_out = utils.run_vitrage_command("cinder list") if vol_name in text_out: LOG.debug("The expected volume exist in the cinder list") else: LOG.error("The expected volume not exist in the cinder list")
def create_vm_with_exist_image(vm_name, flavor_id, image_id): utils.run_vitrage_command("nova boot " + vm_name + " --flavor " + flavor_id + " --image " + image_id) text_out = utils.run_vitrage_command("nova list") if vm_name in text_out: LOG.debug("The expected vm exist in the nova list") else: LOG.error("The expected vm not exist in the nova list")
def attach_volume(self, vm_name, vol_name): vm_id = self.get_instance_id_by_name(vm_name) vol_id = self.get_volume_id_by_name(vol_name) utils.run_vitrage_command("nova volume-attach " + vm_id + " " + vol_id) text_out = utils.run_vitrage_command("cinder list") if vm_id in text_out: LOG.debug("The expected volume attached to vm") else: LOG.error("The expected volume did not attached to vm")
def test_compare_api_and_cli(self): """Wrapper that returns a test graph.""" api_graph = self.vitrage_client.topology.get() cli_graph = utils.run_vitrage_command('vitrage topology show', self.conf) self.assertEqual(True, self._compare_graphs(api_graph, cli_graph))
def test_compare_cli_and_api(self): """compare_cli_and_api test There test validate correctness of rca of created aodh event alarms, and compare them with cli rca """ try: instances = nova_utils.create_instances(num_instances=1, set_public_network=True) self.assertNotEqual(len(instances), 0, 'Failed to create instance') instance_alarm = self._create_alarm( resource_id=instances[0].id, alarm_name='instance_rca_alarm', unic=True) vitrage_id = instance_alarm.get(VProps.VITRAGE_ID) api_rca = self.vitrage_client.rca.get(alarm_id=vitrage_id) cli_rca = utils.run_vitrage_command( 'vitrage rca show ' + vitrage_id, self.conf) self._compare_rca(api_rca, cli_rca) except Exception as e: self._handle_exception(e) raise finally: self._clean_all()
def test_compare_cil_and_api(self): """compare_cil_and_api test There test validate correctness of rca of created aodh event alarms, and compare them with cli rca """ try: instances = self._create_instances(num_instances=1) self.assertNotEqual(len(instances), 0, 'Failed to create instance') instance_alarm = self._create_alarm( resource_id=instances[0].id, alarm_name='instance_rca_alarm', unic=True) vitrage_id = self._get_value(instance_alarm, VProps.VITRAGE_ID) api_rca = self.vitrage_client.rca.get(alarm_id=vitrage_id) cli_rca = utils.run_vitrage_command( 'vitrage rca show ' + vitrage_id, self.conf) self._compare_rca(api_rca, cli_rca) except Exception: LOG.error('Got exception', False) finally: self._clean_all()
def test_compare_alarms(self): """Wrapper that returns a test graph.""" self._create_instances(num_instances=3) api_alarms = self.vitrage_client.alarms.list(vitrage_id=None) cli_alarms = utils.run_vitrage_command('vitrage alarms list') self.assertEqual(True, self._compare_alarms_lists(api_alarms, cli_alarms)) self._delete_instances()
def get_volume_id_by_name(vol_name): text_out = utils.run_vitrage_command("cinder list") for line in text_out.splitlines(): if vol_name in line: vol_id = utils.get_regex_result("\|\s+(.*)\s+\|", line) vol_id = vol_id.split(" ")[0] LOG.debug("The volume id from the cinder list is " + vol_id) return vol_id return None
def get_instance_id_by_name(vm_name): text_out = utils.run_vitrage_command("nova list") for line in text_out.splitlines(): if vm_name in line: vm_id = utils.get_regex_result("\|\s+(.*)\s+\|", line) vm_id = vm_id.split(" ")[0] LOG.debug("The instance id from the nova list is " + vm_id) return vm_id return None
def test_compare_api_and_cli(self): """compare_api_and_cli This test validate correctness of topology graph: cli via api """ api_graph = self.vitrage_client.topology.get() cli_graph = utils.run_vitrage_command("vitrage topology show", self.conf) self._compare_graphs(api_graph, cli_graph)
def test_compare_api_and_cli(self): """compare_api_and_cli This test validate correctness of topology graph: cli via api """ api_graph = self.vitrage_client.topology.get(all_tenants=True) cli_graph = utils.run_vitrage_command( 'vitrage topology show --all-tenants', self.conf) self._compare_graphs(api_graph, cli_graph)
def get_flavor_id_from_list(): text_out = utils.run_vitrage_command("nova flavor-list") try: flavor_id = utils.get_regex_result("\|\s+(\d+)\s+\|", text_out.splitlines()[3]) except Exception as e: LOG.exception("Failed to get flavor id from the list %s ", e) return None LOG.debug("The flavor id from the list is " + flavor_id) return flavor_id
def test_compare_resource_show(self): """resource_show test""" resource_list = self.vitrage_client.resource.list() self.assertNotEqual(len(resource_list), 0) for resource in resource_list: api_resource_show = \ self.vitrage_client.resource.show(resource['vitrage_id']) cli_resource_show = utils.run_vitrage_command( 'vitrage resource show ' + resource['vitrage_id'], self.conf) self._compare_resource_show(api_resource_show, cli_resource_show)
def get_image_id_from_list(): text_out = utils.run_vitrage_command("glance image-list") try: image_id = utils.get_regex_result("\|\s+(.*)\s+\|", text_out.splitlines()[3]) image_id = image_id.split(" ")[0] except Exception as e: LOG.exception("Failed to get image id from the list %s ", e) return None LOG.debug("The image id from the list is " + image_id) return image_id
def test_templates_list(self): """template_list test There test validate correctness of template list, compare templates files existence with default folder and between cli via api ... """ api_template_list = self.vitrage_client.template.list() cli_template_list = utils.run_vitrage_command('vitrage template list', self.conf) self._compare_template_lists(api_template_list, cli_template_list)
def test_templates_list(self): """template_list test There test validate correctness of template list, compare templates files existence with default folder and between cli via api ... """ api_template_list = self.vitrage_client.template.list() cli_template_list = utils.run_vitrage_command( 'vitrage template list', self.conf) self._compare_template_lists(api_template_list, cli_template_list)
def test_compare_resource_show(self): """resource_show test""" resource_list = self.vitrage_client.resource.list(all_tenants=False) self.assertNotEqual(len(resource_list), 0) for resource in resource_list: api_resource_show = \ self.vitrage_client.resource.get(resource[VProps.VITRAGE_ID]) cli_resource_show = utils.run_vitrage_command( 'vitrage resource show ' + resource[VProps.VITRAGE_ID], self.conf) self._compare_resource_show( api_resource_show, cli_resource_show)
def test_run_env(self): if self._show_vitrage_processes() is True: LOG.debug('The vitrage processed existed and should be removed') self._stop_vitrage_processes() self._get_env_params() utils.change_terminal_dir('/home/stack/devstack') utils.run_vitrage_command(". openrc " + self.user + " " + self.user) utils.run_from_terminal("openstack service create rca" + " --name vitrage") utils.run_from_terminal("openstack endpoint create rca" + # " --os-username " + self.user + # " --os-username " + self.user + # " --os-password " + self.password + # " --os-auth-url " + self.url + # " --os-project-name admin" + " --adminurl http://" + self.host + ":" + str(self.port) + " --internalurl http://" + self.host + ":" + str(self.port) + " --publicurl http://" + self.host + ":" + str(self.port) + " --region RegionOne") utils.run_from_terminal("nohup vitrage-graph > /tmp/nohup-graph.out &") utils.run_from_terminal("nohup vitrage-api > /tmp/nohup-api.out &") if self._show_vitrage_processes() is False: LOG.error("No vitrage processes founded") raise ValueError("No vitrage processes founded") else: LOG.info('The vitrage processes exists') if self._validate_vitrage_processes() is False: LOG.error("The vitrage processes are not correct") self._stop_vitrage_processes() raise ValueError("The vitrage processes are not correct")
def test_compare_templates_validation(self): """template_validate test There test validate correctness of template validation, compare templates files validation between cli via api """ path = self.DEFAULT_PATH api_template_validation = \ self.vitrage_client.template.validate(path=path) cli_template_validation = utils.run_vitrage_command( 'vitrage template validate --path ' + path, self.conf) self._compare_template_validations(api_template_validation, cli_template_validation)
def test_compare_templates_validation(self): """template_validate test There test validate correctness of template validation, compare templates files validation between cli via api """ path = self.DEFAULT_PATH api_template_validation = \ self.vitrage_client.template.validate(path=path) cli_template_validation = utils.run_vitrage_command( 'vitrage template validate --path ' + path, self.conf) self._compare_template_validations( api_template_validation, cli_template_validation)
def test_compare_cil_and_api(self): try: vitrage_id = self._get_alarm_id( resource_type=NOVA_INSTANCE_DATASOURCE, alarm_name='instance_rca_alarm', unic=True) api_rca = self.vitrage_client.rca.get(alarm_id=vitrage_id) cli_rca = utils.run_vitrage_command( 'vitrage rca show ' + vitrage_id, self.conf) self.assertTrue(self._compare_rca(api_rca, cli_rca)) finally: self._delete_ceilometer_alarms() self._delete_instances()
def test_run_env(self): if self._show_vitrage_processes() is True: LOG.debug('The vitrage processed existed and should be removed') self._stop_vitrage_processes() self._get_env_params() utils.change_terminal_dir('/home/stack/devstack') utils.run_vitrage_command(". openrc " + self.user + " " + self.user) utils.run_from_terminal("openstack service create rca" + " --name vitrage") utils.run_from_terminal( "openstack endpoint create rca" + # " --os-username " + self.user + # " --os-username " + self.user + # " --os-password " + self.password + # " --os-auth-url " + self.url + # " --os-project-name admin" + " --adminurl http://" + self.host + ":" + str(self.port) + " --internalurl http://" + self.host + ":" + str(self.port) + " --publicurl http://" + self.host + ":" + str(self.port) + " --region RegionOne") utils.run_from_terminal("nohup vitrage-graph > /tmp/nohup-graph.out &") utils.run_from_terminal("nohup vitrage-api > /tmp/nohup-api.out &") if self._show_vitrage_processes() is False: LOG.error("No vitrage processes founded") raise ValueError("No vitrage processes founded") else: LOG.info('The vitrage processes exists') if self._validate_vitrage_processes() is False: LOG.error("The vitrage processes are not correct") self._stop_vitrage_processes() raise ValueError("The vitrage processes are not correct")
def test_compare_cli_vs_api_resource_list(self): """resource list """ try: instances = self._create_instances(num_instances=1) self.assertNotEqual(len(instances), 0, 'The instances list is empty') api_resources = self.vitrage_client.resource.list() cli_resources = utils.run_vitrage_command( 'vitrage resource list -f json', self.conf) self._compare_resources(api_resources, cli_resources) except Exception as e: self._handle_exception(e) raise finally: self._delete_instances()
def test_compare_template_show(self): """templates_show test There test validate correctness of uploaded template files one by one with full details (in /etc/vitrage/templates folder) """ template_list = self.vitrage_client.template.list() self.assertNotEqual(len(template_list), 0) for item in template_list: api_template_show = self.vitrage_client.template.show(item['uuid']) cli_template_show = utils.run_vitrage_command( 'vitrage template show ' + item['uuid'], self.conf) self._compare_template_show(api_template_show, cli_template_show) self._validate_template_structure(item, api_template_show)
def test_compare_template_show(self): """templates_show test There test validate correctness of uploaded template files one by one with full details (in /etc/vitrage/templates folder) """ template_list = self.vitrage_client.template.list() self.assertNotEqual(len(template_list), 0) for item in template_list: api_template_show = self.vitrage_client.template.show(item['uuid']) cli_template_show = utils.run_vitrage_command( 'vitrage template show ' + item['uuid'], self.conf) self._compare_template_show( api_template_show, cli_template_show) self._validate_template_structure(item, api_template_show)
def test_compare_cli_vs_api_alarms(self): """Wrapper that returns a test graph.""" try: resources = self._create_instances(num_instances=1) self._create_ceilometer_alarm(resource_id=resources[0].id, name='tempest_aodh_test') api_alarms = self.vitrage_client.alarms.list(vitrage_id=None) cli_alarms = utils.run_vitrage_command( 'vitrage alarms list', self.conf) self.assertTrue(self._compare_alarms_lists( api_alarms, cli_alarms, AODH_DATASOURCE, utils.uni2str(resources[0].id))) finally: self._delete_ceilometer_alarms() self._delete_instances()
def test_compare_cli_vs_api_alarms(self): """Wrapper that returns a test graph.""" try: instances = self._create_instances(num_instances=1) self.assertNotEqual(len(instances), 0, 'The instances list is empty') self._create_ceilometer_alarm(resource_id=instances[0].id, name='tempest_aodh_test') api_alarms = self.vitrage_client.alarms.list(vitrage_id=None) cli_alarms = utils.run_vitrage_command('vitrage alarm list', self.conf) self._compare_alarms_lists(api_alarms, cli_alarms, AODH_DATASOURCE, utils.uni2str(instances[0].id)) finally: self._delete_ceilometer_alarms() self._delete_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.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()
def test_compare_cli_vs_api_alarms(self): """Wrapper that returns a test graph.""" try: instances = self._create_instances(num_instances=1) self.assertNotEqual(len(instances), 0, 'The instances list is empty') self._create_ceilometer_alarm(resource_id=instances[0].id, name='tempest_aodh_test') api_alarms = self.vitrage_client.alarms.list(vitrage_id=None) cli_alarms = utils.run_vitrage_command( 'vitrage alarm list', self.conf) self._compare_alarms_lists( api_alarms, cli_alarms, AODH_DATASOURCE, utils.uni2str(instances[0].id)) except Exception as e: LOG.exception(e) raise e finally: self._delete_ceilometer_alarms() self._delete_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.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()
def test_compare_cil_and_api(self): """compare_cil_and_api test There test validate correctness of rca of created aodh event alarms, and compare them with cli rca """ try: instances = self._create_instances(num_instances=1) self.assertNotEqual(len(instances), 0, "Failed to create instance") instance_alarm = self._create_alarm(resource_id=instances[0].id, alarm_name="instance_rca_alarm", unic=True) vitrage_id = self._get_value(instance_alarm, VProps.VITRAGE_ID) api_rca = self.vitrage_client.rca.get(alarm_id=vitrage_id) cli_rca = utils.run_vitrage_command("vitrage rca show " + vitrage_id, self.conf) self._compare_rca(api_rca, cli_rca) except Exception as e: LOG.exception(e) raise e finally: self._clean_all()