diff --git a/faucet/valve.py b/faucet/valve.py index efaf2e8d85..9a61ec7589 100644 --- a/faucet/valve.py +++ b/faucet/valve.py @@ -671,7 +671,7 @@ def _update_stack_link_state(self, ports, now, other_valves): self.notify( {'STACK_TOPO_CHANGE': { 'stack_root': valve.dp.stack_root_name, - 'graph': valve.dp.stack_graph, + 'graph': valve.dp.get_node_link_data(), 'dps': notify_dps }}) break diff --git a/tests/integration/mininet_multidp_tests.py b/tests/integration/mininet_multidp_tests.py index ac4ff6f0c6..48c530a1f9 100644 --- a/tests/integration/mininet_multidp_tests.py +++ b/tests/integration/mininet_multidp_tests.py @@ -4,6 +4,7 @@ import os import time import networkx +import json from mininet.log import error @@ -1806,3 +1807,28 @@ def test_broadcast_loop(self): self.assertEqual( except_count, 1, 'Number of links detecting the broadcast ARP %s (!= 1)' % except_count) + + +class FaucetStackTopoChangeTest(FaucetMultiDPTest): + """Test STACK_TOPO_CHANGE event structure""" + + NUM_DPS = 3 + + def test_graph_object(self): + """Parse event log and validate graph object in event.""" + self.set_up( + stack=True, n_dps=self.NUM_DPS, n_tagged=self.NUM_HOSTS, switch_to_switch_links=2) + self._enable_event_log() + self.verify_stack_up() + stack_event_found = False + with open(self.event_log, 'r') as event_log_file: + for event_log_line in event_log_file.readlines(): + event = json.loads(event_log_line.strip()) + if 'STACK_TOPO_CHANGE' in event: + stack_event_found = True + graph = event.get('STACK_TOPO_CHANGE').get('graph') + self.assertTrue(graph) + nodeCount = len(graph.get('nodes')) + self.assertEqual(nodeCount, 3, + 'Number of nodes in graph object is %s (!=3)' % nodeCount) + self.assertTrue(stack_event_found)