Skip to content

Commit

Permalink
Merge pull request #3556 from mab68/topo
Browse files Browse the repository at this point in the history
Test suite config & topology generation
  • Loading branch information
gizmoguy authored May 11, 2020
2 parents 719b01c + 05e7a74 commit 34b3c7e
Show file tree
Hide file tree
Showing 9 changed files with 1,591 additions and 1,146 deletions.
533 changes: 533 additions & 0 deletions clib/config_generator.py

Large diffs are not rendered by default.

508 changes: 181 additions & 327 deletions clib/mininet_test_base_topo.py

Large diffs are not rendered by default.

54 changes: 27 additions & 27 deletions clib/mininet_test_topo.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,33 @@ class FaucetHost(CPULimitedHost):
"""Base Mininet Host class, for Mininet-based tests."""


class VLANHost(FaucetHost):
"""Implementation of a Mininet host on a tagged VLAN."""

intf_root_name = None

def config(self, vlans=[100], **params): # pylint: disable=arguments-differ
"""Configure VLANHost according to (optional) parameters:
vlans (list): List of VLAN IDs for default interface"""
super_config = super().config(**params)
intf = self.defaultIntf()
vlan_intf_name = '%s.%s' % (intf, '.'.join(str(v) for v in vlans))
cmds = [
'ip -4 addr flush dev %s' % intf,
'ip -6 addr flush dev %s' % intf,
'ip link set dev %s up' % vlan_intf_name,
'ip -4 addr add %s dev %s' % (params['ip'], vlan_intf_name)
]
for v in vlans:
cmds.append('vconfig add %s %d' % (intf, v))
for cmd in cmds:
self.cmd(cmd)
self.intf_root_name = intf.name
intf.name = vlan_intf_name
self.nameToIntf[vlan_intf_name] = intf
return super_config


class FaucetSwitch(OVSSwitch):
"""Switch that will be used by all tests (netdev based OVS)."""

Expand Down Expand Up @@ -154,33 +181,6 @@ def start(self, _controllers):
super().start(controllers=[])


class VLANHost(FaucetHost):
"""Implementation of a Mininet host on a tagged VLAN."""

intf_root_name = None

def config(self, vlans=[100], **params): # pylint: disable=arguments-differ
"""Configure VLANHost according to (optional) parameters:
vlans (list): List of VLAN IDs for default interface"""
super_config = super().config(**params)
intf = self.defaultIntf()
vlan_intf_name = '%s.%s' % (intf, '.'.join(str(v) for v in vlans))
cmds = [
'ip -4 addr flush dev %s' % intf,
'ip -6 addr flush dev %s' % intf,
'ip link set dev %s up' % vlan_intf_name,
'ip -4 addr add %s dev %s' % (params['ip'], vlan_intf_name)
]
for v in vlans:
cmds.append('vconfig add %s %d' % (intf, v))
for cmd in cmds:
self.cmd(cmd)
self.intf_root_name = intf.name
intf.name = vlan_intf_name
self.nameToIntf[vlan_intf_name] = intf
return super_config


class FaucetSwitchTopo(Topo):
"""FAUCET switch topology that contains a software switch."""

Expand Down
253 changes: 0 additions & 253 deletions clib/mininet_test_topo_generator.py

This file was deleted.

16 changes: 8 additions & 8 deletions clib/mininet_test_watcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,33 +28,33 @@ class TopologyWatcher():
# Dict of src host key and dst hosts value
connected_hosts = None

def __init__(self, dpids, dp_links, host_links, n_vlans, host_information, routers):
def __init__(self, dpids, switch_links, host_links, n_vlans, host_information, routers):
"""
Args:
dpids (list): Switch dpids to match the DPID indices used in dp_links & other structures
dp_links (dict):
switch_links (dict):
host_links (dict):
n_vlans: Number of VLANs
host_information (dict):
"""
self.dpids = dpids
self.dp_links = dp_links
self.switch_links = switch_links
self.host_links = host_links
self.n_vlans = n_vlans
self.host_information = host_information
self.routers = routers
self.fault_list = []
self.add_fault('Initial')
self.generate_predicted_graph(dpids, dp_links, host_links, host_information)
self.generate_predicted_graph(dpids, switch_links, host_links, host_information)

def generate_predicted_graph(self, dpids, dp_links, host_links, host_information):
def generate_predicted_graph(self, dpids, switch_links, host_links, host_information):
"""Creates the predicted network graph"""
self.predicted_network_graph = networkx.MultiGraph()
for dpid in dpids:
self.predicted_network_graph.add_node(dpid)
for src, dsts in dp_links.items():
for dst in dsts:
self.predicted_network_graph.add_edge(self.dpids[src], self.dpids[dst])
for link in switch_links:
u, v = link
self.predicted_network_graph.add_edge(self.dpids[u], self.dpids[v])
self.host_name_to_index = {}
for host_id, host_info in host_information.items():
host_name = host_info['host'].name
Expand Down
Loading

0 comments on commit 34b3c7e

Please sign in to comment.