Search in sources :

Example 31 with GetPathsResult

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

the class CostAndBandwidthPathComputationStrategyTest method shouldFindTheSameDiversePath.

@Test
public void shouldFindTheSameDiversePath() throws RecoverableException, UnroutableFlowException {
    createDiamondWithDiversity();
    Flow flow = Flow.builder().flowId("new-flow").diverseGroupId("diverse").bandwidth(10).srcSwitch(getSwitchById("00:0A")).srcPort(10).destSwitch(getSwitchById("00:0D")).destPort(10).encapsulationType(FlowEncapsulationType.TRANSIT_VLAN).pathComputationStrategy(PathComputationStrategy.COST).build();
    PathComputer pathComputer = pathComputerFactory.getPathComputer();
    GetPathsResult diversePath = pathComputer.getPath(flow);
    FlowPath forwardPath = FlowPath.builder().pathId(new PathId(UUID.randomUUID().toString())).srcSwitch(flow.getSrcSwitch()).destSwitch(flow.getDestSwitch()).bandwidth(flow.getBandwidth()).segments(new ArrayList<>()).build();
    addPathSegments(forwardPath, diversePath.getForward());
    flow.setForwardPath(forwardPath);
    FlowPath reversePath = FlowPath.builder().pathId(new PathId(UUID.randomUUID().toString())).srcSwitch(flow.getDestSwitch()).destSwitch(flow.getSrcSwitch()).bandwidth(flow.getBandwidth()).segments(new ArrayList<>()).build();
    addPathSegments(reversePath, diversePath.getReverse());
    flow.setReversePath(reversePath);
    flowRepository.add(flow);
    GetPathsResult path2 = pathComputer.getPath(flow, flow.getPathIds());
    assertEquals(diversePath, path2);
}
Also used : PathId(org.openkilda.model.PathId) PathComputer(org.openkilda.pce.PathComputer) ArrayList(java.util.ArrayList) FlowPath(org.openkilda.model.FlowPath) Flow(org.openkilda.model.Flow) GetPathsResult(org.openkilda.pce.GetPathsResult) Test(org.junit.Test)

Example 32 with GetPathsResult

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

the class CostAndBandwidthPathComputationStrategyTest method shouldFindPathOverDiamondWithAllActiveLinksByCostAndBandwidth.

@Test
public void shouldFindPathOverDiamondWithAllActiveLinksByCostAndBandwidth() throws UnroutableFlowException, RecoverableException {
    /*
         * simple happy path test .. everything has cost
         */
    createDiamond(IslStatus.ACTIVE, IslStatus.ACTIVE, 10, 20, "00:", 1);
    Switch srcSwitch = getSwitchById("00:01");
    Switch destSwitch = getSwitchById("00:04");
    Flow f = getTestFlowBuilder(srcSwitch, destSwitch).build();
    PathComputer pathComputer = pathComputerFactory.getPathComputer();
    GetPathsResult path = pathComputer.getPath(f);
    assertNotNull(path);
    assertThat(path.getForward().getSegments(), Matchers.hasSize(2));
    // chooses path B
    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 33 with GetPathsResult

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

the class CostAndBandwidthPathComputationStrategyTest 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.COST).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 34 with GetPathsResult

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

the class CostAndBandwidthPathComputationStrategyTest method shouldFindPathWithSameCostAndMinAvailableBandwidth.

@Test
public void shouldFindPathWithSameCostAndMinAvailableBandwidth() throws RecoverableException, UnroutableFlowException {
    createDiamondWithDifferentAvailableBandwidth();
    Switch srcSwitch = getSwitchById("00:01");
    Switch destSwitch = getSwitchById("00:04");
    Flow f = getTestFlowBuilder(srcSwitch, destSwitch).build();
    PathComputer pathComputer = pathComputerFactory.getPathComputer();
    GetPathsResult path = pathComputer.getPath(f);
    assertNotNull(path);
    assertThat(path.getForward().getSegments(), Matchers.hasSize(2));
    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 35 with GetPathsResult

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

the class InMemoryPathComputerBaseTest method affinityPathShouldPreferIslsUsedByMainPath.

void affinityPathShouldPreferIslsUsedByMainPath(PathComputationStrategy pathComputationStrategy) throws Exception {
    createTestTopologyForAffinityTesting();
    Flow flow = Flow.builder().flowId("new-flow").affinityGroupId(TEST_FLOW_ID).bandwidth(10).srcSwitch(getSwitchById("00:0E")).destSwitch(getSwitchById("00:0F")).encapsulationType(FlowEncapsulationType.TRANSIT_VLAN).pathComputationStrategy(pathComputationStrategy).build();
    PathComputer pathComputer = pathComputerFactory.getPathComputer();
    GetPathsResult affinityPath = pathComputer.getPath(flow);
    List<Segment> segments = affinityPath.getForward().getSegments();
    assertEquals(3, segments.size());
    assertEquals(new SwitchId("00:0E"), segments.get(0).getSrcSwitchId());
    assertEquals(new SwitchId("00:0A"), segments.get(1).getSrcSwitchId());
    assertEquals(new SwitchId("00:0B"), segments.get(2).getSrcSwitchId());
    assertEquals(new SwitchId("00:0A"), segments.get(0).getDestSwitchId());
    assertEquals(new SwitchId("00:0B"), segments.get(1).getDestSwitchId());
    assertEquals(new SwitchId("00:0F"), segments.get(2).getDestSwitchId());
}
Also used : PathComputer(org.openkilda.pce.PathComputer) SwitchId(org.openkilda.model.SwitchId) Segment(org.openkilda.pce.Path.Segment) PathSegment(org.openkilda.model.PathSegment) Flow(org.openkilda.model.Flow) GetPathsResult(org.openkilda.pce.GetPathsResult)

Aggregations

Flow (org.openkilda.model.Flow)50 GetPathsResult (org.openkilda.pce.GetPathsResult)50 PathComputer (org.openkilda.pce.PathComputer)42 Test (org.junit.Test)40 SwitchId (org.openkilda.model.SwitchId)30 Switch (org.openkilda.model.Switch)22 FlowPath (org.openkilda.model.FlowPath)8 PathId (org.openkilda.model.PathId)8 FlowResources (org.openkilda.wfm.share.flow.resources.FlowResources)7 PathSegment (org.openkilda.model.PathSegment)5 BestWeightAndShortestPathFinder (org.openkilda.pce.finder.BestWeightAndShortestPathFinder)5 FlowPathPair (org.openkilda.wfm.topology.flow.model.FlowPathPair)5 ArrayList (java.util.ArrayList)4 Segment (org.openkilda.pce.Path.Segment)4 UnroutableFlowException (org.openkilda.pce.exception.UnroutableFlowException)4 ResourceAllocationException (org.openkilda.wfm.share.flow.resources.ResourceAllocationException)4 List (java.util.List)3 Predicate (java.util.function.Predicate)3 Slf4j (lombok.extern.slf4j.Slf4j)3 FlowSegmentRequest (org.openkilda.floodlight.api.request.FlowSegmentRequest)3