def _createPaths(self, src_port, dst_port): links = [(3, 1, 1, 2), (2, 4, 5, 2), (2, 3, 4, 2), (5, 2, 2, 4),\ (1, 4, 5, 1), (2, 2, 3, 2), (3, 2, 2, 2), (1, 2, 3, 1),\ (1, 3, 4, 1), (4, 1, 1, 3), (4, 2, 2, 3), (1, 1, 2, 1),\ (5, 1, 1, 4), (2, 1, 1, 1)] link_list = test_util.getLinkList(links) path_list = PathList(link_list) paths = path_list.createWholePath(src_port.dpid, dst_port.dpid) return paths
def testLink(self): links = [(3, 1, 1, 2), (2, 4, 5, 2), (2, 3, 4, 2), (5, 2, 2, 4),\ (1, 4, 5, 1), (2, 2, 3, 2), (3, 2, 2, 2), (1, 2, 3, 1),\ (1, 3, 4, 1), (4, 1, 1, 3), (4, 2, 2, 3), (1, 1, 2, 1),\ (5, 1, 1, 4), (2, 1, 1, 1)] link_list = self._getLinkList(links) src_port = self._createPort(4, 3) dst_port = self._createPort(5, 3) path_list = PathList(link_list) paths = path_list.createWholePath(src_port.dpid, dst_port.dpid) expected_pathes = [[(4, 1), (1, 3), (1, 4), (5, 1)], [(4, 2), (2, 3), (2, 4), (5, 2)], [(4, 1), (1, 3), (1, 1), (2, 1), (2, 4), (5, 2)], [(4, 2), (2, 3), (2, 1), (1, 1), (1, 4), (5, 1)], [(4, 1), (1, 3), (1, 2), (3, 1), (3, 2), (2, 2),\ (2, 4), (5, 2)], [(4, 2), (2, 3), (2, 2), (3, 2), (3, 1), (1, 2),\ (1, 4), (5, 1)]] for index in range(len(paths)): path = paths[index] expected_path = expected_pathes[index] for port_index in range(len(path)): eq_(expected_path[port_index][0], path[port_index].dpid) eq_(expected_path[port_index][1], path[port_index].port_no)