use of org.openkilda.model.PathId in project open-kilda by telstra.
the class LatencyPathComputationStrategyBaseTest method shouldFindTheSameDiversePath.
@Test
public void shouldFindTheSameDiversePath() throws RecoverableException, UnroutableFlowException {
createDiamondWithDiversity();
Flow flow = Flow.builder().flowId("new-flow").diverseGroupId("diverse").bandwidth(10).srcSwitch(getSwitchById("00:0A")).srcPort(10).destSwitch(getSwitchById("00:0D")).destPort(10).encapsulationType(FlowEncapsulationType.TRANSIT_VLAN).pathComputationStrategy(PathComputationStrategy.LATENCY).build();
PathComputer pathComputer = pathComputerFactory.getPathComputer();
GetPathsResult diversePath = pathComputer.getPath(flow);
FlowPath forwardPath = FlowPath.builder().pathId(new PathId(UUID.randomUUID().toString())).srcSwitch(flow.getSrcSwitch()).destSwitch(flow.getDestSwitch()).bandwidth(flow.getBandwidth()).build();
addPathSegments(forwardPath, diversePath.getForward());
flow.setForwardPath(forwardPath);
FlowPath reversePath = FlowPath.builder().pathId(new PathId(UUID.randomUUID().toString())).srcSwitch(flow.getDestSwitch()).destSwitch(flow.getSrcSwitch()).bandwidth(flow.getBandwidth()).build();
addPathSegments(reversePath, diversePath.getReverse());
flow.setReversePath(reversePath);
flowRepository.add(flow);
GetPathsResult path2 = pathComputer.getPath(flow, flow.getPathIds());
assertEquals(diversePath, path2);
}
use of org.openkilda.model.PathId in project open-kilda by telstra.
the class AvailableNetworkTest method buildPathWithSegment.
private PathSegment buildPathWithSegment(SwitchId srcDpid, SwitchId dstDpid, int srcPort, int dstPort, String srcPop, String dstPop, int seqId) {
Switch srcSwitch = Switch.builder().switchId(srcDpid).pop(srcPop).build();
Switch dstSwitch = Switch.builder().switchId(dstDpid).pop(dstPop).build();
PathId pathId = new PathId(UUID.randomUUID().toString());
FlowPath flowPath = FlowPath.builder().pathId(pathId).srcSwitch(srcSwitch).destSwitch(dstSwitch).segments(IntStream.rangeClosed(0, seqId).mapToObj(i -> PathSegment.builder().pathId(pathId).srcSwitch(srcSwitch).destSwitch(dstSwitch).srcPort(srcPort).destPort(dstPort).build()).collect(toList())).build();
return flowPath.getSegments().get(seqId);
}
use of org.openkilda.model.PathId in project open-kilda by telstra.
the class InMemoryPathComputerBaseTest method buildFlowPath.
private FlowPath buildFlowPath(String pathIdAsString, int... ids) {
PathId pathId = new PathId(pathIdAsString);
List<PathSegment> segments = new ArrayList<>();
for (int i = 1; i < ids.length; i++) {
segments.add(PathSegment.builder().pathId(pathId).srcSwitch(Switch.builder().switchId(new SwitchId(ids[i - 1])).build()).destSwitch(Switch.builder().switchId(new SwitchId(ids[i])).build()).build());
}
return FlowPath.builder().pathId(pathId).srcSwitch(Switch.builder().switchId(new SwitchId(ids[0])).build()).destSwitch(Switch.builder().switchId(new SwitchId(ids[ids.length - 1])).build()).segments(segments).build();
}
use of org.openkilda.model.PathId in project open-kilda by telstra.
the class InMemoryPathComputerBaseTest method createDiamondWithAffinity.
// A - B - D and A-B-D is used in flow affinity group
// + C +
void createDiamondWithAffinity() {
Switch nodeA = createSwitch("00:0A");
Switch nodeB = createSwitch("00:0B");
Switch nodeC = createSwitch("00:0C");
Switch nodeD = createSwitch("00:0D");
IslStatus status = IslStatus.ACTIVE;
int cost = 100;
createIsl(nodeA, nodeB, status, status, cost * 2, 1000, 1, cost * 2);
createIsl(nodeA, nodeC, status, status, cost, 1000, 2, cost);
createIsl(nodeB, nodeD, status, status, cost * 2, 1000, 3, cost * 2);
createIsl(nodeC, nodeD, status, status, cost, 1000, 4, cost);
createIsl(nodeB, nodeA, status, status, cost * 2, 1000, 1, cost * 2);
createIsl(nodeC, nodeA, status, status, cost, 1000, 2, cost);
createIsl(nodeD, nodeB, status, status, cost * 2, 1000, 3, cost * 2);
createIsl(nodeD, nodeC, status, status, cost, 1000, 4, cost);
int bandwith = 10;
Flow flow = Flow.builder().flowId(TEST_FLOW_ID).srcSwitch(nodeA).srcPort(15).destSwitch(nodeD).destPort(16).affinityGroupId(TEST_FLOW_ID).bandwidth(bandwith).encapsulationType(FlowEncapsulationType.TRANSIT_VLAN).build();
FlowPath forwardPath = FlowPath.builder().pathId(new PathId(UUID.randomUUID().toString())).srcSwitch(nodeA).destSwitch(nodeD).bandwidth(bandwith).cookie(new FlowSegmentCookie(1L).toBuilder().direction(FlowPathDirection.FORWARD).build()).build();
addPathSegment(forwardPath, nodeA, nodeB, 1, 1);
addPathSegment(forwardPath, nodeB, nodeD, 3, 3);
flow.setForwardPath(forwardPath);
FlowPath reversePath = FlowPath.builder().pathId(new PathId(UUID.randomUUID().toString())).srcSwitch(nodeD).destSwitch(nodeA).bandwidth(bandwith).cookie(new FlowSegmentCookie(1L).toBuilder().direction(FlowPathDirection.REVERSE).build()).build();
addPathSegment(reversePath, nodeD, nodeB, 3, 3);
addPathSegment(reversePath, nodeB, nodeA, 1, 1);
flow.setReversePath(reversePath);
flowRepository.add(flow);
}
use of org.openkilda.model.PathId in project open-kilda by telstra.
the class InMemoryPathComputerBaseTest method shouldThrowPathHasNoSegmentsWhenSegmentsIsNull.
@Test
public void shouldThrowPathHasNoSegmentsWhenSegmentsIsNull() {
FlowPath flowPathA = FlowPath.builder().pathId(new PathId("flow_path_a")).srcSwitch(Switch.builder().switchId(new SwitchId(1)).build()).destSwitch(Switch.builder().switchId(new SwitchId(3)).build()).build();
FlowPath flowPathB = buildFlowPath("flow_path_b", 1, 2, 4, 5);
InMemoryPathComputer pathComputer = new InMemoryPathComputer(availableNetworkFactory, new BestWeightAndShortestPathFinder(config.getMaxAllowedDepth()), config);
Exception exception = assertThrows(IllegalArgumentException.class, () -> pathComputer.convertFlowPathsToSwitchLists(SWITCH_1, flowPathA, flowPathB));
assertEquals("The path 'flow_path_a' has no path segments", exception.getMessage());
}
Aggregations