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);
}
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());
}
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());
}
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());
}
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());
}
Aggregations