Search in sources :

Example 11 with PathComputer

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

the class CostPathComputationStrategyTest method shouldFindPathOverTriangleWithOneActiveRouteByCost.

@Test
public void shouldFindPathOverTriangleWithOneActiveRouteByCost() throws UnroutableFlowException, RecoverableException {
    /*
         * simple happy path test .. but lowest path is inactive
         */
    createTriangleTopo(IslStatus.INACTIVE, 5, 20, "02:", 1);
    Switch srcSwitch = getSwitchById("02:01");
    Switch destSwitch = getSwitchById("02:02");
    Flow f = new TestFlowBuilder().srcSwitch(srcSwitch).destSwitch(destSwitch).bandwidth(100).build();
    PathComputer pathComputer = pathComputerFactory.getPathComputer();
    GetPathsResult path = pathComputer.getPath(f);
    assertNotNull(path);
    assertThat(path.getForward().getSegments(), Matchers.hasSize(2));
    // ====> only difference is it should now have C as first hop .. since B is inactive
    // chooses path C
    assertEquals(new SwitchId("02:03"), path.getForward().getSegments().get(0).getDestSwitchId());
}
Also used : PathComputer(org.openkilda.pce.PathComputer) Switch(org.openkilda.model.Switch) SwitchId(org.openkilda.model.SwitchId) Flow(org.openkilda.model.Flow) GetPathsResult(org.openkilda.pce.GetPathsResult) Test(org.junit.Test)

Example 12 with PathComputer

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

the class CostPathComputationStrategyTest method shouldFindPathOverDiamondWithNoCostOnOneRoute.

@Test
public void shouldFindPathOverDiamondWithNoCostOnOneRoute() throws UnroutableFlowException, RecoverableException {
    /*
         * simple happy path test .. but pathB has no cost .. but still cheaper than pathC (test the default)
         */
    createDiamond(IslStatus.ACTIVE, IslStatus.ACTIVE, -1, 2000, "03:", 1);
    Switch srcSwitch = getSwitchById("03:01");
    Switch destSwitch = getSwitchById("03:04");
    Flow f = new TestFlowBuilder().srcSwitch(srcSwitch).destSwitch(destSwitch).bandwidth(100).build();
    PathComputer pathComputer = pathComputerFactory.getPathComputer();
    GetPathsResult path = pathComputer.getPath(f);
    assertNotNull(path);
    assertThat(path.getForward().getSegments(), Matchers.hasSize(2));
    // ====> Should choose B .. because default cost (700) cheaper than 2000
    // chooses path B
    assertEquals(new SwitchId("03:02"), path.getForward().getSegments().get(0).getDestSwitchId());
}
Also used : PathComputer(org.openkilda.pce.PathComputer) Switch(org.openkilda.model.Switch) SwitchId(org.openkilda.model.SwitchId) Flow(org.openkilda.model.Flow) GetPathsResult(org.openkilda.pce.GetPathsResult) Test(org.junit.Test)

Example 13 with PathComputer

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

the class LatencyPathComputationStrategyBaseTest method shouldFindPathOverDiamondWithNoLatencyOnOneRoute.

@Test
public void shouldFindPathOverDiamondWithNoLatencyOnOneRoute() throws UnroutableFlowException, RecoverableException {
    /*
         * path B has no latency, path C has latency greater then default value
         */
    createDiamond(IslStatus.ACTIVE, IslStatus.ACTIVE, 0L, 1_000_000_000L);
    Switch srcSwitch = getSwitchById("00:01");
    Switch destSwitch = getSwitchById("00:04");
    Flow flow = new TestFlowBuilder().srcSwitch(srcSwitch).destSwitch(destSwitch).bandwidth(100).pathComputationStrategy(PathComputationStrategy.LATENCY).build();
    PathComputer pathComputer = pathComputerFactory.getPathComputer();
    GetPathsResult path = pathComputer.getPath(flow);
    assertNotNull(path);
    assertThat(path.getForward().getSegments(), Matchers.hasSize(2));
    // should choose B because default latency (500_000_000) is less then A-C latency (1_000_000_000)
    assertEquals(new SwitchId("00:02"), path.getForward().getSegments().get(0).getDestSwitchId());
}
Also used : PathComputer(org.openkilda.pce.PathComputer) Switch(org.openkilda.model.Switch) SwitchId(org.openkilda.model.SwitchId) Flow(org.openkilda.model.Flow) GetPathsResult(org.openkilda.pce.GetPathsResult) Test(org.junit.Test)

Example 14 with PathComputer

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

the class LatencyPathComputationStrategyBaseTest method shouldFailToFindOverDiamondWithNoActiveRoutes.

@Test
public void shouldFailToFindOverDiamondWithNoActiveRoutes() throws UnroutableFlowException, RecoverableException {
    createDiamond(IslStatus.INACTIVE, IslStatus.INACTIVE, 100L, 1000L);
    Switch srcSwitch = getSwitchById("00:01");
    Switch destSwitch = getSwitchById("00:04");
    Flow flow = new TestFlowBuilder().srcSwitch(srcSwitch).destSwitch(destSwitch).bandwidth(100).pathComputationStrategy(PathComputationStrategy.LATENCY).build();
    thrown.expect(UnroutableFlowException.class);
    PathComputer pathComputer = pathComputerFactory.getPathComputer();
    pathComputer.getPath(flow);
}
Also used : PathComputer(org.openkilda.pce.PathComputer) Switch(org.openkilda.model.Switch) Flow(org.openkilda.model.Flow) Test(org.junit.Test)

Example 15 with PathComputer

use of org.openkilda.pce.PathComputer 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)

Aggregations

PathComputer (org.openkilda.pce.PathComputer)56 Test (org.junit.Test)46 Flow (org.openkilda.model.Flow)45 GetPathsResult (org.openkilda.pce.GetPathsResult)39 SwitchId (org.openkilda.model.SwitchId)33 Switch (org.openkilda.model.Switch)27 InMemoryGraphBasedTest (org.openkilda.persistence.inmemory.InMemoryGraphBasedTest)8 FlowPath (org.openkilda.model.FlowPath)7 AvailableNetworkFactory (org.openkilda.pce.AvailableNetworkFactory)7 PathComputerFactory (org.openkilda.pce.PathComputerFactory)7 FlowResourcesManager (org.openkilda.wfm.share.flow.resources.FlowResourcesManager)7 BestWeightAndShortestPathFinder (org.openkilda.pce.finder.BestWeightAndShortestPathFinder)6 PathSegment (org.openkilda.model.PathSegment)4 Segment (org.openkilda.pce.Path.Segment)4 PathId (org.openkilda.model.PathId)3 RuleManager (org.openkilda.rulemanager.RuleManager)3 RuleManagerImpl (org.openkilda.rulemanager.RuleManagerImpl)3 Isl (org.openkilda.model.Isl)2 FlowCreateService (org.openkilda.wfm.topology.flowhs.service.FlowCreateService)2 FlowRerouteService (org.openkilda.wfm.topology.flowhs.service.FlowRerouteService)2