def testNodeID(self): '''Verify NodeID conversion in both directions.''' pairs = {(0, 0, 1): 0x000001, (0, 1, 1): 0x000101, (1, 0, 1): 0x010001} for a, b in pairs.iteritems(): (x, y, z) = a self.assertEqual(FatTreeTopo.FatTreeNodeID(x, y, z).dpid, b) self.assertEqual(str(FatTreeTopo.FatTreeNodeID(dpid = b)), str(a))
def testDownNodesAndEdges(self): '''Verify number of down edges at each layer.''' ft = FatTreeTopo(4) # map FatTreeNodeID inputs to down node/edge totals pairs = {(0, 0, 1): 2, (0, 2, 1): 2, (4, 1, 1): 4} for a, b in pairs.iteritems(): (x, y, z) = a host = FatTreeTopo.FatTreeNodeID(x, y, z).name_str() self.assertEqual(len(ft.down_nodes(host)), b) self.assertEqual(len(ft.down_edges(host)), b)
def testPorts(self): '''Verify port numbering between selected nodes.''' ft = FatTreeTopo(4) tuples = [((0, 0, 2), (0, 0, 1), 0, 2), ((0, 0, 1), (0, 2, 1), 1, 2), ((0, 0, 1), (0, 3, 1), 3, 2), ((0, 2, 1), (4, 1, 1), 1, 1), ((0, 2, 1), (4, 1, 2), 3, 1), ((3, 3, 1), (4, 2, 1), 1, 4) ] for tuple_ in tuples: src, dst, srcp_exp, dstp_exp = tuple_ x, y, z = src x2, y2, z2 = dst src_dpid = FatTreeTopo.FatTreeNodeID(x, y, z).name_str() dst_dpid = FatTreeTopo.FatTreeNodeID(x2, y2, z2).name_str() (srcp, dstp) = ft.port(src_dpid, dst_dpid) self.assertEqual(srcp, srcp_exp) self.assertEqual(dstp, dstp_exp) # flip order and ensure same result (dstp, srcp) = ft.port(dst_dpid, src_dpid) self.assertEqual(srcp, srcp_exp) self.assertEqual(dstp, dstp_exp)