Search in sources :

Example 21 with Switch

use of org.openkilda.model.Switch 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 22 with Switch

use of org.openkilda.model.Switch in project open-kilda by telstra.

the class LatencyPathComputationStrategyBaseTest method shouldFindPathOverDiamondWithOneIslUnderMaintenanceByLatency.

@Test
public void shouldFindPathOverDiamondWithOneIslUnderMaintenanceByLatency() 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.setUnderMaintenance(true);
    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 under maintenance
    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 23 with Switch

use of org.openkilda.model.Switch in project open-kilda by telstra.

the class MaxLatencyPathComputationStrategyBaseTest method createNonGreedyMaxLatencyTopo.

private void createNonGreedyMaxLatencyTopo() {
    // A - B - C
    // \ /     \
    // D - E - F
    String switchStart = "00:";
    int index = 1;
    Switch nodeA = createSwitch(switchStart + format("%02X", index++));
    Switch nodeB = createSwitch(switchStart + format("%02X", index++));
    Switch nodeC = createSwitch(switchStart + format("%02X", index++));
    Switch nodeD = createSwitch(switchStart + format("%02X", index++));
    Switch nodeE = createSwitch(switchStart + format("%02X", index++));
    Switch nodeF = createSwitch(switchStart + format("%02X", index));
    createBiIsl(nodeA, nodeB, IslStatus.ACTIVE, IslStatus.ACTIVE, 10, 1000, 1, 1L);
    createBiIsl(nodeB, nodeC, IslStatus.ACTIVE, IslStatus.ACTIVE, 10, 1000, 2, 7L);
    createBiIsl(nodeA, nodeD, IslStatus.ACTIVE, IslStatus.ACTIVE, 10, 1000, 3, 3L);
    createBiIsl(nodeB, nodeD, IslStatus.ACTIVE, IslStatus.ACTIVE, 10, 1000, 4, 10L);
    createBiIsl(nodeD, nodeE, IslStatus.ACTIVE, IslStatus.ACTIVE, 10, 1000, 5, 5L);
    createBiIsl(nodeE, nodeF, IslStatus.ACTIVE, IslStatus.ACTIVE, 10, 1000, 6, 12L);
    createBiIsl(nodeC, nodeF, IslStatus.ACTIVE, IslStatus.ACTIVE, 10, 1000, 7, 4L);
}
Also used : Switch(org.openkilda.model.Switch)

Example 24 with Switch

use of org.openkilda.model.Switch in project open-kilda by telstra.

the class AvailableNetworkTest method buildPathWithSegment.

private PathSegment buildPathWithSegment(SwitchId srcDpid, SwitchId dstDpid, int srcPort, int dstPort, String srcPop, String dstPop, int seqId) {
    Switch srcSwitch = Switch.builder().switchId(srcDpid).pop(srcPop).build();
    Switch dstSwitch = Switch.builder().switchId(dstDpid).pop(dstPop).build();
    PathId pathId = new PathId(UUID.randomUUID().toString());
    FlowPath flowPath = FlowPath.builder().pathId(pathId).srcSwitch(srcSwitch).destSwitch(dstSwitch).segments(IntStream.rangeClosed(0, seqId).mapToObj(i -> PathSegment.builder().pathId(pathId).srcSwitch(srcSwitch).destSwitch(dstSwitch).srcPort(srcPort).destPort(dstPort).build()).collect(toList())).build();
    return flowPath.getSegments().get(seqId);
}
Also used : PathId(org.openkilda.model.PathId) IntStream(java.util.stream.IntStream) PathWeight(org.openkilda.pce.model.PathWeight) Switch(org.openkilda.model.Switch) PathSegment(org.openkilda.model.PathSegment) FlowPath(org.openkilda.model.FlowPath) Matchers(org.hamcrest.Matchers) Set(java.util.Set) Test(org.junit.Test) UUID(java.util.UUID) Collections.singletonList(java.util.Collections.singletonList) WeightFunction(org.openkilda.pce.model.WeightFunction) Assert.assertThat(org.junit.Assert.assertThat) Collectors.toList(java.util.stream.Collectors.toList) Edge(org.openkilda.pce.model.Edge) Flow(org.openkilda.model.Flow) SwitchId(org.openkilda.model.SwitchId) Arrays.asList(java.util.Arrays.asList) Node(org.openkilda.pce.model.Node) Assert.assertEquals(org.junit.Assert.assertEquals) PathId(org.openkilda.model.PathId) Switch(org.openkilda.model.Switch) FlowPath(org.openkilda.model.FlowPath)

Example 25 with Switch

use of org.openkilda.model.Switch in project open-kilda by telstra.

the class InMemoryPathComputerBaseTest method createDiamondWithAffinity.

// A - B - D    and A-B-D is used in flow affinity group
// + C +
void createDiamondWithAffinity() {
    Switch nodeA = createSwitch("00:0A");
    Switch nodeB = createSwitch("00:0B");
    Switch nodeC = createSwitch("00:0C");
    Switch nodeD = createSwitch("00:0D");
    IslStatus status = IslStatus.ACTIVE;
    int cost = 100;
    createIsl(nodeA, nodeB, status, status, cost * 2, 1000, 1, cost * 2);
    createIsl(nodeA, nodeC, status, status, cost, 1000, 2, cost);
    createIsl(nodeB, nodeD, status, status, cost * 2, 1000, 3, cost * 2);
    createIsl(nodeC, nodeD, status, status, cost, 1000, 4, cost);
    createIsl(nodeB, nodeA, status, status, cost * 2, 1000, 1, cost * 2);
    createIsl(nodeC, nodeA, status, status, cost, 1000, 2, cost);
    createIsl(nodeD, nodeB, status, status, cost * 2, 1000, 3, cost * 2);
    createIsl(nodeD, nodeC, status, status, cost, 1000, 4, cost);
    int bandwith = 10;
    Flow flow = Flow.builder().flowId(TEST_FLOW_ID).srcSwitch(nodeA).srcPort(15).destSwitch(nodeD).destPort(16).affinityGroupId(TEST_FLOW_ID).bandwidth(bandwith).encapsulationType(FlowEncapsulationType.TRANSIT_VLAN).build();
    FlowPath forwardPath = FlowPath.builder().pathId(new PathId(UUID.randomUUID().toString())).srcSwitch(nodeA).destSwitch(nodeD).bandwidth(bandwith).cookie(new FlowSegmentCookie(1L).toBuilder().direction(FlowPathDirection.FORWARD).build()).build();
    addPathSegment(forwardPath, nodeA, nodeB, 1, 1);
    addPathSegment(forwardPath, nodeB, nodeD, 3, 3);
    flow.setForwardPath(forwardPath);
    FlowPath reversePath = FlowPath.builder().pathId(new PathId(UUID.randomUUID().toString())).srcSwitch(nodeD).destSwitch(nodeA).bandwidth(bandwith).cookie(new FlowSegmentCookie(1L).toBuilder().direction(FlowPathDirection.REVERSE).build()).build();
    addPathSegment(reversePath, nodeD, nodeB, 3, 3);
    addPathSegment(reversePath, nodeB, nodeA, 1, 1);
    flow.setReversePath(reversePath);
    flowRepository.add(flow);
}
Also used : PathId(org.openkilda.model.PathId) FlowSegmentCookie(org.openkilda.model.cookie.FlowSegmentCookie) Switch(org.openkilda.model.Switch) IslStatus(org.openkilda.model.IslStatus) FlowPath(org.openkilda.model.FlowPath) Flow(org.openkilda.model.Flow)

Aggregations

Switch (org.openkilda.model.Switch)230 Test (org.junit.Test)126 Flow (org.openkilda.model.Flow)68 SwitchId (org.openkilda.model.SwitchId)67 InMemoryGraphBasedTest (org.openkilda.persistence.inmemory.InMemoryGraphBasedTest)46 FlowPath (org.openkilda.model.FlowPath)34 PathId (org.openkilda.model.PathId)32 Utils.buildSwitch (org.openkilda.rulemanager.Utils.buildSwitch)32 PathComputer (org.openkilda.pce.PathComputer)28 GetPathsResult (org.openkilda.pce.GetPathsResult)23 List (java.util.List)22 SwitchProperties (org.openkilda.model.SwitchProperties)21 FlowSpeakerData (org.openkilda.rulemanager.FlowSpeakerData)20 SpeakerData (org.openkilda.rulemanager.SpeakerData)19 String.format (java.lang.String.format)17 Set (java.util.Set)17 Isl (org.openkilda.model.Isl)15 HashSet (java.util.HashSet)14 ArrayList (java.util.ArrayList)13 Collections (java.util.Collections)13