use of org.openkilda.pce.GetPathsResult 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.GetPathsResult 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.GetPathsResult 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);
}
use of org.openkilda.pce.GetPathsResult in project open-kilda by telstra.
the class CostAndBandwidthPathComputationStrategyTest method shouldFindPathOverDiamondWithAllActiveLinksAndIgnoreBandwidth.
@Test
public void shouldFindPathOverDiamondWithAllActiveLinksAndIgnoreBandwidth() throws RecoverableException, UnroutableFlowException {
createDiamond(IslStatus.ACTIVE, IslStatus.ACTIVE, 10, 20, "05:", 1);
Switch srcSwitch1 = getSwitchById("05:01");
Switch destSwitch1 = getSwitchById("05:03");
Flow f1 = getTestFlowBuilder(srcSwitch1, destSwitch1).bandwidth(0).ignoreBandwidth(false).build();
PathComputer pathComputer = pathComputerFactory.getPathComputer();
GetPathsResult path = pathComputer.getPath(f1);
assertNotNull(path);
assertThat(path.getForward().getSegments(), Matchers.hasSize(1));
Switch srcSwitch2 = getSwitchById("05:01");
Switch destSwitch2 = getSwitchById("05:04");
Flow f2 = getTestFlowBuilder(srcSwitch2, destSwitch2).bandwidth(0).ignoreBandwidth(false).build();
path = pathComputer.getPath(f2);
assertNotNull(path);
assertThat(path.getForward().getSegments(), Matchers.hasSize(2));
assertEquals(new SwitchId("05:02"), path.getForward().getSegments().get(0).getDestSwitchId());
}
use of org.openkilda.pce.GetPathsResult in project open-kilda by telstra.
the class CostAndBandwidthPathComputationStrategyTest method shouldFindPathOverTriangleWithOneActiveRouteByCostAndBandwidth.
@Test
public void shouldFindPathOverTriangleWithOneActiveRouteByCostAndBandwidth() throws UnroutableFlowException, RecoverableException {
/*
* simple happy path test .. but lowest path is inactive
*/
createTriangleTopo(IslStatus.INACTIVE, 5, 20, "02:", 1);
Switch srcSwitch = getSwitchById("02:01");
Switch destSwitch = getSwitchById("02:02");
Flow f = getTestFlowBuilder(srcSwitch, destSwitch).build();
PathComputer pathComputer = pathComputerFactory.getPathComputer();
GetPathsResult path = pathComputer.getPath(f);
assertNotNull(path);
assertThat(path.getForward().getSegments(), Matchers.hasSize(2));
// ====> only difference is it should now have C as first hop .. since B is inactive
// chooses path C
assertEquals(new SwitchId("02:03"), path.getForward().getSegments().get(0).getDestSwitchId());
}
Aggregations