Merge "more tempests changes"

This commit is contained in:
Jenkins 2017-01-25 08:30:53 +00:00 committed by Gerrit Code Review
commit 41e8a95943
14 changed files with 118 additions and 46 deletions

View File

@ -32,6 +32,7 @@ class TestAlarms(BaseAlarmsTest):
def setUpClass(cls):
super(TestAlarms, cls).setUpClass()
@utils.tempest_logger
def test_compare_cli_vs_api_alarms(self):
"""Wrapper that returns a test graph."""
try:
@ -47,7 +48,8 @@ class TestAlarms(BaseAlarmsTest):
self._compare_alarms_lists(
api_alarms, cli_alarms, AODH_DATASOURCE,
utils.uni2str(instances[0].id))
except Exception:
except Exception as e:
LOG.exception(e)
traceback.print_exc()
raise
finally:
@ -62,10 +64,10 @@ class TestAlarms(BaseAlarmsTest):
self.assertIsNotNone(cli_alarms,
'The alarms list taken from cli is empty')
print("The alarms list taken from cli is : " +
str(cli_alarms))
print("The alarms list taken by api is : " +
str(json.dumps(api_alarms)))
LOG.info("The alarms list taken from cli is : " +
str(cli_alarms))
LOG.info("The alarms list taken by api is : " +
str(json.dumps(api_alarms)))
cli_items = cli_alarms.splitlines()

View File

@ -240,7 +240,7 @@ class BaseApiTest(base.BaseTestCase):
return True
count += 1
time.sleep(2)
print("wait_for_status - False")
LOG.info("wait_for_status - False")
return False
def _entities_validation_data(self, **kwargs):

View File

@ -11,9 +11,11 @@
# 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 import utils
from vitrage_tempest_tests.tests.api.alarms.base import BaseAlarmsTest
@ -28,6 +30,7 @@ class TestAodhAlarm(BaseAlarmsTest):
def setUpClass(cls):
super(TestAodhAlarm, cls).setUpClass()
@utils.tempest_logger
def test_alarm_with_resource_id(self):
try:
# Action
@ -55,13 +58,15 @@ class TestAodhAlarm(BaseAlarmsTest):
num_entities,
num_edges,
entities)
except Exception:
except Exception as e:
traceback.print_exc()
LOG.exception(e)
raise
finally:
self._delete_ceilometer_alarms()
self._delete_instances()
@utils.tempest_logger
def test_alarm_without_resource_id(self):
try:
# Action
@ -84,8 +89,9 @@ class TestAodhAlarm(BaseAlarmsTest):
num_entities,
num_edges,
entities)
except Exception:
except Exception as e:
traceback.print_exc()
LOG.exception(e)
raise
finally:
self._delete_ceilometer_alarms()

View File

@ -11,10 +11,12 @@
# 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
from vitrage_tempest_tests.tests import utils
LOG = logging.getLogger(__name__)
@ -27,6 +29,7 @@ class TestCinderVolume(BaseTopologyTest):
def setUpClass(cls):
super(TestCinderVolume, cls).setUpClass()
@utils.tempest_logger
def test_volume(self):
try:
# Action
@ -54,8 +57,9 @@ class TestCinderVolume(BaseTopologyTest):
num_entities,
num_edges,
entities)
except Exception:
except Exception as e:
traceback.print_exc()
LOG.exception(e)
raise
finally:
self._rollback_to_default()

View File

@ -16,6 +16,7 @@ import time
import traceback
from oslo_log import log as logging
from vitrage_tempest_tests.tests import utils
from vitrage_tempest_tests.tests.api.topology.base import BaseTopologyTest
@ -29,6 +30,7 @@ class TestHeatStack(BaseTopologyTest):
def setUpClass(cls):
super(TestHeatStack, cls).setUpClass()
@utils.tempest_logger
def test_heat_stack(self):
"""heat stack test
@ -63,8 +65,9 @@ class TestHeatStack(BaseTopologyTest):
num_entities,
num_edges,
entities)
except Exception:
except Exception as e:
traceback.print_exc()
LOG.exception(e)
raise
finally:
self._delete_stacks()

View File

@ -11,12 +11,14 @@
# 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.common.constants import VertexProperties as VProps
from vitrage_tempest_tests.tests.api.topology.base import BaseTopologyTest
from vitrage_tempest_tests.tests import utils
LOG = logging.getLogger(__name__)
@ -28,6 +30,7 @@ class TestNeutron(BaseTopologyTest):
def setUpClass(cls):
super(TestNeutron, cls).setUpClass()
@utils.tempest_logger
def test_neutron(self):
"""neutron test
@ -62,8 +65,9 @@ class TestNeutron(BaseTopologyTest):
num_entities,
num_edges,
entities)
except Exception:
except Exception as e:
traceback.print_exc()
LOG.exception(e)
raise
finally:
self._delete_instances()

View File

@ -11,10 +11,12 @@
# 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
from vitrage_tempest_tests.tests import utils
LOG = logging.getLogger(__name__)
@ -26,6 +28,7 @@ class TestNova(BaseTopologyTest):
def setUpClass(cls):
super(TestNova, cls).setUpClass()
@utils.tempest_logger
def test_nova_entities(self):
try:
# Action
@ -50,8 +53,9 @@ class TestNova(BaseTopologyTest):
num_entities,
num_edges,
entities)
except Exception:
except Exception as e:
traceback.print_exc()
LOG.exception(e)
raise
finally:
self._rollback_to_default()

View File

@ -19,6 +19,7 @@ import traceback
from oslo_log import log as logging
from vitrage_tempest_tests.tests.api.base import BaseApiTest
from vitrage_tempest_tests.tests import utils
LOG = logging.getLogger(__name__)
@ -31,6 +32,7 @@ class TestStaticPhysical(BaseApiTest):
def setUpClass(cls):
super(TestStaticPhysical, cls).setUpClass()
@utils.tempest_logger
def test_switches(self):
try:
# Action
@ -54,8 +56,9 @@ class TestStaticPhysical(BaseApiTest):
num_entities,
num_edges,
entities)
except Exception:
except Exception as e:
traceback.print_exc()
LOG.exception(e)
raise
finally:
self._delete_switches()

View File

@ -60,8 +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')
print("The rca taken from cli is : " + str(cli_rca))
print("The rca taken by api is : " + str(json.dumps(api_rca)))
LOG.info("The rca taken from cli is : " + str(cli_rca))
LOG.info("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()))
@ -70,7 +70,7 @@ class BaseRcaTest(BaseAlarmsTest):
def _validate_rca(self, rca):
self.assertNotEqual(len(rca), 0, 'The rca is empty')
print("The rca alarms list is : " + str(json.dumps(rca)))
LOG.info("The rca alarms list is : " + str(json.dumps(rca)))
resource_alarm = self._filter_list_by_pairs_parameters(
rca, [VProps.TYPE, VProps.NAME],
@ -88,7 +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')
print("The alarms list is : " + str(json.dumps(alarms)))
LOG.info("The alarms list is : " + str(json.dumps(alarms)))
deduce_alarms_1 = self._filter_list_by_pairs_parameters(
alarms,

View File

@ -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
@ -30,6 +31,7 @@ class TestRca(BaseRcaTest):
def setUpClass(cls):
super(TestRca, cls).setUpClass()
@utils.tempest_logger
def test_compare_cil_and_api(self):
"""compare_cil_and_api test
@ -51,12 +53,14 @@ class TestRca(BaseRcaTest):
'vitrage rca show ' + vitrage_id, self.conf)
self._compare_rca(api_rca, cli_rca)
except Exception:
except Exception as e:
traceback.print_exc()
LOG.exception(e)
raise
finally:
self._clean_all()
@utils.tempest_logger
def test_validate_rca(self):
"""validate_rca test
@ -79,12 +83,14 @@ class TestRca(BaseRcaTest):
self._validate_rca(rca=api_rca['nodes'])
self._validate_relationship(links=api_rca['links'],
alarms=api_rca['nodes'])
except Exception:
except Exception as e:
traceback.print_exc()
LOG.exception(e)
raise
finally:
self._clean_all()
@utils.tempest_logger
def test_validate_deduce_alarms(self):
"""validate_deduce_alarms test
@ -101,12 +107,14 @@ class TestRca(BaseRcaTest):
self._validate_deduce_alarms(alarms=api_alarms,
instances=instances)
except Exception:
except Exception as e:
traceback.print_exc()
LOG.exception(e)
raise
finally:
self._clean_all()
@utils.tempest_logger
def test_validate_set_state(self):
"""validate_set_state test
@ -124,12 +132,14 @@ class TestRca(BaseRcaTest):
self._validate_set_state(topology=topology['nodes'],
instances=instances)
except Exception:
except Exception as e:
traceback.print_exc()
LOG.exception(e)
raise
finally:
self._clean_all()
@utils.tempest_logger
def test_validate_notifier(self):
"""validate_notifier test
@ -148,8 +158,9 @@ class TestRca(BaseRcaTest):
self._validate_notifier(alarms=ceilometer_alarms,
vitrage_alarms=vitrage_alarms)
except Exception:
except Exception as e:
traceback.print_exc()
LOG.exception(e)
raise
finally:
self._clean_all()

View File

@ -48,10 +48,10 @@ class BaseTemplateTest(BaseApiTest):
self.assertIsNotNone(cli_templates,
'The template list taken from cli is empty')
print("The template list taken from cli is : " +
str(cli_templates))
print("The template list taken by api is : " +
str(json.dumps(api_templates)))
LOG.info("The template list taken from cli is : " +
str(cli_templates))
LOG.info("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)
@ -64,10 +64,10 @@ class BaseTemplateTest(BaseApiTest):
self.assertIsNotNone(
cli_templates, 'The template validations taken from cli is empty')
print("The template validations taken from cli is : " +
str(cli_templates))
print("The template validations taken by api is : " +
str(json.dumps(api_templates)))
LOG.info("The template validations taken from cli is : " +
str(cli_templates))
LOG.info("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())
@ -134,10 +134,10 @@ class BaseTemplateTest(BaseApiTest):
self.assertIsNotNone(
cli_templates, 'The template validations taken from cli is empty')
print("The template validations taken from cli is : " +
str(cli_templates))
print("The template validations taken by api is : " +
str(json.dumps(api_templates)))
LOG.info("The template validations taken from cli is : " +
str(cli_templates))
LOG.info("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())

View File

@ -94,7 +94,7 @@ class TestValidate(BaseTemplateTest):
self._run_template_validation(
validation['results'][0], path, negative=True)
except Exception:
print('Failed to get validation of corrupted template file')
LOG.error('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:
print('Failed to get validation of template file')
LOG.error('Failed to get validation of template file')
def test_compare_template_show(self):
"""templates_show test

View File

@ -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
@ -42,6 +43,7 @@ class TestTopology(BaseTopologyTest):
def setUpClass(cls):
super(TestTopology, cls).setUpClass()
@utils.tempest_logger
def test_compare_api_and_cli(self):
"""compare_api_and_cli
@ -53,6 +55,7 @@ class TestTopology(BaseTopologyTest):
self.conf)
self._compare_graphs(api_graph, cli_graph)
@utils.tempest_logger
def test_default_graph(self):
"""default_graph
@ -84,12 +87,14 @@ class TestTopology(BaseTopologyTest):
num_entities,
num_edges,
entities)
except Exception:
except Exception as e:
traceback.print_exc()
LOG.exception(e)
raise
finally:
self._rollback_to_default()
@utils.tempest_logger
def test_graph_with_query(self):
"""graph_with_query
@ -119,12 +124,14 @@ class TestTopology(BaseTopologyTest):
num_entities,
num_edges,
entities)
except Exception:
except Exception as e:
traceback.print_exc()
LOG.exception(e)
raise
finally:
self._rollback_to_default()
@utils.tempest_logger
def test_nova_tree(self):
"""nova_tree
@ -152,12 +159,14 @@ class TestTopology(BaseTopologyTest):
num_entities,
num_edges,
entities)
except Exception:
except Exception as e:
traceback.print_exc()
LOG.exception(e)
raise
finally:
self._rollback_to_default()
@utils.tempest_logger
def test_tree_with_query(self):
"""tree_with_query
@ -180,12 +189,14 @@ class TestTopology(BaseTopologyTest):
self.num_default_entities,
self.num_default_edges,
entities)
except Exception:
except Exception as e:
traceback.print_exc()
LOG.exception(e)
raise
finally:
self._rollback_to_default()
@utils.tempest_logger
def test_tree_with_depth_exclude_instance(self):
"""tree_with_query
@ -208,12 +219,14 @@ class TestTopology(BaseTopologyTest):
self.num_default_entities,
self.num_default_edges,
entities)
except Exception:
except Exception as e:
traceback.print_exc()
LOG.exception(e)
raise
finally:
self._rollback_to_default()
@utils.tempest_logger
def test_tree_with_depth_include_instance(self):
"""tree_with_query
@ -241,13 +254,15 @@ class TestTopology(BaseTopologyTest):
num_entities,
num_edges,
entities)
except Exception:
except Exception as e:
traceback.print_exc()
LOG.exception(e)
raise
finally:
self._rollback_to_default()
@unittest.skip("testing skipping")
@utils.tempest_logger
def test_graph_with_root_and_depth_exclude_instance(self):
"""tree_with_query
@ -272,13 +287,15 @@ class TestTopology(BaseTopologyTest):
self.num_default_entities,
self.num_default_edges,
entities)
except Exception:
except Exception as e:
traceback.print_exc()
LOG.exception(e)
raise
finally:
self._rollback_to_default()
@unittest.skip("testing skipping")
@utils.tempest_logger
def test_graph_with_root_and_depth_include_instance(self):
"""graph_with_root_and_depth_include_instance
@ -308,12 +325,14 @@ class TestTopology(BaseTopologyTest):
num_entities,
num_edges,
entities)
except Exception:
except Exception as e:
traceback.print_exc()
LOG.exception(e)
raise
finally:
self._rollback_to_default()
@utils.tempest_logger
def test_graph_with_depth_and_no_root(self):
"""graph_with_depth_and_no_root
@ -339,6 +358,7 @@ class TestTopology(BaseTopologyTest):
finally:
self._rollback_to_default()
@utils.tempest_logger
def test_graph_with_no_match_query(self):
"""graph_with_no_match_query
@ -361,12 +381,14 @@ class TestTopology(BaseTopologyTest):
self.assertEqual(
0,
len(api_graph['links']), 'num of edges')
except Exception:
except Exception as e:
traceback.print_exc()
LOG.exception(e)
raise
finally:
self._rollback_to_default()
@utils.tempest_logger
def test_tree_with_no_match_query(self):
"""tree_with_no_match_query
@ -385,8 +407,9 @@ class TestTopology(BaseTopologyTest):
# Test Assertions
self.assertEqual({}, api_graph)
except Exception:
except Exception as e:
traceback.print_exc()
LOG.exception(e)
raise
finally:
self._rollback_to_default()

View File

@ -110,3 +110,15 @@ def get_regex_result(pattern, text):
def uni2str(text):
return text.encode('ascii', 'ignore')
def tempest_logger(func):
func_name = func.func_name
def func_name_print_func(*args, **kwargs):
LOG.info('Test Start: ' + func_name)
result = func(*args, **kwargs)
LOG.info('Test End: ' + func_name)
return result
return func_name_print_func