use the right graph compare
also fix some logging issues Change-Id: I6b857347879ced1054f8cdb75f10a287b219ccb0
This commit is contained in:
parent
f0822c33ef
commit
36fa3966bc
@ -67,8 +67,8 @@ class BaseRcaTest(BaseVitrageTempest):
|
|||||||
'The rca taken from api is empty')
|
'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.info("The rca taken from cli is : " + str(cli_rca))
|
LOG.debug("The rca taken from cli is : %s", cli_rca)
|
||||||
LOG.info("The rca taken by api is : " + str(json.dumps(api_rca)))
|
LOG.debug("The rca taken by api is : %s", 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()))
|
||||||
@ -77,7 +77,7 @@ class BaseRcaTest(BaseVitrageTempest):
|
|||||||
|
|
||||||
def _validate_rca(self, rca):
|
def _validate_rca(self, rca):
|
||||||
self.assertThat(rca, IsNotEmpty, 'The rca is empty')
|
self.assertThat(rca, IsNotEmpty, 'The rca is empty')
|
||||||
LOG.info("The rca alarms list is : " + str(json.dumps(rca)))
|
LOG.debug("The rca alarms list is : %s", rca)
|
||||||
|
|
||||||
resource_alarm = g_utils.all_matches(
|
resource_alarm = g_utils.all_matches(
|
||||||
rca,
|
rca,
|
||||||
@ -97,7 +97,7 @@ class BaseRcaTest(BaseVitrageTempest):
|
|||||||
def _validate_deduce_alarms(self, alarms, instances):
|
def _validate_deduce_alarms(self, alarms, instances):
|
||||||
"""Validate alarm existence """
|
"""Validate alarm existence """
|
||||||
self.assertThat(alarms, IsNotEmpty(), 'The alarms list is empty')
|
self.assertThat(alarms, IsNotEmpty(), 'The alarms list is empty')
|
||||||
LOG.info("The alarms list is : " + str(json.dumps(alarms)))
|
LOG.debug("The alarms list is : %s", alarms)
|
||||||
|
|
||||||
# Find the vitrage_id of the deduced alarms using their original id.
|
# Find the vitrage_id of the deduced alarms using their original id.
|
||||||
vitrage_resources = self.vitrage_client.resource.list(
|
vitrage_resources = self.vitrage_client.resource.list(
|
||||||
|
@ -11,7 +11,6 @@
|
|||||||
# 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 json
|
|
||||||
|
|
||||||
from oslo_log import log as logging
|
from oslo_log import log as logging
|
||||||
from testtools import matchers
|
from testtools import matchers
|
||||||
@ -54,10 +53,8 @@ class BaseTemplateTest(BaseVitrageTempest):
|
|||||||
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.info("The template list taken from cli is : " +
|
LOG.debug("The template list taken from cli is : %s", cli_templates)
|
||||||
str(cli_templates))
|
LOG.debug("The template list taken by api is : %s", api_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_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)
|
||||||
|
@ -12,7 +12,6 @@
|
|||||||
# 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 json
|
|
||||||
import time
|
import time
|
||||||
|
|
||||||
|
|
||||||
@ -20,8 +19,6 @@ from vitrage_tempest_plugin.tests.base import BaseVitrageTempest
|
|||||||
from vitrage_tempest_plugin.tests.base import IsNotEmpty
|
from vitrage_tempest_plugin.tests.base import IsNotEmpty
|
||||||
from vitrage_tempest_plugin.tests.base import LOG
|
from vitrage_tempest_plugin.tests.base import LOG
|
||||||
from vitrage_tempest_plugin.tests.common import cinder_utils
|
from vitrage_tempest_plugin.tests.common import cinder_utils
|
||||||
from vitrage_tempest_plugin.tests.common.constants import VertexProperties as \
|
|
||||||
VProps
|
|
||||||
from vitrage_tempest_plugin.tests.common import nova_utils
|
from vitrage_tempest_plugin.tests.common import nova_utils
|
||||||
|
|
||||||
|
|
||||||
@ -73,32 +70,6 @@ class BaseTopologyTest(BaseVitrageTempest):
|
|||||||
# entity graph processor
|
# entity graph processor
|
||||||
time.sleep(2)
|
time.sleep(2)
|
||||||
|
|
||||||
def _compare_graphs(self, api_graph, cli_graph):
|
|
||||||
"""Compare Graph object to graph form terminal """
|
|
||||||
self.assertThat(api_graph, IsNotEmpty(),
|
|
||||||
'The topology graph taken from rest api is empty')
|
|
||||||
self.assertThat(cli_graph, IsNotEmpty(),
|
|
||||||
'The topology graph taken from terminal is empty')
|
|
||||||
|
|
||||||
parsed_topology = json.loads(cli_graph)
|
|
||||||
|
|
||||||
sorted_cli_graph = sorted(parsed_topology.items())
|
|
||||||
sorted_api_graph = sorted(api_graph.items())
|
|
||||||
|
|
||||||
for item in sorted_cli_graph[4][1]:
|
|
||||||
item.pop(VProps.UPDATE_TIMESTAMP, None)
|
|
||||||
|
|
||||||
for item in sorted_api_graph[4][1]:
|
|
||||||
item.pop(VProps.UPDATE_TIMESTAMP, None)
|
|
||||||
|
|
||||||
for item in sorted_cli_graph[4][1]:
|
|
||||||
item.pop(VProps.VITRAGE_SAMPLE_TIMESTAMP, None)
|
|
||||||
|
|
||||||
for item in sorted_api_graph[4][1]:
|
|
||||||
item.pop(VProps.VITRAGE_SAMPLE_TIMESTAMP, None)
|
|
||||||
|
|
||||||
self.assert_list_equal(sorted_cli_graph, sorted_api_graph)
|
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def _graph_query():
|
def _graph_query():
|
||||||
return '{"and": [{"==": {"vitrage_category": "RESOURCE"}},' \
|
return '{"and": [{"==": {"vitrage_category": "RESOURCE"}},' \
|
||||||
|
@ -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 json
|
||||||
|
|
||||||
from oslo_log import log as logging
|
from oslo_log import log as logging
|
||||||
from testtools import ExpectedException
|
from testtools import ExpectedException
|
||||||
@ -51,10 +52,7 @@ class TestTopology(BaseTopologyTest):
|
|||||||
cli_graph = utils.run_vitrage_command(
|
cli_graph = utils.run_vitrage_command(
|
||||||
'vitrage topology show --all-tenants')
|
'vitrage topology show --all-tenants')
|
||||||
|
|
||||||
LOG.info('api-graph=%(api)s cli-graph=%(cli)s', {'api': api_graph,
|
self._assert_graph_equal(api_graph, json.loads(cli_graph))
|
||||||
'cli': cli_graph})
|
|
||||||
|
|
||||||
self._compare_graphs(api_graph, cli_graph)
|
|
||||||
|
|
||||||
@utils.tempest_logger
|
@utils.tempest_logger
|
||||||
def test_default_graph_all_tenants(self):
|
def test_default_graph_all_tenants(self):
|
||||||
|
@ -169,6 +169,41 @@ class BaseVitrageTempest(test.BaseTestCase):
|
|||||||
|
|
||||||
return graph
|
return graph
|
||||||
|
|
||||||
|
def _assert_graph_equal(self, g1, g2, msg=''):
|
||||||
|
"""Checks that two graphs are equals.
|
||||||
|
|
||||||
|
This relies on assert_dict_equal when comparing the nodes and the
|
||||||
|
edges of each graph.
|
||||||
|
"""
|
||||||
|
g1_nodes = g1['nodes']
|
||||||
|
g1_links = g1['links']
|
||||||
|
|
||||||
|
g2_nodes = g2['nodes']
|
||||||
|
g2_links = g1['links']
|
||||||
|
|
||||||
|
to_remove = {'vitrage_sample_timestamp',
|
||||||
|
'update_timestamp',
|
||||||
|
'graph_index'}
|
||||||
|
|
||||||
|
self._remove_keys_from_dicts(g1_nodes, g2_nodes, to_remove)
|
||||||
|
|
||||||
|
self.assert_items_equal(g1_nodes, g2_nodes,
|
||||||
|
msg + "Nodes of each graph are not equal")
|
||||||
|
self.assert_items_equal(g1_links, g2_links,
|
||||||
|
msg + "Edges of each graph are not equal")
|
||||||
|
|
||||||
|
def _remove_keys_from_dicts(self, dictionaries1,
|
||||||
|
dictionaries2, keys_to_remove):
|
||||||
|
self._delete_keys_from_dict(dictionaries1, keys_to_remove)
|
||||||
|
self._delete_keys_from_dict(dictionaries2, keys_to_remove)
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def _delete_keys_from_dict(dictionaries, keys_to_remove):
|
||||||
|
for dictionary in dictionaries:
|
||||||
|
for key in keys_to_remove:
|
||||||
|
if key in dictionary:
|
||||||
|
del dictionary[key]
|
||||||
|
|
||||||
def _create_graph_from_tree_dictionary(self,
|
def _create_graph_from_tree_dictionary(self,
|
||||||
api_graph,
|
api_graph,
|
||||||
graph=None,
|
graph=None,
|
||||||
|
@ -110,8 +110,8 @@ class TestLongProcessing(TestActionsBase):
|
|||||||
for i in range(5):
|
for i in range(5):
|
||||||
self._check_template_instance_3rd_degree_scenarios()
|
self._check_template_instance_3rd_degree_scenarios()
|
||||||
topo2 = self.vitrage_client.topology.get(all_tenants=True)
|
topo2 = self.vitrage_client.topology.get(all_tenants=True)
|
||||||
self.assert_graph_equal(
|
self._assert_graph_equal(
|
||||||
topo1, topo2, 'comparing graph items iteration ' + str(i))
|
topo1, topo2, 'comparing graph items iteration %s' % i)
|
||||||
time.sleep(CONF.root_cause_analysis_service.snapshots_interval)
|
time.sleep(CONF.root_cause_analysis_service.snapshots_interval)
|
||||||
|
|
||||||
v_utils.delete_template(name=TEMPLATE_NAME)
|
v_utils.delete_template(name=TEMPLATE_NAME)
|
||||||
@ -165,41 +165,6 @@ class TestLongProcessing(TestActionsBase):
|
|||||||
alarm_count['CRITICAL'],
|
alarm_count['CRITICAL'],
|
||||||
'found CRITICAL deduced alarms after template delete')
|
'found CRITICAL deduced alarms after template delete')
|
||||||
|
|
||||||
def assert_graph_equal(self, g1, g2, msg):
|
|
||||||
"""Checks that two graphs are equals.
|
|
||||||
|
|
||||||
This relies on assert_dict_equal when comparing the nodes and the
|
|
||||||
edges of each graph.
|
|
||||||
"""
|
|
||||||
g1_nodes = g1['nodes']
|
|
||||||
g1_links = g1['links']
|
|
||||||
|
|
||||||
g2_nodes = g2['nodes']
|
|
||||||
g2_links = g1['links']
|
|
||||||
|
|
||||||
to_remove = {'vitrage_sample_timestamp',
|
|
||||||
'update_timestamp',
|
|
||||||
'graph_index'}
|
|
||||||
|
|
||||||
self._remove_keys_from_dicts(g1_nodes, g2_nodes, to_remove)
|
|
||||||
|
|
||||||
self.assert_items_equal(g1_nodes, g2_nodes,
|
|
||||||
msg + "Nodes of each graph are not equal")
|
|
||||||
self.assert_items_equal(g1_links, g2_links,
|
|
||||||
"Edges of each graph are not equal")
|
|
||||||
|
|
||||||
def _remove_keys_from_dicts(self, dictionaries1,
|
|
||||||
dictionaries2, keys_to_remove):
|
|
||||||
self._delete_keys_from_dict(dictionaries1, keys_to_remove)
|
|
||||||
self._delete_keys_from_dict(dictionaries2, keys_to_remove)
|
|
||||||
|
|
||||||
@staticmethod
|
|
||||||
def _delete_keys_from_dict(dictionaries, keys_to_remove):
|
|
||||||
for dictionary in dictionaries:
|
|
||||||
for key in keys_to_remove:
|
|
||||||
if key in dictionary:
|
|
||||||
del dictionary[key]
|
|
||||||
|
|
||||||
def _async_doctor_events(self, spacing=1):
|
def _async_doctor_events(self, spacing=1):
|
||||||
|
|
||||||
def do_create():
|
def do_create():
|
||||||
@ -226,7 +191,7 @@ class TestLongProcessing(TestActionsBase):
|
|||||||
try:
|
try:
|
||||||
v_utils.generate_fake_host_alarm(
|
v_utils.generate_fake_host_alarm(
|
||||||
'nova.host-0-nova.zone-0-openstack.cluster-0',
|
'nova.host-0-nova.zone-0-openstack.cluster-0',
|
||||||
'test_high_availability_events' + str(i),
|
'test_high_availability_events %s' % i,
|
||||||
enabled=False)
|
enabled=False)
|
||||||
except Exception:
|
except Exception:
|
||||||
continue
|
continue
|
||||||
|
@ -61,7 +61,7 @@ def run_vitrage_command(command):
|
|||||||
user_domain_id_param,
|
user_domain_id_param,
|
||||||
project_domain_id_par)
|
project_domain_id_par)
|
||||||
|
|
||||||
LOG.info('Full command: %s', full_command)
|
LOG.debug('Full command: %s', full_command)
|
||||||
|
|
||||||
child = subprocess.Popen(full_command,
|
child = subprocess.Popen(full_command,
|
||||||
shell=True,
|
shell=True,
|
||||||
@ -76,7 +76,7 @@ def run_vitrage_command(command):
|
|||||||
|
|
||||||
output = stdout.decode('utf-8')
|
output = stdout.decode('utf-8')
|
||||||
|
|
||||||
LOG.info('cli stdout: %s', output)
|
LOG.debug('cli stdout: %s', output)
|
||||||
|
|
||||||
if child.returncode:
|
if child.returncode:
|
||||||
LOG.error('process return code is not 0 : return code = %d',
|
LOG.error('process return code is not 0 : return code = %d',
|
||||||
|
Loading…
Reference in New Issue
Block a user