fix tempests in gate

Change-Id: Ic14e9523c841b94c4cc7aeab2ec89d8f86ba102c
This commit is contained in:
Alexey Weyl 2017-01-24 13:42:04 +00:00
parent c771ad1a1b
commit 3fc88cbddf
15 changed files with 103 additions and 76 deletions

View File

@ -100,7 +100,8 @@ class ConsistencyEnforcer(object):
'and': [ 'and': [
{'!=': {VProps.TYPE: VITRAGE_TYPE}}, {'!=': {VProps.TYPE: VITRAGE_TYPE}},
{'<': {VProps.SAMPLE_TIMESTAMP: str(utcnow() - timedelta( {'<': {VProps.SAMPLE_TIMESTAMP: str(utcnow() - timedelta(
seconds=2 * self.conf.datasources.snapshots_interval))}} seconds=2 * self.conf.datasources.snapshots_interval))}},
{'==': {VProps.IS_DELETED: False}}
] ]
} }

View File

@ -70,7 +70,7 @@ def nova_client(conf):
version=conf.nova_version, version=conf.nova_version,
session=keystone_client.get_session(conf), session=keystone_client.get_session(conf),
region_name=auth_config.region_name, region_name=auth_config.region_name,
interface=auth_config.interface, endpoint_type='publicURL',
) )
LOG.info('Nova client created') LOG.info('Nova client created')
return client return client

View File

@ -13,6 +13,7 @@
# under the License. # under the License.
import json import json
import traceback
from oslo_log import log as logging from oslo_log import log as logging
@ -46,8 +47,8 @@ class TestAlarms(BaseAlarmsTest):
self._compare_alarms_lists( self._compare_alarms_lists(
api_alarms, cli_alarms, AODH_DATASOURCE, api_alarms, cli_alarms, AODH_DATASOURCE,
utils.uni2str(instances[0].id)) utils.uni2str(instances[0].id))
except Exception as e: except Exception:
LOG.exception(e) traceback.print_exc()
raise raise
finally: finally:
self._delete_ceilometer_alarms() self._delete_ceilometer_alarms()
@ -61,9 +62,10 @@ class TestAlarms(BaseAlarmsTest):
self.assertIsNotNone(cli_alarms, self.assertIsNotNone(cli_alarms,
'The alarms list taken from cli is empty') 'The alarms list taken from cli is empty')
LOG.debug("The alarms list taken from cli is : %s", cli_alarms) print("The alarms list taken from cli is : " +
LOG.debug("The alarms list taken by api is : %s", str(cli_alarms))
json.dumps(api_alarms)) print("The alarms list taken by api is : " +
str(json.dumps(api_alarms)))
cli_items = cli_alarms.splitlines() cli_items = cli_alarms.splitlines()

View File

@ -55,10 +55,12 @@ class BaseApiTest(base.BaseTestCase):
cls.vitrage_client = \ cls.vitrage_client = \
v_client.Client('1', session=keystone_client.get_session(cls.conf)) v_client.Client('1', session=keystone_client.get_session(cls.conf))
cls.nova_client = os_clients.nova_client(cls.conf) cls.nova_client = cls._create_client(os_clients.nova_client, cls.conf)
cls.cinder_client = os_clients.cinder_client(cls.conf) cls.cinder_client = cls._create_client(os_clients.cinder_client,
cls.neutron_client = os_clients.neutron_client(cls.conf) cls.conf)
cls.heat_client = os_clients.heat_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 = \ cls.num_default_networks = \
len(cls.neutron_client.list_networks()['networks']) len(cls.neutron_client.list_networks()['networks'])
@ -67,6 +69,22 @@ class BaseApiTest(base.BaseTestCase):
cls.num_default_entities = 3 cls.num_default_entities = 3
cls.num_default_edges = 2 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 @staticmethod
def _filter_list_by_pairs_parameters(origin_list, def _filter_list_by_pairs_parameters(origin_list,
keys, values): keys, values):
@ -222,7 +240,7 @@ class BaseApiTest(base.BaseTestCase):
return True return True
count += 1 count += 1
time.sleep(2) time.sleep(2)
LOG.info("wait_for_status - False") print("wait_for_status - False")
return False return False
def _entities_validation_data(self, **kwargs): def _entities_validation_data(self, **kwargs):

View File

@ -11,6 +11,7 @@
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
import traceback
from oslo_log import log as logging from oslo_log import log as logging
@ -54,8 +55,8 @@ class TestAodhAlarm(BaseAlarmsTest):
num_entities, num_entities,
num_edges, num_edges,
entities) entities)
except Exception as e: except Exception:
LOG.exception(e) traceback.print_exc()
raise raise
finally: finally:
self._delete_ceilometer_alarms() self._delete_ceilometer_alarms()
@ -83,8 +84,8 @@ class TestAodhAlarm(BaseAlarmsTest):
num_entities, num_entities,
num_edges, num_edges,
entities) entities)
except Exception as e: except Exception:
LOG.exception(e) traceback.print_exc()
raise raise
finally: finally:
self._delete_ceilometer_alarms() self._delete_ceilometer_alarms()

View File

@ -11,6 +11,7 @@
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
import traceback
from oslo_log import log as logging from oslo_log import log as logging
from vitrage_tempest_tests.tests.api.topology.base import BaseTopologyTest from vitrage_tempest_tests.tests.api.topology.base import BaseTopologyTest
@ -53,8 +54,8 @@ class TestCinderVolume(BaseTopologyTest):
num_entities, num_entities,
num_edges, num_edges,
entities) entities)
except Exception as e: except Exception:
LOG.exception(e) traceback.print_exc()
raise raise
finally: finally:
self._rollback_to_default() self._rollback_to_default()

View File

@ -13,6 +13,7 @@
# under the License. # under the License.
import time import time
import traceback
from oslo_log import log as logging from oslo_log import log as logging
@ -62,8 +63,8 @@ class TestHeatStack(BaseTopologyTest):
num_entities, num_entities,
num_edges, num_edges,
entities) entities)
except Exception as e: except Exception:
LOG.exception(e) traceback.print_exc()
raise raise
finally: finally:
self._delete_stacks() self._delete_stacks()

View File

@ -11,6 +11,7 @@
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
import traceback
from oslo_log import log as logging from oslo_log import log as logging
@ -61,8 +62,8 @@ class TestNeutron(BaseTopologyTest):
num_entities, num_entities,
num_edges, num_edges,
entities) entities)
except Exception as e: except Exception:
LOG.exception(e) traceback.print_exc()
raise raise
finally: finally:
self._delete_instances() self._delete_instances()

View File

@ -11,6 +11,7 @@
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
import traceback
from oslo_log import log as logging from oslo_log import log as logging
from vitrage_tempest_tests.tests.api.topology.base import BaseTopologyTest from vitrage_tempest_tests.tests.api.topology.base import BaseTopologyTest
@ -49,8 +50,8 @@ class TestNova(BaseTopologyTest):
num_entities, num_entities,
num_edges, num_edges,
entities) entities)
except Exception as e: except Exception:
LOG.exception(e) traceback.print_exc()
raise raise
finally: finally:
self._rollback_to_default() self._rollback_to_default()

View File

@ -15,6 +15,7 @@
import os import os
import socket import socket
import time import time
import traceback
from oslo_log import log as logging from oslo_log import log as logging
from vitrage_tempest_tests.tests.api.base import BaseApiTest from vitrage_tempest_tests.tests.api.base import BaseApiTest
@ -53,8 +54,8 @@ class TestStaticPhysical(BaseApiTest):
num_entities, num_entities,
num_edges, num_edges,
entities) entities)
except Exception as e: except Exception:
LOG.exception(e) traceback.print_exc()
raise raise
finally: finally:
self._delete_switches() self._delete_switches()

View File

@ -60,9 +60,8 @@ class BaseRcaTest(BaseAlarmsTest):
self.assertNotEqual(len(api_rca), 0, 'The rca taken from api is empty') self.assertNotEqual(len(api_rca), 0, 'The rca taken from api is empty')
self.assertIsNotNone(cli_rca, 'The rca taken from cli is empty') self.assertIsNotNone(cli_rca, 'The rca taken from cli is empty')
LOG.debug("The rca taken from cli is : %s", cli_rca) print("The rca taken from cli is : " + str(cli_rca))
LOG.debug("The rca taken by api is : %s", print("The rca taken by api is : " + str(json.dumps(api_rca)))
json.dumps(api_rca))
parsed_rca = json.loads(cli_rca) parsed_rca = json.loads(cli_rca)
sorted_cli_graph = self._clean_timestamps(sorted(parsed_rca.items())) sorted_cli_graph = self._clean_timestamps(sorted(parsed_rca.items()))
@ -71,8 +70,7 @@ class BaseRcaTest(BaseAlarmsTest):
def _validate_rca(self, rca): def _validate_rca(self, rca):
self.assertNotEqual(len(rca), 0, 'The rca is empty') self.assertNotEqual(len(rca), 0, 'The rca is empty')
LOG.debug("The rca alarms list is : %s", print("The rca alarms list is : " + str(json.dumps(rca)))
json.dumps(rca))
resource_alarm = self._filter_list_by_pairs_parameters( resource_alarm = self._filter_list_by_pairs_parameters(
rca, [VProps.TYPE, VProps.NAME], rca, [VProps.TYPE, VProps.NAME],
@ -90,8 +88,7 @@ class BaseRcaTest(BaseAlarmsTest):
def _validate_deduce_alarms(self, alarms, instances): def _validate_deduce_alarms(self, alarms, instances):
"""Validate alarm existence """ """Validate alarm existence """
self.assertNotEqual(len(alarms), 0, 'The alarms list is empty') self.assertNotEqual(len(alarms), 0, 'The alarms list is empty')
LOG.debug("The alarms list is : %s", print("The alarms list is : " + str(json.dumps(alarms)))
json.dumps(alarms))
deduce_alarms_1 = self._filter_list_by_pairs_parameters( deduce_alarms_1 = self._filter_list_by_pairs_parameters(
alarms, alarms,

View File

@ -11,6 +11,7 @@
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
import traceback
from oslo_log import log as logging from oslo_log import log as logging
@ -50,8 +51,8 @@ class TestRca(BaseRcaTest):
'vitrage rca show ' + vitrage_id, self.conf) 'vitrage rca show ' + vitrage_id, self.conf)
self._compare_rca(api_rca, cli_rca) self._compare_rca(api_rca, cli_rca)
except Exception as e: except Exception:
LOG.exception(e) traceback.print_exc()
raise raise
finally: finally:
self._clean_all() self._clean_all()
@ -78,8 +79,8 @@ class TestRca(BaseRcaTest):
self._validate_rca(rca=api_rca['nodes']) self._validate_rca(rca=api_rca['nodes'])
self._validate_relationship(links=api_rca['links'], self._validate_relationship(links=api_rca['links'],
alarms=api_rca['nodes']) alarms=api_rca['nodes'])
except Exception as e: except Exception:
LOG.exception(e) traceback.print_exc()
raise raise
finally: finally:
self._clean_all() self._clean_all()
@ -100,8 +101,8 @@ class TestRca(BaseRcaTest):
self._validate_deduce_alarms(alarms=api_alarms, self._validate_deduce_alarms(alarms=api_alarms,
instances=instances) instances=instances)
except Exception as e: except Exception:
LOG.exception(e) traceback.print_exc()
raise raise
finally: finally:
self._clean_all() self._clean_all()
@ -123,8 +124,8 @@ class TestRca(BaseRcaTest):
self._validate_set_state(topology=topology['nodes'], self._validate_set_state(topology=topology['nodes'],
instances=instances) instances=instances)
except Exception as e: except Exception:
LOG.exception(e) traceback.print_exc()
raise raise
finally: finally:
self._clean_all() self._clean_all()
@ -147,8 +148,8 @@ class TestRca(BaseRcaTest):
self._validate_notifier(alarms=ceilometer_alarms, self._validate_notifier(alarms=ceilometer_alarms,
vitrage_alarms=vitrage_alarms) vitrage_alarms=vitrage_alarms)
except Exception as e: except Exception:
LOG.exception(e) traceback.print_exc()
raise raise
finally: finally:
self._clean_all() self._clean_all()

View File

@ -48,9 +48,10 @@ class BaseTemplateTest(BaseApiTest):
self.assertIsNotNone(cli_templates, self.assertIsNotNone(cli_templates,
'The template list taken from cli is empty') 'The template list taken from cli is empty')
LOG.debug("The template list taken from cli is : %s", cli_templates) print("The template list taken from cli is : " +
LOG.debug("The template list taken by api is : %s", str(cli_templates))
json.dumps(api_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_templates_list_length(api_templates, cli_templates)
self._validate_passed_templates_length(api_templates, cli_templates) self._validate_passed_templates_length(api_templates, cli_templates)
@ -63,10 +64,10 @@ class BaseTemplateTest(BaseApiTest):
self.assertIsNotNone( self.assertIsNotNone(
cli_templates, 'The template validations taken from cli is empty') cli_templates, 'The template validations taken from cli is empty')
LOG.debug("The template validations taken from cli is : %s", print("The template validations taken from cli is : " +
cli_templates) str(cli_templates))
LOG.debug("The template validations taken by api is : %s", print("The template validations taken by api is : " +
json.dumps(api_templates)) str(json.dumps(api_templates)))
parsed_topology = json.loads(cli_templates) parsed_topology = json.loads(cli_templates)
sorted_cli_templates = sorted(parsed_topology.items()) sorted_cli_templates = sorted(parsed_topology.items())
@ -133,10 +134,10 @@ class BaseTemplateTest(BaseApiTest):
self.assertIsNotNone( self.assertIsNotNone(
cli_templates, 'The template validations taken from cli is empty') cli_templates, 'The template validations taken from cli is empty')
LOG.debug("The template validations taken from cli is : %s", print("The template validations taken from cli is : " +
cli_templates) str(cli_templates))
LOG.debug("The template validations taken by api is : %s", print("The template validations taken by api is : " +
json.dumps(api_templates)) str(json.dumps(api_templates)))
parsed_topology = json.loads(cli_templates) parsed_topology = json.loads(cli_templates)
sorted_cli_templates = sorted(parsed_topology.items()) sorted_cli_templates = sorted(parsed_topology.items())

View File

@ -94,7 +94,7 @@ class TestValidate(BaseTemplateTest):
self._run_template_validation( self._run_template_validation(
validation['results'][0], path, negative=True) validation['results'][0], path, negative=True)
except Exception: 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): def test_templates_validate_correct_template(self):
"""templates_validate test """templates_validate test
@ -108,7 +108,7 @@ class TestValidate(BaseTemplateTest):
self._run_template_validation( self._run_template_validation(
validation['results'][0], path) validation['results'][0], path)
except Exception: 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): def test_compare_template_show(self):
"""templates_show test """templates_show test

View File

@ -11,6 +11,7 @@
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
import traceback
from oslo_log import log as logging from oslo_log import log as logging
@ -83,8 +84,8 @@ class TestTopology(BaseTopologyTest):
num_entities, num_entities,
num_edges, num_edges,
entities) entities)
except Exception as e: except Exception:
LOG.exception(e) traceback.print_exc()
raise raise
finally: finally:
self._rollback_to_default() self._rollback_to_default()
@ -118,8 +119,8 @@ class TestTopology(BaseTopologyTest):
num_entities, num_entities,
num_edges, num_edges,
entities) entities)
except Exception as e: except Exception:
LOG.exception(e) traceback.print_exc()
raise raise
finally: finally:
self._rollback_to_default() self._rollback_to_default()
@ -151,8 +152,8 @@ class TestTopology(BaseTopologyTest):
num_entities, num_entities,
num_edges, num_edges,
entities) entities)
except Exception as e: except Exception:
LOG.exception(e) traceback.print_exc()
raise raise
finally: finally:
self._rollback_to_default() self._rollback_to_default()
@ -179,8 +180,8 @@ class TestTopology(BaseTopologyTest):
self.num_default_entities, self.num_default_entities,
self.num_default_edges, self.num_default_edges,
entities) entities)
except Exception as e: except Exception:
LOG.exception(e) traceback.print_exc()
raise raise
finally: finally:
self._rollback_to_default() self._rollback_to_default()
@ -207,8 +208,8 @@ class TestTopology(BaseTopologyTest):
self.num_default_entities, self.num_default_entities,
self.num_default_edges, self.num_default_edges,
entities) entities)
except Exception as e: except Exception:
LOG.exception(e) traceback.print_exc()
raise raise
finally: finally:
self._rollback_to_default() self._rollback_to_default()
@ -240,8 +241,8 @@ class TestTopology(BaseTopologyTest):
num_entities, num_entities,
num_edges, num_edges,
entities) entities)
except Exception as e: except Exception:
LOG.exception(e) traceback.print_exc()
raise raise
finally: finally:
self._rollback_to_default() self._rollback_to_default()
@ -271,8 +272,8 @@ class TestTopology(BaseTopologyTest):
self.num_default_entities, self.num_default_entities,
self.num_default_edges, self.num_default_edges,
entities) entities)
except Exception as e: except Exception:
LOG.exception(e) traceback.print_exc()
raise raise
finally: finally:
self._rollback_to_default() self._rollback_to_default()
@ -307,8 +308,8 @@ class TestTopology(BaseTopologyTest):
num_entities, num_entities,
num_edges, num_edges,
entities) entities)
except Exception as e: except Exception:
LOG.exception(e) traceback.print_exc()
raise raise
finally: finally:
self._rollback_to_default() self._rollback_to_default()
@ -360,8 +361,8 @@ class TestTopology(BaseTopologyTest):
self.assertEqual( self.assertEqual(
0, 0,
len(api_graph['links']), 'num of edges') len(api_graph['links']), 'num of edges')
except Exception as e: except Exception:
LOG.exception(e) traceback.print_exc()
raise raise
finally: finally:
self._rollback_to_default() self._rollback_to_default()
@ -384,8 +385,8 @@ class TestTopology(BaseTopologyTest):
# Test Assertions # Test Assertions
self.assertEqual({}, api_graph) self.assertEqual({}, api_graph)
except Exception as e: except Exception:
LOG.exception(e) traceback.print_exc()
raise raise
finally: finally:
self._rollback_to_default() self._rollback_to_default()