use of org.openkilda.pce.finder.BestWeightAndShortestPathFinder in project open-kilda by telstra.
the class LatencyPathComputationStrategyBaseTest method shouldSetBackUpFlagWhenPathHasLatencyGreaterThanMaxLatency.
@Test
public void shouldSetBackUpFlagWhenPathHasLatencyGreaterThanMaxLatency() throws RecoverableException, UnroutableFlowException {
createTriangleTopo(IslStatus.ACTIVE, 100, 100, "00:", 1);
// when: request a flow with LATENCY strategy and 'max-latency' is lower than found path
Flow flow = Flow.builder().flowId("test flow").srcSwitch(getSwitchById("00:01")).srcPort(15).destSwitch(getSwitchById("00:02")).destPort(15).bandwidth(500).encapsulationType(FlowEncapsulationType.TRANSIT_VLAN).pathComputationStrategy(PathComputationStrategy.LATENCY).maxLatency(50L).maxLatencyTier2(300L).build();
PathComputer pathComputer = new InMemoryPathComputer(availableNetworkFactory, new BestWeightAndShortestPathFinder(5), config);
GetPathsResult pathsResult = pathComputer.getPath(flow);
// then: system returns a path built with backUpPathComputationWayUsed flag
assertTrue(pathsResult.isBackUpPathComputationWayUsed());
assertThat(pathsResult.getForward().getSegments().get(1).getSrcSwitchId(), equalTo(new SwitchId("00:03")));
assertThat(pathsResult.getReverse().getSegments().get(1).getSrcSwitchId(), equalTo(new SwitchId("00:03")));
}
use of org.openkilda.pce.finder.BestWeightAndShortestPathFinder in project open-kilda by telstra.
the class MaxLatencyPathComputationStrategyBaseTest method shouldUseBackUpWeightWhenNoPathFoundInMaxLatencyStrat.
@Test
public void shouldUseBackUpWeightWhenNoPathFoundInMaxLatencyStrat() throws RecoverableException, UnroutableFlowException {
// 1 - 2 - 4
// + 3 +
// path 1>2>4 has less latency than 1>3>4
createDiamond(IslStatus.ACTIVE, IslStatus.ACTIVE, 100, 100, "00:", 1, 100, 101);
// when: request a flow with MAX_LATENCY strategy and 'max-latency' is not enough to build a path
Flow flow = Flow.builder().flowId("test flow").srcSwitch(getSwitchById("00:01")).srcPort(15).destSwitch(getSwitchById("00:04")).destPort(15).bandwidth(500).encapsulationType(FlowEncapsulationType.TRANSIT_VLAN).pathComputationStrategy(PathComputationStrategy.MAX_LATENCY).maxLatency(100L).maxLatencyTier2(300L).build();
PathComputer pathComputer = new InMemoryPathComputer(availableNetworkFactory, new BestWeightAndShortestPathFinder(5), config);
GetPathsResult pathsResult = pathComputer.getPath(flow);
// then: system returns a path built by 'max_latency_tier2'
assertTrue(pathsResult.isBackUpPathComputationWayUsed());
assertThat(pathsResult.getForward().getSegments().get(1).getSrcSwitchId(), equalTo(new SwitchId("00:03")));
assertThat(pathsResult.getReverse().getSegments().get(1).getSrcSwitchId(), equalTo(new SwitchId("00:03")));
}
use of org.openkilda.pce.finder.BestWeightAndShortestPathFinder 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());
}
use of org.openkilda.pce.finder.BestWeightAndShortestPathFinder in project open-kilda by telstra.
the class MaxLatencyPathComputationStrategyBaseTest method maxLatencyStratWithNullLatency.
/**
* Special case: flow with MAX_LATENCY strategy and 'max-latency' being unset(null) should pick path with least
* latency.
*/
@Test
public void maxLatencyStratWithNullLatency() throws RecoverableException, UnroutableFlowException {
// 1 - 2 - 4
// + 3 +
// path 1>2>4 has less latency than 1>3>4
createDiamond(IslStatus.ACTIVE, IslStatus.ACTIVE, 100, 100, "00:", 1, 100, 101);
// when: request a flow with MAX_LATENCY strategy and 'max-latency' set to 0
Flow flow = Flow.builder().flowId("test flow").srcSwitch(getSwitchById("00:01")).srcPort(15).destSwitch(getSwitchById("00:04")).destPort(15).bandwidth(500).encapsulationType(FlowEncapsulationType.TRANSIT_VLAN).pathComputationStrategy(PathComputationStrategy.MAX_LATENCY).build();
PathComputer pathComputer = new InMemoryPathComputer(availableNetworkFactory, new BestWeightAndShortestPathFinder(5), config);
GetPathsResult pathsResult = pathComputer.getPath(flow);
// then: system returns a path with least weight
assertFalse(pathsResult.isBackUpPathComputationWayUsed());
assertThat(pathsResult.getForward().getSegments().get(1).getSrcSwitchId(), equalTo(new SwitchId("00:02")));
assertThat(pathsResult.getReverse().getSegments().get(1).getSrcSwitchId(), equalTo(new SwitchId("00:02")));
}
use of org.openkilda.pce.finder.BestWeightAndShortestPathFinder in project open-kilda by telstra.
the class LatencyPathComputationStrategyBaseTest method shouldReturnEmptyPathWhenPathHasLatencyGreaterThanMaxLatencyTier2.
@Test
public void shouldReturnEmptyPathWhenPathHasLatencyGreaterThanMaxLatencyTier2() throws RecoverableException, UnroutableFlowException {
createTriangleTopo(IslStatus.ACTIVE, 100, 100, "00:", 1);
// when: request a flow with LATENCY strategy and 'max-latency-tier-2' is lower than found path
Flow flow = Flow.builder().flowId("test flow").srcSwitch(getSwitchById("00:01")).srcPort(15).destSwitch(getSwitchById("00:02")).destPort(15).bandwidth(500).encapsulationType(FlowEncapsulationType.TRANSIT_VLAN).pathComputationStrategy(PathComputationStrategy.LATENCY).maxLatency(50L).maxLatencyTier2(70L).build();
PathComputer pathComputer = new InMemoryPathComputer(availableNetworkFactory, new BestWeightAndShortestPathFinder(5), config);
// then: system can't find path
thrown.expect(UnroutableFlowException.class);
pathComputer.getPath(flow);
}
Aggregations