Search in sources :

Example 46 with PathComputer

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

the class LatencyPathComputationStrategyBaseTest method shouldFindPathOverDiamondWithAllActiveLinksByLatency.

@Test
public void shouldFindPathOverDiamondWithAllActiveLinksByLatency() throws UnroutableFlowException, RecoverableException {
    createDiamond(IslStatus.ACTIVE, IslStatus.ACTIVE, 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();
    PathComputer pathComputer = pathComputerFactory.getPathComputer();
    GetPathsResult path = pathComputer.getPath(flow);
    assertNotNull(path);
    assertThat(path.getForward().getSegments(), Matchers.hasSize(2));
    // should choose path B because it has lower latency
    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 47 with PathComputer

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

the class LatencyPathComputationStrategyBaseTest method shouldFindPathOverDiamondWithOneActiveRouteByLatency.

@Test
public void shouldFindPathOverDiamondWithOneActiveRouteByLatency() throws UnroutableFlowException, RecoverableException {
    createDiamond(IslStatus.INACTIVE, IslStatus.ACTIVE, 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();
    PathComputer pathComputer = pathComputerFactory.getPathComputer();
    GetPathsResult path = pathComputer.getPath(flow);
    assertNotNull(path);
    assertThat(path.getForward().getSegments(), Matchers.hasSize(2));
    // should have switch C as first hop since B is inactive
    assertEquals(new SwitchId("00: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 48 with PathComputer

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

the class LatencyPathComputationStrategyBaseTest method shouldFindDiversePath.

@Test
public void shouldFindDiversePath() throws RecoverableException, UnroutableFlowException {
    createDiamondWithDiversity();
    Flow flow = Flow.builder().flowId("new-flow").diverseGroupId("diverse").bandwidth(10).srcSwitch(getSwitchById("00:0A")).destSwitch(getSwitchById("00:0D")).encapsulationType(FlowEncapsulationType.TRANSIT_VLAN).pathComputationStrategy(PathComputationStrategy.LATENCY).build();
    PathComputer pathComputer = pathComputerFactory.getPathComputer();
    GetPathsResult diversePath = pathComputer.getPath(flow);
    diversePath.getForward().getSegments().forEach(segment -> {
        assertNotEquals(new SwitchId("00:0B"), segment.getSrcSwitchId());
        assertNotEquals(new SwitchId("00:0B"), segment.getDestSwitchId());
    });
}
Also used : PathComputer(org.openkilda.pce.PathComputer) SwitchId(org.openkilda.model.SwitchId) Flow(org.openkilda.model.Flow) GetPathsResult(org.openkilda.pce.GetPathsResult) Test(org.junit.Test)

Example 49 with PathComputer

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

the class LatencyPathComputationStrategyBaseTest method shouldFindPathOverDiamondWithUnstableIslByLatency.

@Test
public void shouldFindPathOverDiamondWithUnstableIslByLatency() throws UnroutableFlowException, RecoverableException {
    createDiamond(IslStatus.ACTIVE, IslStatus.ACTIVE, 100L, 1000L);
    Switch srcSwitch = getSwitchById("00:01");
    Switch destSwitch = getSwitchById("00:04");
    Isl linkAB = islRepository.findBySrcSwitch(srcSwitch.getSwitchId()).stream().filter(isl -> isl.getDestSwitchId().equals(new SwitchId("00:02"))).findAny().orElseThrow(() -> new IllegalStateException("Link A-B not found"));
    linkAB.setTimeUnstable(Instant.now());
    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 now have C as first hop since A - B link is unstable
    assertEquals(new SwitchId("00:03"), path.getForward().getSegments().get(0).getDestSwitchId());
}
Also used : Isl(org.openkilda.model.Isl) 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 50 with PathComputer

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

the class LatencyPathComputationStrategyBaseTest method shouldFailToFindOverIslandsWithAllActiveLinks.

@Test
public void shouldFailToFindOverIslandsWithAllActiveLinks() throws RecoverableException, UnroutableFlowException {
    createDiamond(IslStatus.ACTIVE, IslStatus.ACTIVE, 10, 20, "00:", 1);
    createDiamond(IslStatus.ACTIVE, IslStatus.ACTIVE, 10, 20, "00:", 6);
    Switch srcSwitch = getSwitchById("00:01");
    Switch destSwitch = getSwitchById("00:06");
    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)

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