Search in sources :

Example 6 with GetPathsResult

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

the class CostAndBandwidthPathComputationStrategyTest method shouldFailToFindOverIslandsWithAllActiveLinksAndIgnoreBandwidth.

/**
 * Create a couple of islands .. try to find a path between them .. validate no path is returned, and that the
 * function completes in reasonable time ( < 10ms);
 */
@Test
public void shouldFailToFindOverIslandsWithAllActiveLinksAndIgnoreBandwidth() throws RecoverableException, UnroutableFlowException {
    createDiamond(IslStatus.ACTIVE, IslStatus.ACTIVE, 10, 20, "06:", 1);
    createDiamond(IslStatus.ACTIVE, IslStatus.ACTIVE, 10, 20, "07:", 1);
    Switch srcSwitch1 = getSwitchById("06:01");
    Switch destSwitch1 = getSwitchById("06:03");
    // THIS ONE SHOULD WORK
    Flow f1 = getTestFlowBuilder(srcSwitch1, destSwitch1).bandwidth(0).ignoreBandwidth(false).build();
    PathComputer pathComputer = pathComputerFactory.getPathComputer();
    GetPathsResult path = pathComputer.getPath(f1);
    assertNotNull(path);
    assertThat(path.getForward().getSegments(), Matchers.hasSize(1));
    Switch srcSwitch2 = getSwitchById("06:01");
    Switch destSwitch2 = getSwitchById("07:04");
    // THIS ONE SHOULD FAIL
    Flow f2 = getTestFlowBuilder(srcSwitch2, destSwitch2).bandwidth(0).ignoreBandwidth(false).build();
    thrown.expect(UnroutableFlowException.class);
    pathComputer.getPath(f2);
}
Also used : PathComputer(org.openkilda.pce.PathComputer) Switch(org.openkilda.model.Switch) Flow(org.openkilda.model.Flow) GetPathsResult(org.openkilda.pce.GetPathsResult) Test(org.junit.Test)

Example 7 with GetPathsResult

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

the class CostAndBandwidthPathComputationStrategyTest method shouldFindPathOverDiamondWithOneActiveRouteByCostAndBandwidth.

@Test
public void shouldFindPathOverDiamondWithOneActiveRouteByCostAndBandwidth() throws UnroutableFlowException, RecoverableException {
    createDiamond(IslStatus.INACTIVE, IslStatus.ACTIVE, 10, 20, "01:", 1);
    Switch srcSwitch = getSwitchById("01:01");
    Switch destSwitch = getSwitchById("01: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));
    // ====> only difference is it should now have C as first hop .. since B is inactive
    // chooses path C
    assertEquals(new SwitchId("01: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 8 with GetPathsResult

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

the class CostAndBandwidthPathComputationStrategyTest 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 = getTestFlowBuilder(srcSwitch, destSwitch).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 9 with GetPathsResult

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

the class InMemoryPathComputerBaseTest method shouldFindAffinityPathOnDiamond.

void shouldFindAffinityPathOnDiamond(PathComputationStrategy pathComputationStrategy) throws Exception {
    createDiamondWithAffinity();
    Flow flow = Flow.builder().flowId("new-flow").affinityGroupId(TEST_FLOW_ID).bandwidth(10).srcSwitch(getSwitchById("00:0A")).destSwitch(getSwitchById("00:0D")).encapsulationType(FlowEncapsulationType.TRANSIT_VLAN).pathComputationStrategy(pathComputationStrategy).build();
    PathComputer pathComputer = pathComputerFactory.getPathComputer();
    GetPathsResult affinityPath = pathComputer.getPath(flow);
    List<Segment> segments = affinityPath.getForward().getSegments();
    assertEquals(new SwitchId("00:0B"), segments.get(1).getSrcSwitchId());
    assertEquals(new SwitchId("00:0B"), segments.get(0).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)

Example 10 with GetPathsResult

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

the class CostPathComputationStrategyTest method shouldFindPathOverDiamondWithOneActiveRouteByCost.

@Test
public void shouldFindPathOverDiamondWithOneActiveRouteByCost() throws UnroutableFlowException, RecoverableException {
    createDiamond(IslStatus.INACTIVE, IslStatus.ACTIVE, 10, 20, "01:", 1);
    Switch srcSwitch = getSwitchById("01:01");
    Switch destSwitch = getSwitchById("01: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));
    // ====> only difference is it should now have C as first hop .. since B is inactive
    // chooses path C
    assertEquals(new SwitchId("01: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)

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