Search in sources :

Example 1 with BestWeightAndShortestPathFinder

use of org.openkilda.pce.finder.BestWeightAndShortestPathFinder in project open-kilda by telstra.

the class LatencyPathComputationStrategyBaseTest method shouldSetBackUpFlagWhenPathHasLatencyGreaterThanMaxLatency.

@Test
public void shouldSetBackUpFlagWhenPathHasLatencyGreaterThanMaxLatency() throws RecoverableException, UnroutableFlowException {
    createTriangleTopo(IslStatus.ACTIVE, 100, 100, "00:", 1);
    // when: request a flow with LATENCY strategy and 'max-latency' is lower than found path
    Flow flow = Flow.builder().flowId("test flow").srcSwitch(getSwitchById("00:01")).srcPort(15).destSwitch(getSwitchById("00:02")).destPort(15).bandwidth(500).encapsulationType(FlowEncapsulationType.TRANSIT_VLAN).pathComputationStrategy(PathComputationStrategy.LATENCY).maxLatency(50L).maxLatencyTier2(300L).build();
    PathComputer pathComputer = new InMemoryPathComputer(availableNetworkFactory, new BestWeightAndShortestPathFinder(5), config);
    GetPathsResult pathsResult = pathComputer.getPath(flow);
    // then: system returns a path built with backUpPathComputationWayUsed flag
    assertTrue(pathsResult.isBackUpPathComputationWayUsed());
    assertThat(pathsResult.getForward().getSegments().get(1).getSrcSwitchId(), equalTo(new SwitchId("00:03")));
    assertThat(pathsResult.getReverse().getSegments().get(1).getSrcSwitchId(), equalTo(new SwitchId("00:03")));
}
Also used : PathComputer(org.openkilda.pce.PathComputer) BestWeightAndShortestPathFinder(org.openkilda.pce.finder.BestWeightAndShortestPathFinder) SwitchId(org.openkilda.model.SwitchId) Flow(org.openkilda.model.Flow) GetPathsResult(org.openkilda.pce.GetPathsResult) Test(org.junit.Test)

Example 2 with BestWeightAndShortestPathFinder

use of org.openkilda.pce.finder.BestWeightAndShortestPathFinder in project open-kilda by telstra.

the class MaxLatencyPathComputationStrategyBaseTest method shouldUseBackUpWeightWhenNoPathFoundInMaxLatencyStrat.

@Test
public void shouldUseBackUpWeightWhenNoPathFoundInMaxLatencyStrat() throws RecoverableException, UnroutableFlowException {
    // 1 - 2 - 4
    // + 3 +
    // path 1>2>4 has less latency than 1>3>4
    createDiamond(IslStatus.ACTIVE, IslStatus.ACTIVE, 100, 100, "00:", 1, 100, 101);
    // when: request a flow with MAX_LATENCY strategy and 'max-latency' is not enough to build a path
    Flow flow = Flow.builder().flowId("test flow").srcSwitch(getSwitchById("00:01")).srcPort(15).destSwitch(getSwitchById("00:04")).destPort(15).bandwidth(500).encapsulationType(FlowEncapsulationType.TRANSIT_VLAN).pathComputationStrategy(PathComputationStrategy.MAX_LATENCY).maxLatency(100L).maxLatencyTier2(300L).build();
    PathComputer pathComputer = new InMemoryPathComputer(availableNetworkFactory, new BestWeightAndShortestPathFinder(5), config);
    GetPathsResult pathsResult = pathComputer.getPath(flow);
    // then: system returns a path built by 'max_latency_tier2'
    assertTrue(pathsResult.isBackUpPathComputationWayUsed());
    assertThat(pathsResult.getForward().getSegments().get(1).getSrcSwitchId(), equalTo(new SwitchId("00:03")));
    assertThat(pathsResult.getReverse().getSegments().get(1).getSrcSwitchId(), equalTo(new SwitchId("00:03")));
}
Also used : PathComputer(org.openkilda.pce.PathComputer) BestWeightAndShortestPathFinder(org.openkilda.pce.finder.BestWeightAndShortestPathFinder) SwitchId(org.openkilda.model.SwitchId) Flow(org.openkilda.model.Flow) GetPathsResult(org.openkilda.pce.GetPathsResult) Test(org.junit.Test)

Example 3 with BestWeightAndShortestPathFinder

use of org.openkilda.pce.finder.BestWeightAndShortestPathFinder in project open-kilda by telstra.

the class InMemoryPathComputerBaseTest method shouldThrowPathHasNoSegmentsWhenSegmentsIsNull.

@Test
public void shouldThrowPathHasNoSegmentsWhenSegmentsIsNull() {
    FlowPath flowPathA = FlowPath.builder().pathId(new PathId("flow_path_a")).srcSwitch(Switch.builder().switchId(new SwitchId(1)).build()).destSwitch(Switch.builder().switchId(new SwitchId(3)).build()).build();
    FlowPath flowPathB = buildFlowPath("flow_path_b", 1, 2, 4, 5);
    InMemoryPathComputer pathComputer = new InMemoryPathComputer(availableNetworkFactory, new BestWeightAndShortestPathFinder(config.getMaxAllowedDepth()), config);
    Exception exception = assertThrows(IllegalArgumentException.class, () -> pathComputer.convertFlowPathsToSwitchLists(SWITCH_1, flowPathA, flowPathB));
    assertEquals("The path 'flow_path_a' has no path segments", exception.getMessage());
}
Also used : PathId(org.openkilda.model.PathId) BestWeightAndShortestPathFinder(org.openkilda.pce.finder.BestWeightAndShortestPathFinder) SwitchId(org.openkilda.model.SwitchId) FlowPath(org.openkilda.model.FlowPath) UnroutableFlowException(org.openkilda.pce.exception.UnroutableFlowException) RecoverableException(org.openkilda.pce.exception.RecoverableException) ExpectedException(org.junit.rules.ExpectedException) InMemoryGraphBasedTest(org.openkilda.persistence.inmemory.InMemoryGraphBasedTest) Test(org.junit.Test)

Example 4 with BestWeightAndShortestPathFinder

use of org.openkilda.pce.finder.BestWeightAndShortestPathFinder in project open-kilda by telstra.

the class MaxLatencyPathComputationStrategyBaseTest method maxLatencyStratWithNullLatency.

/**
 * Special case: flow with MAX_LATENCY strategy and 'max-latency' being unset(null) should pick path with least
 * latency.
 */
@Test
public void maxLatencyStratWithNullLatency() throws RecoverableException, UnroutableFlowException {
    // 1 - 2 - 4
    // + 3 +
    // path 1>2>4 has less latency than 1>3>4
    createDiamond(IslStatus.ACTIVE, IslStatus.ACTIVE, 100, 100, "00:", 1, 100, 101);
    // when: request a flow with MAX_LATENCY strategy and 'max-latency' set to 0
    Flow flow = Flow.builder().flowId("test flow").srcSwitch(getSwitchById("00:01")).srcPort(15).destSwitch(getSwitchById("00:04")).destPort(15).bandwidth(500).encapsulationType(FlowEncapsulationType.TRANSIT_VLAN).pathComputationStrategy(PathComputationStrategy.MAX_LATENCY).build();
    PathComputer pathComputer = new InMemoryPathComputer(availableNetworkFactory, new BestWeightAndShortestPathFinder(5), config);
    GetPathsResult pathsResult = pathComputer.getPath(flow);
    // then: system returns a path with least weight
    assertFalse(pathsResult.isBackUpPathComputationWayUsed());
    assertThat(pathsResult.getForward().getSegments().get(1).getSrcSwitchId(), equalTo(new SwitchId("00:02")));
    assertThat(pathsResult.getReverse().getSegments().get(1).getSrcSwitchId(), equalTo(new SwitchId("00:02")));
}
Also used : PathComputer(org.openkilda.pce.PathComputer) BestWeightAndShortestPathFinder(org.openkilda.pce.finder.BestWeightAndShortestPathFinder) SwitchId(org.openkilda.model.SwitchId) Flow(org.openkilda.model.Flow) GetPathsResult(org.openkilda.pce.GetPathsResult) Test(org.junit.Test)

Example 5 with BestWeightAndShortestPathFinder

use of org.openkilda.pce.finder.BestWeightAndShortestPathFinder in project open-kilda by telstra.

the class LatencyPathComputationStrategyBaseTest method shouldReturnEmptyPathWhenPathHasLatencyGreaterThanMaxLatencyTier2.

@Test
public void shouldReturnEmptyPathWhenPathHasLatencyGreaterThanMaxLatencyTier2() throws RecoverableException, UnroutableFlowException {
    createTriangleTopo(IslStatus.ACTIVE, 100, 100, "00:", 1);
    // when: request a flow with LATENCY strategy and 'max-latency-tier-2' is lower than found path
    Flow flow = Flow.builder().flowId("test flow").srcSwitch(getSwitchById("00:01")).srcPort(15).destSwitch(getSwitchById("00:02")).destPort(15).bandwidth(500).encapsulationType(FlowEncapsulationType.TRANSIT_VLAN).pathComputationStrategy(PathComputationStrategy.LATENCY).maxLatency(50L).maxLatencyTier2(70L).build();
    PathComputer pathComputer = new InMemoryPathComputer(availableNetworkFactory, new BestWeightAndShortestPathFinder(5), config);
    // then: system can't find path
    thrown.expect(UnroutableFlowException.class);
    pathComputer.getPath(flow);
}
Also used : PathComputer(org.openkilda.pce.PathComputer) BestWeightAndShortestPathFinder(org.openkilda.pce.finder.BestWeightAndShortestPathFinder) Flow(org.openkilda.model.Flow) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)10 BestWeightAndShortestPathFinder (org.openkilda.pce.finder.BestWeightAndShortestPathFinder)10 SwitchId (org.openkilda.model.SwitchId)7 Flow (org.openkilda.model.Flow)6 PathComputer (org.openkilda.pce.PathComputer)6 GetPathsResult (org.openkilda.pce.GetPathsResult)5 InMemoryGraphBasedTest (org.openkilda.persistence.inmemory.InMemoryGraphBasedTest)5 FlowPath (org.openkilda.model.FlowPath)4 ExpectedException (org.junit.rules.ExpectedException)3 RecoverableException (org.openkilda.pce.exception.RecoverableException)3 UnroutableFlowException (org.openkilda.pce.exception.UnroutableFlowException)3 PathId (org.openkilda.model.PathId)2 ArrayList (java.util.ArrayList)1 LinkedList (java.util.LinkedList)1 Ignore (org.junit.Ignore)1 Switch (org.openkilda.model.Switch)1