use of org.openkilda.pce.model.FindPathResult in project open-kilda by telstra.
the class BestWeightAndShortestPathFinderTest method shouldReturnThePathBottomClosestToBackUpMaxWeight.
/**
* Ensure system picks path closest to backUpMaxWeight from the bottom. Omit closest path from the top even if it is
* closer than the one from the bottom
*/
@Test
public void shouldReturnThePathBottomClosestToBackUpMaxWeight() throws UnroutableFlowException {
// a path with backUpMaxWeight 200
FindPathResult pathResult = findThePathBottomClosestToMaxWeight(100L, 200L);
assertTrue(pathResult.isBackUpPathComputationWayUsed());
}
use of org.openkilda.pce.model.FindPathResult in project open-kilda by telstra.
the class BestWeightAndShortestPathFinderTest method findPathThrowMoreExpensiveWayMaxLatencyStrategy.
private FindPathResult findPathThrowMoreExpensiveWayMaxLatencyStrategy(long maxWeight, long backUpMaxWeight) throws UnroutableFlowException {
// Reverse way is more expansive then forward, so we must choose this path
// and the sequence of switches must match the forward path.
AvailableNetwork network = buildNetworkWithCostInReversePathBiggerThanForward();
BestWeightAndShortestPathFinder pathFinder = new BestWeightAndShortestPathFinder(ALLOWED_DEPTH);
FindPathResult pathResult = pathFinder.findPathWithWeightCloseToMaxWeight(network, SWITCH_ID_1, SWITCH_ID_5, WEIGHT_FUNCTION, maxWeight, backUpMaxWeight);
Pair<List<Edge>, List<Edge>> paths = pathResult.getFoundPath();
List<Edge> fpath = paths.getLeft();
assertThat(fpath, Matchers.hasSize(3));
assertEquals(SWITCH_ID_1, fpath.get(0).getSrcSwitch().getSwitchId());
assertEquals(SWITCH_ID_3, fpath.get(2).getSrcSwitch().getSwitchId());
List<Edge> rpath = paths.getRight();
assertThat(rpath, Matchers.hasSize(3));
assertEquals(SWITCH_ID_5, fpath.get(2).getDestSwitch().getSwitchId());
assertEquals(SWITCH_ID_3, rpath.get(0).getDestSwitch().getSwitchId());
return pathResult;
}
use of org.openkilda.pce.model.FindPathResult in project open-kilda by telstra.
the class BestWeightAndShortestPathFinderTest method findThePathBottomClosestToMaxWeight.
private FindPathResult findThePathBottomClosestToMaxWeight(long maxWeight, long backUpMaxWeight) throws UnroutableFlowException {
// given 3 paths that cost: 198, 200, 201
AvailableNetwork network = buildThreePathsNetwork();
BestWeightAndShortestPathFinder pathFinder = new BestWeightAndShortestPathFinder(ALLOWED_DEPTH);
// when: request a path with maxWeight 200
FindPathResult pathResult = pathFinder.findPathWithWeightCloseToMaxWeight(network, SWITCH_ID_1, SWITCH_ID_5, WEIGHT_FUNCTION, maxWeight, backUpMaxWeight);
Pair<List<Edge>, List<Edge>> pairPath = pathResult.getFoundPath();
// then: system picks 198 path
List<SwitchId> forwardSwitches = getInvolvedSwitches(pairPath.getLeft());
assertThat(forwardSwitches, equalTo(Arrays.asList(SWITCH_ID_1, SWITCH_ID_2, SWITCH_ID_5)));
assertThat(getInvolvedSwitches(pairPath.getRight()), equalTo(Lists.reverse(forwardSwitches)));
return pathResult;
}
use of org.openkilda.pce.model.FindPathResult in project open-kilda by telstra.
the class BestWeightAndShortestPathFinderTest method shouldReturnThePathClosestToBackUpMaxWeight.
/**
* System picks path closest to maxWeightTier2. Omit too cheap path and maxWeight path,
* omit equal to backUpMaxWeight path
*/
@Test
public void shouldReturnThePathClosestToBackUpMaxWeight() throws UnroutableFlowException {
// a path with backUpMaxWeight 201
FindPathResult pathResult = findThePathClosestToMaxWeight(100L, 201L);
assertTrue(pathResult.isBackUpPathComputationWayUsed());
}
use of org.openkilda.pce.model.FindPathResult in project open-kilda by telstra.
the class BestWeightAndShortestPathFinderTest method maxWeightAccountsForBothLinkDirections.
/**
* Check that we take into account both forward-way and reverse-way links when calculating path using MAX_LATENCY
* strategy when maxWeight satisfies the path.
*/
@Test
public void maxWeightAccountsForBothLinkDirections() throws UnroutableFlowException {
// a path with maxWeight 103
FindPathResult pathResult = maxWeightStratAccountsForBothLinkDirections(103L, Long.MAX_VALUE);
assertFalse(pathResult.isBackUpPathComputationWayUsed());
}
Aggregations