def test_max_50_base_load_projection(self): """Test that the max_50 base load projection does not overload any link, as links have different capacities""" # iterate over each of the seedmapping values for seed in range(1, 11): EnterpriseTopology(mappingseed=seed)
def test_0_5_50_base_load_projection(self): """Test that the 0.5-50 base load projection does not overload any link, as links have different capacities""" with self.assertRaisesRegexp(AssertionError, "No acceptable scaling factor found"): # iterate over each of the seedmapping values for seed in range(1, 11): EnterpriseTopology(tm_factor_name="0.5-50", mappingseed=seed)
def test_rollback(self): """In case a port could not be made SDN, the current state of the simulation needs to be rolled back. This method tests if this is done correctly.""" topo = EnterpriseTopology.load_from_pickle("2004", "max-50", 1, 2) sim = Simulator(topo, self.args_2) istate = sim.istate strategy = "VOL" self.assertNotEqual(sim.switch_selection(istate, strategy), 0) istate.reinitialize() istate.frontiers = sim.find_frontiers(istate) self.assertEqual(len(istate.remaining_ft_per_switch), 1) # Save ramaining ft state remaining_ft = {} for key in istate.remaining_ft_per_switch.iterkeys(): remaining_ft[key] = istate.remaining_ft_per_switch[key] # Save forwarding rules state basic_forwarding_rules_at_sw = {} for key in istate.basic_forwarding_rules_at_sw.iterkeys(): basic_forwarding_rules_at_sw[key] = set() for port in istate.basic_forwarding_rules_at_sw[key]: basic_forwarding_rules_at_sw[key].add(str(port)) # Save graph state rollback_graph = {} for src, dst, edgeattrs in topo.graph.edges(data=True): if src not in rollback_graph: rollback_graph[src] = {} rollback_graph[src][dst] = copy.deepcopy(edgeattrs) port = topo.ports()[0] sim.make_port_sdn(istate, port, False) # Check remaining ft for key in istate.remaining_ft_per_switch.iterkeys(): self.assertEqual(istate.remaining_ft_per_switch[key], remaining_ft[key]) # Check graph for src, dst, edgeattrs in topo.graph.edges(data=True): for key in rollback_graph[src][dst]: self.assertEqual(edgeattrs[key], rollback_graph[src][dst][key]) # Checks if reinitialize correctly resets the forwarding rules istate.reinitialize() for key in istate.basic_forwarding_rules_at_sw.iterkeys(): for port in istate.basic_forwarding_rules_at_sw[key]: self.assertEqual(len(basic_forwarding_rules_at_sw), len(istate.basic_forwarding_rules_at_sw)) self.assertIn(str(port), basic_forwarding_rules_at_sw[key])
class TestPort(unittest.TestCase): """ Tests for the classes of the EnterpriseTopology class""" def setUp(self): self.topo = EnterpriseTopology() def test_graph_invariants(self): """ test that the traffic matrix is identical """ is_true = list_is_true([list_is_true( [v == self.topo.graph.node[x.switch]['tm'][int(x.name)][int(k.name)] for k,v in x._volume_to.iteritems()]) for x in self.topo.ports()]) assert is_true is True
class TestPort(unittest.TestCase): """ Tests for the classes of the EnterpriseTopology class""" def setUp(self): self.topo = EnterpriseTopology() def test_graph_invariants(self): """ test that the traffic matrix is identical """ is_true = list_is_true([ list_is_true([ v == self.topo.graph.node[x.switch]['tm'][int(x.name)][int( k.name)] for k, v in x._volume_to.iteritems() ]) for x in self.topo.ports() ]) assert is_true is True
def test_allocate_basic_forwarding_at_sw(self): """allocate_basic_forwarding_at_sw needs to be idempotent. This test verifies that.""" topo = EnterpriseTopology.load_from_pickle("2004", "max-50", 1, 2) sim = Simulator(topo, self.args) istate = sim.istate switch = topo.graph.nodes()[0] istate.sdn_switches[switch] = topo.graph.node[switch] istate.reinitialize() port = topo.graph.node[switch]['ports'][0] self.assertEqual(istate.allocate_basic_forwarding_at_sw(switch, port), 1) self.assertEqual(istate.allocate_basic_forwarding_at_sw(switch, port), 0) self.assertEqual(len(istate.basic_forwarding_rules_at_sw[switch]), 1)
def test_reinitialize(self): """Checks if IterationState.reinitialize correctly reinitializes the iteration state.""" topo = EnterpriseTopology.load_from_pickle("2004", "max-50", 1, 2) sim = Simulator(topo, self.args) istate = sim.istate istate.reinitialize() self.check_istate_reinitialization(istate) istate.frontiers = sim.find_frontiers(istate) sim.allocate_ft_for_ports_on_sdn_switches(istate) sim.make_ports_sdn(istate, cand_ports=istate.ports_on_sdn_switches()) istate.reinitialize() self.check_istate_reinitialization(istate)
def setUp(self): self.topo = EnterpriseTopology()
def main(): FORMAT="%(asctime)s %(process)d %(levelname)s %(message)s" logging.basicConfig(format=FORMAT) logger = logging.getLogger('panoptisim') parser = get_parser() args = parser.parse_args() logger.setLevel(args.verbosity) for module in ['sim.topology', 'sim.simulator']: lg = logging.getLogger(module) lg.setLevel(logger.getEffectiveLevel()) logger.info("Starting on host [{}]".format(args.hostname)) logger.info("Starting with args: {args}".format( args="\n\t".join(sorted([str(k)+": "+str(v) for k,v in args.__dict__.iteritems()])) ) ) logger.debug("Excluding Devices: %s" % str(args.exclude)) random.seed(args.seedmapping) logger.debug("Mapping Randomseed is: %s" % str(args.seedmapping)) EPscalingFactor = int(args.epsf) topo = None if args.pickletopo: topo = EnterpriseTopology.load_from_pickle(args.tm, args.tmsf, args.seedmapping, EPscalingFactor) else: logger.info("Creating New EnterpriseTopology") topo = EnterpriseTopology(tm=args.tm, tm_factor_name=args.tmsf, EPscalingFactor=EPscalingFactor) random.seed(args.seednextswitch) logger.debug("Nextswitch Randomseed: %s" % str(args.seednextswitch)) # Magic switches are switches that can accommmodate all 1296 SDN ports with # traffic under epp=2 maxvlan=1024 maxft=100000 if args.magicswitches > 0: magic_switches = ['config451', 'config1520', 'config333', 'config424', 'config426', 'config427', 'config428', 'config429', 'config431', 'config433', 'config434', 'config435', 'config436', 'config437', 'config439', 'config441', 'config442', 'config444', 'config445', 'config446', 'config447', 'config449', 'config450', 'config452', 'config453', 'config457', 'config458', 'config459', 'config460', 'config461', 'config462', 'config463', 'config465', 'config468', 'config469', 'config471', 'config474', 'config567', 'config714', 'config775', 'config823', 'config842', 'config962', 'config1515', 'config455', 'config473', 'config470', 'config418', 'config467', 'config472', 'config713'] random.shuffle(magic_switches) args.onlyupgrade = magic_switches[:args.magicswitches] logger.info("Starting with magic switches: {args}".format( args="\n\t".join(sorted([str(k)+": "+str(v) for k,v in args.__dict__.iteritems()])) ) ) simulation = Simulator(topo, args) simulation.run() logger.info("Finished Simulation")
def setUp(self): self.topo = EnterpriseTopology.load_from_pickle("2004", "max-50", 1, 2)
def main(): FORMAT = "%(asctime)s %(process)d %(levelname)s %(message)s" logging.basicConfig(format=FORMAT) logger = logging.getLogger('panoptisim') parser = get_parser() args = parser.parse_args() logger.setLevel(args.verbosity) for module in ['sim.topology', 'sim.simulator']: lg = logging.getLogger(module) lg.setLevel(logger.getEffectiveLevel()) logger.info("Starting on host [{}]".format(args.hostname)) logger.info("Starting with args: {args}".format(args="\n\t".join( sorted([str(k) + ": " + str(v) for k, v in args.__dict__.iteritems()])))) logger.debug("Excluding Devices: %s" % str(args.exclude)) random.seed(args.seedmapping) logger.debug("Mapping Randomseed is: %s" % str(args.seedmapping)) EPscalingFactor = int(args.epsf) topo = None if args.pickletopo: topo = EnterpriseTopology.load_from_pickle(args.tm, args.tmsf, args.seedmapping, EPscalingFactor) else: logger.info("Creating New EnterpriseTopology") topo = EnterpriseTopology(tm=args.tm, tm_factor_name=args.tmsf, EPscalingFactor=EPscalingFactor) random.seed(args.seednextswitch) logger.debug("Nextswitch Randomseed: %s" % str(args.seednextswitch)) # Magic switches are switches that can accommmodate all 1296 SDN ports with # traffic under epp=2 maxvlan=1024 maxft=100000 if args.magicswitches > 0: magic_switches = [ 'config451', 'config1520', 'config333', 'config424', 'config426', 'config427', 'config428', 'config429', 'config431', 'config433', 'config434', 'config435', 'config436', 'config437', 'config439', 'config441', 'config442', 'config444', 'config445', 'config446', 'config447', 'config449', 'config450', 'config452', 'config453', 'config457', 'config458', 'config459', 'config460', 'config461', 'config462', 'config463', 'config465', 'config468', 'config469', 'config471', 'config474', 'config567', 'config714', 'config775', 'config823', 'config842', 'config962', 'config1515', 'config455', 'config473', 'config470', 'config418', 'config467', 'config472', 'config713' ] random.shuffle(magic_switches) args.onlyupgrade = magic_switches[:args.magicswitches] logger.info( "Starting with magic switches: {args}".format(args="\n\t".join( sorted([ str(k) + ": " + str(v) for k, v in args.__dict__.iteritems() ])))) simulation = Simulator(topo, args) simulation.run() logger.info("Finished Simulation")