Search in sources :

Example 41 with SwitchId

use of org.openkilda.model.SwitchId 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 42 with SwitchId

use of org.openkilda.model.SwitchId 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 43 with SwitchId

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

the class InMemoryPathComputerBaseTest method createSwitch.

Switch createSwitch(String name) {
    Switch sw = Switch.builder().switchId(new SwitchId(name)).status(SwitchStatus.ACTIVE).build();
    switchRepository.add(sw);
    SwitchProperties switchProperties = SwitchProperties.builder().switchObj(sw).supportedTransitEncapsulation(SwitchProperties.DEFAULT_FLOW_ENCAPSULATION_TYPES).build();
    switchPropertiesRepository.add(switchProperties);
    return sw;
}
Also used : Switch(org.openkilda.model.Switch) SwitchId(org.openkilda.model.SwitchId) SwitchProperties(org.openkilda.model.SwitchProperties)

Example 44 with SwitchId

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

the class AvailableNetworkTest method shouldKeepLinksWithOtherSwitchesAfterReducing.

@Test
public void shouldKeepLinksWithOtherSwitchesAfterReducing() {
    AvailableNetwork network = new AvailableNetwork();
    addLink(network, SRC_SWITCH, new SwitchId("00:00"), 1, 1, 20, 5);
    addLink(network, SRC_SWITCH, DST_SWITCH, 2, 2, 10, 3);
    addLink(network, DST_SWITCH, SRC_SWITCH, 1, 1, 20, 5);
    addLink(network, new SwitchId("00:00"), SRC_SWITCH, 2, 2, 10, 3);
    assertThat(network.getSwitch(SRC_SWITCH).getOutgoingLinks(), Matchers.hasSize(2));
    assertThat(network.getSwitch(SRC_SWITCH).getIncomingLinks(), Matchers.hasSize(2));
}
Also used : SwitchId(org.openkilda.model.SwitchId) Test(org.junit.Test)

Example 45 with SwitchId

use of org.openkilda.model.SwitchId 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

SwitchId (org.openkilda.model.SwitchId)339 Test (org.junit.Test)149 Flow (org.openkilda.model.Flow)73 Switch (org.openkilda.model.Switch)69 List (java.util.List)59 FlowPath (org.openkilda.model.FlowPath)49 ArrayList (java.util.ArrayList)44 Collectors (java.util.stream.Collectors)37 PathId (org.openkilda.model.PathId)36 PathComputer (org.openkilda.pce.PathComputer)35 Set (java.util.Set)34 YFlow (org.openkilda.model.YFlow)33 Map (java.util.Map)30 GetPathsResult (org.openkilda.pce.GetPathsResult)30 InfoMessage (org.openkilda.messaging.info.InfoMessage)29 String.format (java.lang.String.format)28 HashSet (java.util.HashSet)27 Optional (java.util.Optional)27 Collection (java.util.Collection)26 Collections (java.util.Collections)26