use of org.openkilda.pce.GetPathsResult in project open-kilda by telstra.
the class CostPathComputationStrategyTest method shouldFindTheSameDiversePath.
@Test
public void shouldFindTheSameDiversePath() throws RecoverableException, UnroutableFlowException {
createDiamondWithDiversity();
Flow flow = Flow.builder().flowId("new-flow").diverseGroupId("diverse").bandwidth(10).srcSwitch(getSwitchById("00:0A")).srcPort(10).destSwitch(getSwitchById("00:0D")).destPort(10).encapsulationType(FlowEncapsulationType.TRANSIT_VLAN).pathComputationStrategy(PathComputationStrategy.COST).build();
PathComputer pathComputer = pathComputerFactory.getPathComputer();
GetPathsResult diversePath = pathComputer.getPath(flow);
FlowPath forwardPath = FlowPath.builder().pathId(new PathId(UUID.randomUUID().toString())).srcSwitch(flow.getSrcSwitch()).destSwitch(flow.getDestSwitch()).bandwidth(flow.getBandwidth()).build();
addPathSegments(forwardPath, diversePath.getForward());
flow.setForwardPath(forwardPath);
FlowPath reversePath = FlowPath.builder().pathId(new PathId(UUID.randomUUID().toString())).srcSwitch(flow.getDestSwitch()).destSwitch(flow.getSrcSwitch()).bandwidth(flow.getBandwidth()).build();
addPathSegments(reversePath, diversePath.getReverse());
flow.setReversePath(reversePath);
flowRepository.add(flow);
GetPathsResult path2 = pathComputer.getPath(flow, flow.getPathIds());
assertEquals(diversePath, path2);
}
use of org.openkilda.pce.GetPathsResult in project open-kilda by telstra.
the class CostPathComputationStrategyTest method shouldFailToFindOverIslandsWithAllActiveLinksAndIgnoreBandwidth.
/**
* Create a couple of islands .. try to find a path between them .. validate no path is returned, and that the
* function completes in reasonable time ( < 10ms);
*/
@Test
public void shouldFailToFindOverIslandsWithAllActiveLinksAndIgnoreBandwidth() throws RecoverableException, UnroutableFlowException {
createDiamond(IslStatus.ACTIVE, IslStatus.ACTIVE, 10, 20, "06:", 1);
createDiamond(IslStatus.ACTIVE, IslStatus.ACTIVE, 10, 20, "07:", 1);
Switch srcSwitch1 = getSwitchById("06:01");
Switch destSwitch1 = getSwitchById("06:03");
// THIS ONE SHOULD WORK
Flow f1 = new TestFlowBuilder().srcSwitch(srcSwitch1).destSwitch(destSwitch1).bandwidth(0).ignoreBandwidth(false).build();
PathComputer pathComputer = pathComputerFactory.getPathComputer();
GetPathsResult path = pathComputer.getPath(f1);
assertNotNull(path);
assertThat(path.getForward().getSegments(), Matchers.hasSize(1));
Switch srcSwitch2 = getSwitchById("06:01");
Switch destSwitch2 = getSwitchById("07:04");
// THIS ONE SHOULD FAIL
Flow f2 = new TestFlowBuilder().srcSwitch(srcSwitch2).destSwitch(destSwitch2).bandwidth(0).ignoreBandwidth(false).build();
thrown.expect(UnroutableFlowException.class);
pathComputer.getPath(f2);
}
use of org.openkilda.pce.GetPathsResult in project open-kilda by telstra.
the class CostPathComputationStrategyTest method shouldFindDiversePath.
@Test
public void shouldFindDiversePath() throws RecoverableException, UnroutableFlowException {
createDiamondWithDiversity();
Flow flow = Flow.builder().flowId("new-flow").diverseGroupId("diverse").bandwidth(10).srcSwitch(getSwitchById("00:0A")).destSwitch(getSwitchById("00:0D")).encapsulationType(FlowEncapsulationType.TRANSIT_VLAN).pathComputationStrategy(PathComputationStrategy.COST).build();
PathComputer pathComputer = pathComputerFactory.getPathComputer();
GetPathsResult diversePath = pathComputer.getPath(flow);
diversePath.getForward().getSegments().forEach(segment -> {
assertNotEquals(new SwitchId("00:0B"), segment.getSrcSwitchId());
assertNotEquals(new SwitchId("00:0B"), segment.getDestSwitchId());
});
}
use of org.openkilda.pce.GetPathsResult in project open-kilda by telstra.
the class CostPathComputationStrategyTest method shouldFindPathOverDiamondWithAllActiveLinksAndIgnoreBandwidth.
@Test
public void shouldFindPathOverDiamondWithAllActiveLinksAndIgnoreBandwidth() throws RecoverableException, UnroutableFlowException {
createDiamond(IslStatus.ACTIVE, IslStatus.ACTIVE, 10, 20, "05:", 1);
Switch srcSwitch1 = getSwitchById("05:01");
Switch destSwitch1 = getSwitchById("05:03");
Flow f1 = new TestFlowBuilder().srcSwitch(srcSwitch1).destSwitch(destSwitch1).bandwidth(0).ignoreBandwidth(false).build();
PathComputer pathComputer = pathComputerFactory.getPathComputer();
GetPathsResult path = pathComputer.getPath(f1);
assertNotNull(path);
assertThat(path.getForward().getSegments(), Matchers.hasSize(1));
Switch srcSwitch2 = getSwitchById("05:01");
Switch destSwitch2 = getSwitchById("05:04");
Flow f2 = new TestFlowBuilder().srcSwitch(srcSwitch2).destSwitch(destSwitch2).bandwidth(0).ignoreBandwidth(false).build();
path = pathComputer.getPath(f2);
assertNotNull(path);
assertThat(path.getForward().getSegments(), Matchers.hasSize(2));
assertEquals(new SwitchId("05:02"), path.getForward().getSegments().get(0).getDestSwitchId());
}
use of org.openkilda.pce.GetPathsResult in project open-kilda by telstra.
the class CostPathComputationStrategyTest method shouldFindPathOverDiamondWithAllActiveLinksByCost.
@Test
public void shouldFindPathOverDiamondWithAllActiveLinksByCost() throws UnroutableFlowException, RecoverableException {
/*
* simple happy path test .. everything has cost
*/
createDiamond(IslStatus.ACTIVE, IslStatus.ACTIVE, 10, 20, "00:", 1);
Switch srcSwitch = getSwitchById("00:01");
Switch destSwitch = getSwitchById("00: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));
// chooses path B
assertEquals(new SwitchId("00:02"), path.getForward().getSegments().get(0).getDestSwitchId());
}
Aggregations