Skip to content

Commit

Permalink
Merge pull request #2063 from anarkiwi/master
Browse files Browse the repository at this point in the history
Test stacking where redundant links are down/root dp is unreachable, …
  • Loading branch information
anarkiwi authored Jun 11, 2018
2 parents e4972fc + cfefa10 commit 7fe7daf
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 9 deletions.
13 changes: 7 additions & 6 deletions faucet/dp.py
Original file line number Diff line number Diff line change
Expand Up @@ -403,16 +403,17 @@ def make_edge_attr(edge_a, edge_z):

def shortest_path(self, dest_dp):
"""Return shortest path to a DP, as a list of DPs."""
if self.stack is None:
return None
return networkx.shortest_path(
self.stack['graph'], self.name, dest_dp)
if self.stack is not None and 'root_dp' in self.stack:
return networkx.shortest_path(
self.stack['graph'], self.name, dest_dp)
return []

def shortest_path_to_root(self):
"""Return shortest path to root DP, as list of DPs."""
if self.stack is not None:
# TODO: root_dp will be None, if stacking is enabled but the root DP is down.
if self.stack is not None and 'root_dp' in self.stack:
root_dp = self.stack['root_dp']
if root_dp != self:
if root_dp is not None and root_dp != self:
return self.shortest_path(root_dp.name)
return []

Expand Down
11 changes: 8 additions & 3 deletions tests/faucet_mininet_test_unit.py
Original file line number Diff line number Diff line change
Expand Up @@ -5242,11 +5242,14 @@ def setUp(self): # pylint: disable=invalid-name
switch_to_switch_links=2)
self.start_net()

def verify_one_stack_down(self, port_no):
def verify_one_stack_down(self, port_no, coldstart=False):
self.retry_net_ping()
self.set_port_down(port_no, wait=False)
# self.dpids[1] is the intermediate switch.
self.set_port_down(port_no, self.dpids[1], wait=False)
# test case where one link is down when coldstarted.
if coldstart:
self.coldstart_conf()
self.retry_net_ping()
# Broadcast works, and first switch doesn't see broadcast packet ins from stack.
packet_in_before_broadcast = self.scrape_prometheus_var('of_vlan_packet_ins')
Expand All @@ -5258,10 +5261,12 @@ def verify_one_stack_down(self, port_no):

def test_tagged(self):
"""All tagged hosts in stack topology can reach each other."""
self.verify_one_stack_down(self.NUM_HOSTS + 1)
for coldstart in (False, True):
self.verify_one_stack_down(self.NUM_HOSTS + 1, coldstart)

def test_other_tagged(self):
self.verify_one_stack_down(self.NUM_HOSTS + 2)
for coldstart in (False, True):
self.verify_one_stack_down(self.NUM_HOSTS + 2, coldstart)


class FaucetStackStringOfDPUntaggedTest(FaucetStringOfDPTest):
Expand Down

0 comments on commit 7fe7daf

Please sign in to comment.