use of org.openkilda.pce.PathComputer in project open-kilda by telstra.
the class InMemoryPathComputerBaseTest method shouldAlwaysFindPathForExistedFlow.
/**
* Checks that existed flow should always have available path even there is only links with 0 available bandwidth.
*/
@Test
public void shouldAlwaysFindPathForExistedFlow() throws RecoverableException, UnroutableFlowException {
String flowId = "flow-A1:01-A1:03";
long bandwidth = 1000;
createLinearTopoWithFlowSegments(10, "A1:", 1, 0L, flowId, bandwidth);
Switch srcSwitch = getSwitchById("A1:01");
Switch destSwitch = getSwitchById("A1:03");
Flow flow = new TestFlowBuilder().flowId(flowId).srcSwitch(srcSwitch).destSwitch(destSwitch).bandwidth(bandwidth).ignoreBandwidth(false).build();
Flow oldFlow = flowRepository.findById(flowId).orElseThrow(() -> new AssertionError("Flow not found"));
PathComputer pathComputer = pathComputerFactory.getPathComputer();
GetPathsResult result = pathComputer.getPath(flow, oldFlow.getPathIds());
assertThat(result.getForward().getSegments(), Matchers.hasSize(2));
assertThat(result.getReverse().getSegments(), Matchers.hasSize(2));
}
use of org.openkilda.pce.PathComputer in project open-kilda by telstra.
the class InMemoryPathComputerBaseTest method shouldNotFindPathForExistedFlowAndIncreasedBandwidth.
/**
* Tests the case when we try to increase bandwidth of the flow and there is no available bandwidth left.
*/
@Test
public void shouldNotFindPathForExistedFlowAndIncreasedBandwidth() throws RecoverableException, UnroutableFlowException {
String flowId = "flow-A1:01-A1:03";
long originFlowBandwidth = 1000L;
// create network, all links have available bandwidth 0
createLinearTopoWithFlowSegments(10, "A1:", 1, 0, flowId, originFlowBandwidth);
Switch srcSwitch = getSwitchById("A1:01");
Switch destSwitch = getSwitchById("A1:03");
Flow flow = new TestFlowBuilder().flowId(flowId).srcSwitch(srcSwitch).destSwitch(destSwitch).bandwidth(originFlowBandwidth).ignoreBandwidth(false).build();
long updatedFlowBandwidth = originFlowBandwidth + 1;
flow.setBandwidth(updatedFlowBandwidth);
thrown.expect(UnroutableFlowException.class);
PathComputer pathComputer = pathComputerFactory.getPathComputer();
pathComputer.getPath(flow, flow.getPathIds());
}
use of org.openkilda.pce.PathComputer in project open-kilda by telstra.
the class InMemoryPathComputerBaseTest method verifyConversionToPair.
/**
* This verifies that the getPath in PathComputer returns what we expect. Essentially, this tests the additional
* logic wrt taking the results of the algo and convert to something installable.
*/
@Test
public void verifyConversionToPair() throws UnroutableFlowException, RecoverableException {
createDiamond(IslStatus.ACTIVE, IslStatus.ACTIVE, 10, 20, "09:", 1);
Switch srcSwitch = getSwitchById("09:01");
Switch destSwitch = getSwitchById("09:04");
Flow flow = new TestFlowBuilder().srcSwitch(srcSwitch).destSwitch(destSwitch).bandwidth(10).ignoreBandwidth(false).build();
PathComputer pathComputer = pathComputerFactory.getPathComputer();
GetPathsResult result = pathComputer.getPath(flow);
assertNotNull(result);
// ensure start/end switches match
List<Path.Segment> left = result.getForward().getSegments();
assertEquals(srcSwitch.getSwitchId(), left.get(0).getSrcSwitchId());
assertEquals(destSwitch.getSwitchId(), left.get(left.size() - 1).getDestSwitchId());
List<Path.Segment> right = result.getReverse().getSegments();
assertEquals(destSwitch.getSwitchId(), right.get(0).getSrcSwitchId());
assertEquals(srcSwitch.getSwitchId(), right.get(right.size() - 1).getDestSwitchId());
}
use of org.openkilda.pce.PathComputer in project open-kilda by telstra.
the class InMemoryPathComputerBaseTest method shouldGetYPoint2DifferentFlowPathsWithSameEndpoints.
@Test
public void shouldGetYPoint2DifferentFlowPathsWithSameEndpoints() {
FlowPath flowPathA = buildFlowPath("flow_path_a", 1, 2, 3);
FlowPath flowPathB = buildFlowPath("flow_path_b", 1, 4, 3);
PathComputer pathComputer = pathComputerFactory.getPathComputer();
SwitchId result = pathComputer.getIntersectionPoint(SWITCH_1, flowPathA, flowPathB);
assertEquals(new SwitchId(1), result);
}
use of org.openkilda.pce.PathComputer in project open-kilda by telstra.
the class MaxLatencyPathComputationStrategyBaseTest method nonGreedyMaxLatencyTest.
@Test
public void nonGreedyMaxLatencyTest() throws Exception {
// non-greedy algorithm can't find the closest path to max-latency param
createNonGreedyMaxLatencyTopo();
Flow flow = Flow.builder().flowId("test flow").srcSwitch(getSwitchById("00:01")).srcPort(15).destSwitch(getSwitchById("00:06")).destPort(15).bandwidth(500).encapsulationType(FlowEncapsulationType.TRANSIT_VLAN).pathComputationStrategy(PathComputationStrategy.MAX_LATENCY).maxLatency(25L).build();
PathComputer pathComputer = pathComputerFactory.getPathComputer();
GetPathsResult path = pathComputer.getPath(flow);
assertNotNull(path);
// best path is A-D-B-C-F and has 4 segments and 24 latency but non-greedy algorithm can find only path A-D-E-F
// with 3 segments and total latency 20
assertEquals(path.getForward().getSegments().size(), 3);
}
Aggregations