From 3fc88cbddf66520a7a54cafe8155c8854579b33a Mon Sep 17 00:00:00 2001 From: Alexey Weyl Date: Tue, 24 Jan 2017 13:42:04 +0000 Subject: [PATCH] fix tempests in gate Change-Id: Ic14e9523c841b94c4cc7aeab2ec89d8f86ba102c --- .../consistency/consistency_enforcer.py | 3 +- vitrage/os_clients.py | 2 +- .../tests/api/alarms/test_alarms.py | 12 +++--- vitrage_tempest_tests/tests/api/base.py | 28 ++++++++++--- .../tests/api/datasources/test_aodh.py | 9 ++-- .../api/datasources/test_cinder_volume.py | 5 ++- .../tests/api/datasources/test_heat_stack.py | 5 ++- .../tests/api/datasources/test_neutron.py | 5 ++- .../tests/api/datasources/test_nova.py | 5 ++- .../api/datasources/test_static_physical.py | 5 ++- vitrage_tempest_tests/tests/api/rca/base.py | 11 ++--- .../tests/api/rca/test_rca.py | 21 +++++----- .../tests/api/templates/base.py | 23 ++++++----- .../tests/api/templates/test_template.py | 4 +- .../tests/api/topology/test_topology.py | 41 ++++++++++--------- 15 files changed, 103 insertions(+), 76 deletions(-) diff --git a/vitrage/entity_graph/consistency/consistency_enforcer.py b/vitrage/entity_graph/consistency/consistency_enforcer.py index e90b890c2..a8eacad2d 100644 --- a/vitrage/entity_graph/consistency/consistency_enforcer.py +++ b/vitrage/entity_graph/consistency/consistency_enforcer.py @@ -100,7 +100,8 @@ class ConsistencyEnforcer(object): 'and': [ {'!=': {VProps.TYPE: VITRAGE_TYPE}}, {'<': {VProps.SAMPLE_TIMESTAMP: str(utcnow() - timedelta( - seconds=2 * self.conf.datasources.snapshots_interval))}} + seconds=2 * self.conf.datasources.snapshots_interval))}}, + {'==': {VProps.IS_DELETED: False}} ] } diff --git a/vitrage/os_clients.py b/vitrage/os_clients.py index c03e9a125..140bf103c 100644 --- a/vitrage/os_clients.py +++ b/vitrage/os_clients.py @@ -70,7 +70,7 @@ def nova_client(conf): version=conf.nova_version, session=keystone_client.get_session(conf), region_name=auth_config.region_name, - interface=auth_config.interface, + endpoint_type='publicURL', ) LOG.info('Nova client created') return client diff --git a/vitrage_tempest_tests/tests/api/alarms/test_alarms.py b/vitrage_tempest_tests/tests/api/alarms/test_alarms.py index 1268183cf..7e18849be 100644 --- a/vitrage_tempest_tests/tests/api/alarms/test_alarms.py +++ b/vitrage_tempest_tests/tests/api/alarms/test_alarms.py @@ -13,6 +13,7 @@ # under the License. import json +import traceback from oslo_log import log as logging @@ -46,8 +47,8 @@ class TestAlarms(BaseAlarmsTest): self._compare_alarms_lists( api_alarms, cli_alarms, AODH_DATASOURCE, utils.uni2str(instances[0].id)) - except Exception as e: - LOG.exception(e) + except Exception: + traceback.print_exc() raise finally: self._delete_ceilometer_alarms() @@ -61,9 +62,10 @@ class TestAlarms(BaseAlarmsTest): self.assertIsNotNone(cli_alarms, 'The alarms list taken from cli is empty') - LOG.debug("The alarms list taken from cli is : %s", cli_alarms) - LOG.debug("The alarms list taken by api is : %s", - json.dumps(api_alarms)) + print("The alarms list taken from cli is : " + + str(cli_alarms)) + print("The alarms list taken by api is : " + + str(json.dumps(api_alarms))) cli_items = cli_alarms.splitlines() diff --git a/vitrage_tempest_tests/tests/api/base.py b/vitrage_tempest_tests/tests/api/base.py index 0fdeff4cd..7b38273da 100644 --- a/vitrage_tempest_tests/tests/api/base.py +++ b/vitrage_tempest_tests/tests/api/base.py @@ -55,10 +55,12 @@ class BaseApiTest(base.BaseTestCase): cls.vitrage_client = \ v_client.Client('1', session=keystone_client.get_session(cls.conf)) - cls.nova_client = os_clients.nova_client(cls.conf) - cls.cinder_client = os_clients.cinder_client(cls.conf) - cls.neutron_client = os_clients.neutron_client(cls.conf) - cls.heat_client = os_clients.heat_client(cls.conf) + cls.nova_client = cls._create_client(os_clients.nova_client, cls.conf) + cls.cinder_client = cls._create_client(os_clients.cinder_client, + cls.conf) + cls.neutron_client = cls._create_client(os_clients.neutron_client, + cls.conf) + cls.heat_client = cls._create_client(os_clients.heat_client, cls.conf) cls.num_default_networks = \ len(cls.neutron_client.list_networks()['networks']) @@ -67,6 +69,22 @@ class BaseApiTest(base.BaseTestCase): cls.num_default_entities = 3 cls.num_default_edges = 2 + @staticmethod + def _create_client(client_func, conf): + count = 0 + + while count < 40: + LOG.info("wait_for_client - " + client_func.func_name) + client = client_func(conf) + if client: + return client + count += 1 + time.sleep(5) + + LOG.info("wait_for_client - False") + + return None + @staticmethod def _filter_list_by_pairs_parameters(origin_list, keys, values): @@ -222,7 +240,7 @@ class BaseApiTest(base.BaseTestCase): return True count += 1 time.sleep(2) - LOG.info("wait_for_status - False") + print("wait_for_status - False") return False def _entities_validation_data(self, **kwargs): diff --git a/vitrage_tempest_tests/tests/api/datasources/test_aodh.py b/vitrage_tempest_tests/tests/api/datasources/test_aodh.py index 5e1fc36de..cdb3f114f 100644 --- a/vitrage_tempest_tests/tests/api/datasources/test_aodh.py +++ b/vitrage_tempest_tests/tests/api/datasources/test_aodh.py @@ -11,6 +11,7 @@ # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations # under the License. +import traceback from oslo_log import log as logging @@ -54,8 +55,8 @@ class TestAodhAlarm(BaseAlarmsTest): num_entities, num_edges, entities) - except Exception as e: - LOG.exception(e) + except Exception: + traceback.print_exc() raise finally: self._delete_ceilometer_alarms() @@ -83,8 +84,8 @@ class TestAodhAlarm(BaseAlarmsTest): num_entities, num_edges, entities) - except Exception as e: - LOG.exception(e) + except Exception: + traceback.print_exc() raise finally: self._delete_ceilometer_alarms() diff --git a/vitrage_tempest_tests/tests/api/datasources/test_cinder_volume.py b/vitrage_tempest_tests/tests/api/datasources/test_cinder_volume.py index 60fe0de13..7e9e2a7d0 100644 --- a/vitrage_tempest_tests/tests/api/datasources/test_cinder_volume.py +++ b/vitrage_tempest_tests/tests/api/datasources/test_cinder_volume.py @@ -11,6 +11,7 @@ # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations # under the License. +import traceback from oslo_log import log as logging from vitrage_tempest_tests.tests.api.topology.base import BaseTopologyTest @@ -53,8 +54,8 @@ class TestCinderVolume(BaseTopologyTest): num_entities, num_edges, entities) - except Exception as e: - LOG.exception(e) + except Exception: + traceback.print_exc() raise finally: self._rollback_to_default() diff --git a/vitrage_tempest_tests/tests/api/datasources/test_heat_stack.py b/vitrage_tempest_tests/tests/api/datasources/test_heat_stack.py index 1bf1ef235..781ac7bf0 100644 --- a/vitrage_tempest_tests/tests/api/datasources/test_heat_stack.py +++ b/vitrage_tempest_tests/tests/api/datasources/test_heat_stack.py @@ -13,6 +13,7 @@ # under the License. import time +import traceback from oslo_log import log as logging @@ -62,8 +63,8 @@ class TestHeatStack(BaseTopologyTest): num_entities, num_edges, entities) - except Exception as e: - LOG.exception(e) + except Exception: + traceback.print_exc() raise finally: self._delete_stacks() diff --git a/vitrage_tempest_tests/tests/api/datasources/test_neutron.py b/vitrage_tempest_tests/tests/api/datasources/test_neutron.py index 01ecf8e36..07cff69b5 100644 --- a/vitrage_tempest_tests/tests/api/datasources/test_neutron.py +++ b/vitrage_tempest_tests/tests/api/datasources/test_neutron.py @@ -11,6 +11,7 @@ # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations # under the License. +import traceback from oslo_log import log as logging @@ -61,8 +62,8 @@ class TestNeutron(BaseTopologyTest): num_entities, num_edges, entities) - except Exception as e: - LOG.exception(e) + except Exception: + traceback.print_exc() raise finally: self._delete_instances() diff --git a/vitrage_tempest_tests/tests/api/datasources/test_nova.py b/vitrage_tempest_tests/tests/api/datasources/test_nova.py index ab3cf68e4..c5be18be1 100644 --- a/vitrage_tempest_tests/tests/api/datasources/test_nova.py +++ b/vitrage_tempest_tests/tests/api/datasources/test_nova.py @@ -11,6 +11,7 @@ # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations # under the License. +import traceback from oslo_log import log as logging from vitrage_tempest_tests.tests.api.topology.base import BaseTopologyTest @@ -49,8 +50,8 @@ class TestNova(BaseTopologyTest): num_entities, num_edges, entities) - except Exception as e: - LOG.exception(e) + except Exception: + traceback.print_exc() raise finally: self._rollback_to_default() diff --git a/vitrage_tempest_tests/tests/api/datasources/test_static_physical.py b/vitrage_tempest_tests/tests/api/datasources/test_static_physical.py index 1d993b45f..81028ef33 100644 --- a/vitrage_tempest_tests/tests/api/datasources/test_static_physical.py +++ b/vitrage_tempest_tests/tests/api/datasources/test_static_physical.py @@ -15,6 +15,7 @@ import os import socket import time +import traceback from oslo_log import log as logging from vitrage_tempest_tests.tests.api.base import BaseApiTest @@ -53,8 +54,8 @@ class TestStaticPhysical(BaseApiTest): num_entities, num_edges, entities) - except Exception as e: - LOG.exception(e) + except Exception: + traceback.print_exc() raise finally: self._delete_switches() diff --git a/vitrage_tempest_tests/tests/api/rca/base.py b/vitrage_tempest_tests/tests/api/rca/base.py index 49413b61c..bba743804 100644 --- a/vitrage_tempest_tests/tests/api/rca/base.py +++ b/vitrage_tempest_tests/tests/api/rca/base.py @@ -60,9 +60,8 @@ class BaseRcaTest(BaseAlarmsTest): self.assertNotEqual(len(api_rca), 0, 'The rca taken from api is empty') self.assertIsNotNone(cli_rca, 'The rca taken from cli is empty') - LOG.debug("The rca taken from cli is : %s", cli_rca) - LOG.debug("The rca taken by api is : %s", - json.dumps(api_rca)) + print("The rca taken from cli is : " + str(cli_rca)) + print("The rca taken by api is : " + str(json.dumps(api_rca))) parsed_rca = json.loads(cli_rca) sorted_cli_graph = self._clean_timestamps(sorted(parsed_rca.items())) @@ -71,8 +70,7 @@ class BaseRcaTest(BaseAlarmsTest): def _validate_rca(self, rca): self.assertNotEqual(len(rca), 0, 'The rca is empty') - LOG.debug("The rca alarms list is : %s", - json.dumps(rca)) + print("The rca alarms list is : " + str(json.dumps(rca))) resource_alarm = self._filter_list_by_pairs_parameters( rca, [VProps.TYPE, VProps.NAME], @@ -90,8 +88,7 @@ class BaseRcaTest(BaseAlarmsTest): def _validate_deduce_alarms(self, alarms, instances): """Validate alarm existence """ self.assertNotEqual(len(alarms), 0, 'The alarms list is empty') - LOG.debug("The alarms list is : %s", - json.dumps(alarms)) + print("The alarms list is : " + str(json.dumps(alarms))) deduce_alarms_1 = self._filter_list_by_pairs_parameters( alarms, diff --git a/vitrage_tempest_tests/tests/api/rca/test_rca.py b/vitrage_tempest_tests/tests/api/rca/test_rca.py index 1f959056e..363d9e934 100644 --- a/vitrage_tempest_tests/tests/api/rca/test_rca.py +++ b/vitrage_tempest_tests/tests/api/rca/test_rca.py @@ -11,6 +11,7 @@ # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations # under the License. +import traceback from oslo_log import log as logging @@ -50,8 +51,8 @@ class TestRca(BaseRcaTest): 'vitrage rca show ' + vitrage_id, self.conf) self._compare_rca(api_rca, cli_rca) - except Exception as e: - LOG.exception(e) + except Exception: + traceback.print_exc() raise finally: self._clean_all() @@ -78,8 +79,8 @@ class TestRca(BaseRcaTest): self._validate_rca(rca=api_rca['nodes']) self._validate_relationship(links=api_rca['links'], alarms=api_rca['nodes']) - except Exception as e: - LOG.exception(e) + except Exception: + traceback.print_exc() raise finally: self._clean_all() @@ -100,8 +101,8 @@ class TestRca(BaseRcaTest): self._validate_deduce_alarms(alarms=api_alarms, instances=instances) - except Exception as e: - LOG.exception(e) + except Exception: + traceback.print_exc() raise finally: self._clean_all() @@ -123,8 +124,8 @@ class TestRca(BaseRcaTest): self._validate_set_state(topology=topology['nodes'], instances=instances) - except Exception as e: - LOG.exception(e) + except Exception: + traceback.print_exc() raise finally: self._clean_all() @@ -147,8 +148,8 @@ class TestRca(BaseRcaTest): self._validate_notifier(alarms=ceilometer_alarms, vitrage_alarms=vitrage_alarms) - except Exception as e: - LOG.exception(e) + except Exception: + traceback.print_exc() raise finally: self._clean_all() diff --git a/vitrage_tempest_tests/tests/api/templates/base.py b/vitrage_tempest_tests/tests/api/templates/base.py index 982ea6411..97f4c3bf4 100644 --- a/vitrage_tempest_tests/tests/api/templates/base.py +++ b/vitrage_tempest_tests/tests/api/templates/base.py @@ -48,9 +48,10 @@ class BaseTemplateTest(BaseApiTest): self.assertIsNotNone(cli_templates, 'The template list taken from cli is empty') - LOG.debug("The template list taken from cli is : %s", cli_templates) - LOG.debug("The template list taken by api is : %s", - json.dumps(api_templates)) + print("The template list taken from cli is : " + + str(cli_templates)) + print("The template list taken by api is : " + + str(json.dumps(api_templates))) self._validate_templates_list_length(api_templates, cli_templates) self._validate_passed_templates_length(api_templates, cli_templates) @@ -63,10 +64,10 @@ class BaseTemplateTest(BaseApiTest): self.assertIsNotNone( cli_templates, 'The template validations taken from cli is empty') - LOG.debug("The template validations taken from cli is : %s", - cli_templates) - LOG.debug("The template validations taken by api is : %s", - json.dumps(api_templates)) + print("The template validations taken from cli is : " + + str(cli_templates)) + print("The template validations taken by api is : " + + str(json.dumps(api_templates))) parsed_topology = json.loads(cli_templates) sorted_cli_templates = sorted(parsed_topology.items()) @@ -133,10 +134,10 @@ class BaseTemplateTest(BaseApiTest): self.assertIsNotNone( cli_templates, 'The template validations taken from cli is empty') - LOG.debug("The template validations taken from cli is : %s", - cli_templates) - LOG.debug("The template validations taken by api is : %s", - json.dumps(api_templates)) + print("The template validations taken from cli is : " + + str(cli_templates)) + print("The template validations taken by api is : " + + str(json.dumps(api_templates))) parsed_topology = json.loads(cli_templates) sorted_cli_templates = sorted(parsed_topology.items()) diff --git a/vitrage_tempest_tests/tests/api/templates/test_template.py b/vitrage_tempest_tests/tests/api/templates/test_template.py index f5a6d1456..286e21b80 100644 --- a/vitrage_tempest_tests/tests/api/templates/test_template.py +++ b/vitrage_tempest_tests/tests/api/templates/test_template.py @@ -94,7 +94,7 @@ class TestValidate(BaseTemplateTest): self._run_template_validation( validation['results'][0], path, negative=True) except Exception: - LOG.error('Failed to get validation of corrupted template file') + print('Failed to get validation of corrupted template file') def test_templates_validate_correct_template(self): """templates_validate test @@ -108,7 +108,7 @@ class TestValidate(BaseTemplateTest): self._run_template_validation( validation['results'][0], path) except Exception: - LOG.error('Failed to get validation of template file') + print('Failed to get validation of template file') def test_compare_template_show(self): """templates_show test diff --git a/vitrage_tempest_tests/tests/api/topology/test_topology.py b/vitrage_tempest_tests/tests/api/topology/test_topology.py index c144eac2f..789007a3d 100644 --- a/vitrage_tempest_tests/tests/api/topology/test_topology.py +++ b/vitrage_tempest_tests/tests/api/topology/test_topology.py @@ -11,6 +11,7 @@ # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations # under the License. +import traceback from oslo_log import log as logging @@ -83,8 +84,8 @@ class TestTopology(BaseTopologyTest): num_entities, num_edges, entities) - except Exception as e: - LOG.exception(e) + except Exception: + traceback.print_exc() raise finally: self._rollback_to_default() @@ -118,8 +119,8 @@ class TestTopology(BaseTopologyTest): num_entities, num_edges, entities) - except Exception as e: - LOG.exception(e) + except Exception: + traceback.print_exc() raise finally: self._rollback_to_default() @@ -151,8 +152,8 @@ class TestTopology(BaseTopologyTest): num_entities, num_edges, entities) - except Exception as e: - LOG.exception(e) + except Exception: + traceback.print_exc() raise finally: self._rollback_to_default() @@ -179,8 +180,8 @@ class TestTopology(BaseTopologyTest): self.num_default_entities, self.num_default_edges, entities) - except Exception as e: - LOG.exception(e) + except Exception: + traceback.print_exc() raise finally: self._rollback_to_default() @@ -207,8 +208,8 @@ class TestTopology(BaseTopologyTest): self.num_default_entities, self.num_default_edges, entities) - except Exception as e: - LOG.exception(e) + except Exception: + traceback.print_exc() raise finally: self._rollback_to_default() @@ -240,8 +241,8 @@ class TestTopology(BaseTopologyTest): num_entities, num_edges, entities) - except Exception as e: - LOG.exception(e) + except Exception: + traceback.print_exc() raise finally: self._rollback_to_default() @@ -271,8 +272,8 @@ class TestTopology(BaseTopologyTest): self.num_default_entities, self.num_default_edges, entities) - except Exception as e: - LOG.exception(e) + except Exception: + traceback.print_exc() raise finally: self._rollback_to_default() @@ -307,8 +308,8 @@ class TestTopology(BaseTopologyTest): num_entities, num_edges, entities) - except Exception as e: - LOG.exception(e) + except Exception: + traceback.print_exc() raise finally: self._rollback_to_default() @@ -360,8 +361,8 @@ class TestTopology(BaseTopologyTest): self.assertEqual( 0, len(api_graph['links']), 'num of edges') - except Exception as e: - LOG.exception(e) + except Exception: + traceback.print_exc() raise finally: self._rollback_to_default() @@ -384,8 +385,8 @@ class TestTopology(BaseTopologyTest): # Test Assertions self.assertEqual({}, api_graph) - except Exception as e: - LOG.exception(e) + except Exception: + traceback.print_exc() raise finally: self._rollback_to_default()