Search in sources :

Example 31 with PathComputer

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

the class InMemoryPathComputerBaseTest method shouldAlwaysFindPathForExistedFlow.

/**
 * Checks that existed flow should always have available path even there is only links with 0 available bandwidth.
 */
@Test
public void shouldAlwaysFindPathForExistedFlow() throws RecoverableException, UnroutableFlowException {
    String flowId = "flow-A1:01-A1:03";
    long bandwidth = 1000;
    createLinearTopoWithFlowSegments(10, "A1:", 1, 0L, flowId, bandwidth);
    Switch srcSwitch = getSwitchById("A1:01");
    Switch destSwitch = getSwitchById("A1:03");
    Flow flow = new TestFlowBuilder().flowId(flowId).srcSwitch(srcSwitch).destSwitch(destSwitch).bandwidth(bandwidth).ignoreBandwidth(false).build();
    Flow oldFlow = flowRepository.findById(flowId).orElseThrow(() -> new AssertionError("Flow not found"));
    PathComputer pathComputer = pathComputerFactory.getPathComputer();
    GetPathsResult result = pathComputer.getPath(flow, oldFlow.getPathIds());
    assertThat(result.getForward().getSegments(), Matchers.hasSize(2));
    assertThat(result.getReverse().getSegments(), Matchers.hasSize(2));
}
Also used : PathComputer(org.openkilda.pce.PathComputer) Switch(org.openkilda.model.Switch) Flow(org.openkilda.model.Flow) GetPathsResult(org.openkilda.pce.GetPathsResult) InMemoryGraphBasedTest(org.openkilda.persistence.inmemory.InMemoryGraphBasedTest) Test(org.junit.Test)

Example 32 with PathComputer

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

the class InMemoryPathComputerBaseTest method shouldNotFindPathForExistedFlowAndIncreasedBandwidth.

/**
 * Tests the case when we try to increase bandwidth of the flow and there is no available bandwidth left.
 */
@Test
public void shouldNotFindPathForExistedFlowAndIncreasedBandwidth() throws RecoverableException, UnroutableFlowException {
    String flowId = "flow-A1:01-A1:03";
    long originFlowBandwidth = 1000L;
    // create network, all links have available bandwidth 0
    createLinearTopoWithFlowSegments(10, "A1:", 1, 0, flowId, originFlowBandwidth);
    Switch srcSwitch = getSwitchById("A1:01");
    Switch destSwitch = getSwitchById("A1:03");
    Flow flow = new TestFlowBuilder().flowId(flowId).srcSwitch(srcSwitch).destSwitch(destSwitch).bandwidth(originFlowBandwidth).ignoreBandwidth(false).build();
    long updatedFlowBandwidth = originFlowBandwidth + 1;
    flow.setBandwidth(updatedFlowBandwidth);
    thrown.expect(UnroutableFlowException.class);
    PathComputer pathComputer = pathComputerFactory.getPathComputer();
    pathComputer.getPath(flow, flow.getPathIds());
}
Also used : PathComputer(org.openkilda.pce.PathComputer) Switch(org.openkilda.model.Switch) Flow(org.openkilda.model.Flow) InMemoryGraphBasedTest(org.openkilda.persistence.inmemory.InMemoryGraphBasedTest) Test(org.junit.Test)

Example 33 with PathComputer

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

the class InMemoryPathComputerBaseTest method verifyConversionToPair.

/**
 * This verifies that the getPath in PathComputer returns what we expect. Essentially, this tests the additional
 * logic wrt taking the results of the algo and convert to something installable.
 */
@Test
public void verifyConversionToPair() throws UnroutableFlowException, RecoverableException {
    createDiamond(IslStatus.ACTIVE, IslStatus.ACTIVE, 10, 20, "09:", 1);
    Switch srcSwitch = getSwitchById("09:01");
    Switch destSwitch = getSwitchById("09:04");
    Flow flow = new TestFlowBuilder().srcSwitch(srcSwitch).destSwitch(destSwitch).bandwidth(10).ignoreBandwidth(false).build();
    PathComputer pathComputer = pathComputerFactory.getPathComputer();
    GetPathsResult result = pathComputer.getPath(flow);
    assertNotNull(result);
    // ensure start/end switches match
    List<Path.Segment> left = result.getForward().getSegments();
    assertEquals(srcSwitch.getSwitchId(), left.get(0).getSrcSwitchId());
    assertEquals(destSwitch.getSwitchId(), left.get(left.size() - 1).getDestSwitchId());
    List<Path.Segment> right = result.getReverse().getSegments();
    assertEquals(destSwitch.getSwitchId(), right.get(0).getSrcSwitchId());
    assertEquals(srcSwitch.getSwitchId(), right.get(right.size() - 1).getDestSwitchId());
}
Also used : PathComputer(org.openkilda.pce.PathComputer) Switch(org.openkilda.model.Switch) Segment(org.openkilda.pce.Path.Segment) PathSegment(org.openkilda.model.PathSegment) Flow(org.openkilda.model.Flow) GetPathsResult(org.openkilda.pce.GetPathsResult) InMemoryGraphBasedTest(org.openkilda.persistence.inmemory.InMemoryGraphBasedTest) Test(org.junit.Test)

Example 34 with PathComputer

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

the class InMemoryPathComputerBaseTest method shouldGetYPoint2DifferentFlowPathsWithSameEndpoints.

@Test
public void shouldGetYPoint2DifferentFlowPathsWithSameEndpoints() {
    FlowPath flowPathA = buildFlowPath("flow_path_a", 1, 2, 3);
    FlowPath flowPathB = buildFlowPath("flow_path_b", 1, 4, 3);
    PathComputer pathComputer = pathComputerFactory.getPathComputer();
    SwitchId result = pathComputer.getIntersectionPoint(SWITCH_1, flowPathA, flowPathB);
    assertEquals(new SwitchId(1), result);
}
Also used : PathComputer(org.openkilda.pce.PathComputer) SwitchId(org.openkilda.model.SwitchId) FlowPath(org.openkilda.model.FlowPath) InMemoryGraphBasedTest(org.openkilda.persistence.inmemory.InMemoryGraphBasedTest) Test(org.junit.Test)

Example 35 with PathComputer

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

the class MaxLatencyPathComputationStrategyBaseTest method nonGreedyMaxLatencyTest.

@Test
public void nonGreedyMaxLatencyTest() throws Exception {
    // non-greedy algorithm can't find the closest path to max-latency param
    createNonGreedyMaxLatencyTopo();
    Flow flow = Flow.builder().flowId("test flow").srcSwitch(getSwitchById("00:01")).srcPort(15).destSwitch(getSwitchById("00:06")).destPort(15).bandwidth(500).encapsulationType(FlowEncapsulationType.TRANSIT_VLAN).pathComputationStrategy(PathComputationStrategy.MAX_LATENCY).maxLatency(25L).build();
    PathComputer pathComputer = pathComputerFactory.getPathComputer();
    GetPathsResult path = pathComputer.getPath(flow);
    assertNotNull(path);
    // best path is A-D-B-C-F and has 4 segments and 24 latency but non-greedy algorithm can find only path A-D-E-F
    // with 3 segments and total latency 20
    assertEquals(path.getForward().getSegments().size(), 3);
}
Also used : PathComputer(org.openkilda.pce.PathComputer) 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