Search in sources :

Example 16 with Switch

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

the class CostPathComputationStrategyTest method shouldFailToFindOverDiamondWithNoActiveRoutes.

@Test
public void shouldFailToFindOverDiamondWithNoActiveRoutes() throws UnroutableFlowException, RecoverableException {
    createDiamond(IslStatus.INACTIVE, IslStatus.INACTIVE, 10, 30, "04:", 1);
    Switch srcSwitch = getSwitchById("04:01");
    Switch destSwitch = getSwitchById("04:04");
    Flow f = new TestFlowBuilder().srcSwitch(srcSwitch).destSwitch(destSwitch).bandwidth(100).build();
    thrown.expect(UnroutableFlowException.class);
    PathComputer pathComputer = pathComputerFactory.getPathComputer();
    pathComputer.getPath(f);
}
Also used : PathComputer(org.openkilda.pce.PathComputer) Switch(org.openkilda.model.Switch) Flow(org.openkilda.model.Flow) Test(org.junit.Test)

Example 17 with Switch

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

Example 18 with Switch

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

the class CostPathComputationStrategyTest method shouldFindPathOverTriangleWithOneActiveRouteByCost.

@Test
public void shouldFindPathOverTriangleWithOneActiveRouteByCost() throws UnroutableFlowException, RecoverableException {
    /*
         * simple happy path test .. but lowest path is inactive
         */
    createTriangleTopo(IslStatus.INACTIVE, 5, 20, "02:", 1);
    Switch srcSwitch = getSwitchById("02:01");
    Switch destSwitch = getSwitchById("02:02");
    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("02: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 19 with Switch

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

the class CostPathComputationStrategyTest 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 = 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));
    // ====> 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 20 with Switch

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

the class LatencyPathComputationStrategyBaseTest method shouldFindPathOverDiamondWithNoLatencyOnOneRoute.

@Test
public void shouldFindPathOverDiamondWithNoLatencyOnOneRoute() throws UnroutableFlowException, RecoverableException {
    /*
         * path B has no latency, path C has latency greater then default value
         */
    createDiamond(IslStatus.ACTIVE, IslStatus.ACTIVE, 0L, 1_000_000_000L);
    Switch srcSwitch = getSwitchById("00:01");
    Switch destSwitch = getSwitchById("00:04");
    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 choose B because default latency (500_000_000) is less then A-C latency (1_000_000_000)
    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)

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