Search in sources :

Example 1 with FindPathResult

use of org.openkilda.pce.model.FindPathResult in project open-kilda by telstra.

the class BestWeightAndShortestPathFinderTest method shouldAddIntermediateSwitchWeightOnceMaxWeightStrategyBackUpWay.

@Test
public void shouldAddIntermediateSwitchWeightOnceMaxWeightStrategyBackUpWay() throws UnroutableFlowException {
    // a path with backUpMaxWeight 201
    FindPathResult pathResult = addIntermediateSwitchWeightOnceMaxWeightStrategy(100L, 201L);
    assertTrue(pathResult.isBackUpPathComputationWayUsed());
}
Also used : FindPathResult(org.openkilda.pce.model.FindPathResult) Test(org.junit.Test)

Example 2 with FindPathResult

use of org.openkilda.pce.model.FindPathResult in project open-kilda by telstra.

the class BestWeightAndShortestPathFinderTest method shouldReturnThePathBottomClosestToMaxWeight.

/**
 * Ensure system picks path closest to maxWeight from the bottom. Omit closest path from the top even if it is
 * closer than the one from the bottom
 */
@Test
public void shouldReturnThePathBottomClosestToMaxWeight() throws UnroutableFlowException {
    // a path with maxWeight 200
    FindPathResult pathResult = findThePathBottomClosestToMaxWeight(200L, Long.MAX_VALUE);
    assertFalse(pathResult.isBackUpPathComputationWayUsed());
}
Also used : FindPathResult(org.openkilda.pce.model.FindPathResult) Test(org.junit.Test)

Example 3 with FindPathResult

use of org.openkilda.pce.model.FindPathResult in project open-kilda by telstra.

the class BestWeightAndShortestPathFinderTest method findThePathClosestToMaxWeight.

private FindPathResult findThePathClosestToMaxWeight(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 201
    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 200 path
    List<SwitchId> forwardSwitches = getInvolvedSwitches(pairPath.getLeft());
    assertThat(forwardSwitches, equalTo(Arrays.asList(SWITCH_ID_1, SWITCH_ID_3, SWITCH_ID_5)));
    assertThat(getInvolvedSwitches(pairPath.getRight()), equalTo(Lists.reverse(forwardSwitches)));
    return pathResult;
}
Also used : FindPathResult(org.openkilda.pce.model.FindPathResult) ArrayList(java.util.ArrayList) List(java.util.List) SwitchId(org.openkilda.model.SwitchId) AvailableNetwork(org.openkilda.pce.impl.AvailableNetwork)

Example 4 with FindPathResult

use of org.openkilda.pce.model.FindPathResult in project open-kilda by telstra.

the class BestWeightAndShortestPathFinderTest method shouldCreatePathThrowMoreExpensiveBackUpWayMaxLatencyStrategy.

@Test
public void shouldCreatePathThrowMoreExpensiveBackUpWayMaxLatencyStrategy() throws UnroutableFlowException {
    FindPathResult pathResult = findPathThrowMoreExpensiveWayMaxLatencyStrategy(100L, 10201L);
    assertTrue(pathResult.isBackUpPathComputationWayUsed());
}
Also used : FindPathResult(org.openkilda.pce.model.FindPathResult) Test(org.junit.Test)

Example 5 with FindPathResult

use of org.openkilda.pce.model.FindPathResult in project open-kilda by telstra.

the class BestWeightAndShortestPathFinderTest method shouldAddIntermediateSwitchWeightOnceMaxWeightStrategy.

@Test
public void shouldAddIntermediateSwitchWeightOnceMaxWeightStrategy() throws UnroutableFlowException {
    // a path with maxWeight 201
    FindPathResult pathResult = addIntermediateSwitchWeightOnceMaxWeightStrategy(201L, Long.MAX_VALUE);
    assertFalse(pathResult.isBackUpPathComputationWayUsed());
}
Also used : FindPathResult(org.openkilda.pce.model.FindPathResult) Test(org.junit.Test)

Aggregations

FindPathResult (org.openkilda.pce.model.FindPathResult)16 Test (org.junit.Test)10 ArrayList (java.util.ArrayList)5 List (java.util.List)5 AvailableNetwork (org.openkilda.pce.impl.AvailableNetwork)5 SwitchId (org.openkilda.model.SwitchId)4 UnroutableFlowException (org.openkilda.pce.exception.UnroutableFlowException)1 Edge (org.openkilda.pce.model.Edge)1 WeightFunction (org.openkilda.pce.model.WeightFunction)1