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);
}
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);
}
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());
}
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);
}
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;
}
Aggregations