Search in sources :

Example 6 with AvailableNetwork

use of org.openkilda.pce.impl.AvailableNetwork in project open-kilda by telstra.

the class BestWeightAndShortestPathFinderTest method failToFindASwitch.

@Test(expected = UnroutableFlowException.class)
public void failToFindASwitch() throws UnroutableFlowException {
    AvailableNetwork network = buildTestNetwork();
    SwitchId srcDpid = new SwitchId("00:00:00:00:00:00:00:ff");
    BestWeightAndShortestPathFinder pathFinder = new BestWeightAndShortestPathFinder(ALLOWED_DEPTH);
    pathFinder.findPathWithMinWeight(network, srcDpid, SWITCH_ID_F, WEIGHT_FUNCTION);
}
Also used : SwitchId(org.openkilda.model.SwitchId) AvailableNetwork(org.openkilda.pce.impl.AvailableNetwork) Test(org.junit.Test)

Example 7 with AvailableNetwork

use of org.openkilda.pce.impl.AvailableNetwork in project open-kilda by telstra.

the class BestWeightAndShortestPathFinderTest method testForwardAndBackwardPathsEquality.

@Test
public void testForwardAndBackwardPathsEquality() throws UnroutableFlowException {
    AvailableNetwork network = buildEqualCostsNetwork();
    BestWeightAndShortestPathFinder pathFinder = new BestWeightAndShortestPathFinder(ALLOWED_DEPTH);
    Pair<List<Edge>, List<Edge>> paths = pathFinder.findPathWithMinWeight(network, SWITCH_ID_1, SWITCH_ID_5, WEIGHT_FUNCTION).getFoundPath();
    List<SwitchId> forwardSwitchPath = getSwitchIdsFlowPath(paths.getLeft());
    List<SwitchId> backwardSwitchPath = Lists.reverse(getSwitchIdsFlowPath(paths.getRight()));
    assertEquals(forwardSwitchPath, backwardSwitchPath);
}
Also used : ArrayList(java.util.ArrayList) List(java.util.List) SwitchId(org.openkilda.model.SwitchId) AvailableNetwork(org.openkilda.pce.impl.AvailableNetwork) Test(org.junit.Test)

Example 8 with AvailableNetwork

use of org.openkilda.pce.impl.AvailableNetwork in project open-kilda by telstra.

the class BestWeightAndShortestPathFinderTest method shouldChooseDeeperOverCheaperMaxWeightStrategy.

@Test
public void shouldChooseDeeperOverCheaperMaxWeightStrategy() throws UnroutableFlowException {
    AvailableNetwork network = buildLongAndExpensivePathsNetwork();
    BestWeightAndShortestPathFinder pathFinder = new BestWeightAndShortestPathFinder(4);
    Pair<List<Edge>, List<Edge>> pairPath = pathFinder.findPathWithWeightCloseToMaxWeight(network, SWITCH_ID_1, SWITCH_ID_3, WEIGHT_FUNCTION, Long.MAX_VALUE, Long.MAX_VALUE).getFoundPath();
    List<Edge> fpath = pairPath.getLeft();
    assertThat(fpath, Matchers.hasSize(4));
    assertEquals(SWITCH_ID_5, fpath.get(3).getSrcSwitch().getSwitchId());
    List<Edge> rpath = pairPath.getRight();
    assertThat(rpath, Matchers.hasSize(4));
    assertEquals(SWITCH_ID_5, rpath.get(0).getDestSwitch().getSwitchId());
}
Also used : ArrayList(java.util.ArrayList) List(java.util.List) AvailableNetwork(org.openkilda.pce.impl.AvailableNetwork) Edge(org.openkilda.pce.model.Edge) Test(org.junit.Test)

Example 9 with AvailableNetwork

use of org.openkilda.pce.impl.AvailableNetwork in project open-kilda by telstra.

the class BestWeightAndShortestPathFinderTest method shouldFailWhenPathIsLongerThenAllowedDepth.

@Test(expected = UnroutableFlowException.class)
public void shouldFailWhenPathIsLongerThenAllowedDepth() throws UnroutableFlowException {
    AvailableNetwork network = buildTestNetwork();
    BestWeightAndShortestPathFinder pathFinder = new BestWeightAndShortestPathFinder(1);
    pathFinder.findPathWithMinWeight(network, SWITCH_ID_D, SWITCH_ID_F, WEIGHT_FUNCTION);
}
Also used : AvailableNetwork(org.openkilda.pce.impl.AvailableNetwork) Test(org.junit.Test)

Example 10 with AvailableNetwork

use of org.openkilda.pce.impl.AvailableNetwork in project open-kilda by telstra.

the class BestWeightAndShortestPathFinderTest method buildNetworkWithCostInReversePathBiggerThanForward.

private AvailableNetwork buildNetworkWithCostInReversePathBiggerThanForward() {
    /*
         *   Topology:
         *
         *   SW1---SW2---SW4
         *          |     |
         *         SW3---SW5
         *
         *   SW3---SW5 isl has lower cost then reverse one.
         */
    AvailableNetwork network = new AvailableNetwork();
    addBidirectionalLink(network, SWITCH_ID_1, SWITCH_ID_2, 1, 2, 100);
    addBidirectionalLink(network, SWITCH_ID_2, SWITCH_ID_4, 3, 4, 100);
    addBidirectionalLink(network, SWITCH_ID_2, SWITCH_ID_3, 5, 68, 100);
    addLink(network, SWITCH_ID_3, SWITCH_ID_5, 7, 8, 10, 100, false, false);
    addLink(network, SWITCH_ID_5, SWITCH_ID_3, 8, 7, 10000, 100, false, false);
    addLink(network, SWITCH_ID_4, SWITCH_ID_5, 9, 10, 100, 100, false, false);
    addLink(network, SWITCH_ID_5, SWITCH_ID_4, 10, 9, 100, 100, false, false);
    return network;
}
Also used : AvailableNetwork(org.openkilda.pce.impl.AvailableNetwork)

Aggregations

AvailableNetwork (org.openkilda.pce.impl.AvailableNetwork)43 Test (org.junit.Test)28 ArrayList (java.util.ArrayList)24 List (java.util.List)23 Edge (org.openkilda.pce.model.Edge)13 SwitchId (org.openkilda.model.SwitchId)9 Flow (org.openkilda.model.Flow)7 IslImmutableView (org.openkilda.persistence.repositories.IslRepository.IslImmutableView)7 FindPathResult (org.openkilda.pce.model.FindPathResult)6 FlowPath (org.openkilda.model.FlowPath)3 PathId (org.openkilda.model.PathId)3 Collectors (java.util.stream.Collectors)2 Lists (com.google.common.collect.Lists)1 Arrays (java.util.Arrays)1 Collection (java.util.Collection)1 Objects (java.util.Objects)1 IntStream (java.util.stream.IntStream)1 Slf4j (lombok.extern.slf4j.Slf4j)1 Pair (org.apache.commons.lang3.tuple.Pair)1 CoreMatchers.equalTo (org.hamcrest.CoreMatchers.equalTo)1