use of org.openkilda.model.FlowPath in project open-kilda by telstra.
the class FlowMirrorPointsFrame method getFlowPath.
@Override
public FlowPath getFlowPath() {
if (flowPath == null) {
List<? extends FlowPathFrame> flowFrames = traverse(v -> v.in(FlowPathFrame.HAS_SEGMENTS_EDGE).hasLabel(FlowPathFrame.FRAME_LABEL)).toListExplicit(FlowPathFrame.class);
flowPath = !flowFrames.isEmpty() ? new FlowPath(flowFrames.get(0)) : null;
PathId pathId = flowPath != null ? flowPath.getPathId() : null;
if (!Objects.equals(getFlowPathId(), pathId)) {
throw new IllegalStateException(format("The flow mirror points %s has inconsistent flow_path_id %s / %s", getId(), getFlowPathId(), pathId));
}
}
return flowPath;
}
use of org.openkilda.model.FlowPath in project open-kilda by telstra.
the class FermaFlowPathRepositoryTest method shouldFindPathBySegmentDestSwitch.
@Test
public void shouldFindPathBySegmentDestSwitch() {
FlowPath flowPath = createTestFlowPathWithIntermediate(switchC, 100);
flow.setForwardPath(flowPath);
Collection<FlowPath> foundPaths = flowPathRepository.findBySegmentDestSwitch(switchC.getSwitchId());
assertThat(foundPaths, hasSize(1));
}
use of org.openkilda.model.FlowPath in project open-kilda by telstra.
the class FermaFlowPathRepositoryTest method shouldFindPathById.
@Test
public void shouldFindPathById() {
FlowPath flowPath = createTestFlowPath();
Optional<FlowPath> foundPath = flowPathRepository.findById(flowPath.getPathId());
assertTrue(foundPath.isPresent());
}
use of org.openkilda.model.FlowPath in project open-kilda by telstra.
the class FermaFlowPathRepositoryTest method shouldCreateFlowWithPaths.
@Test
public void shouldCreateFlowWithPaths() {
createTestFlowPathPair();
Collection<FlowPath> allPaths = flowPathRepository.findAll();
assertThat(allPaths, hasSize(2));
FlowPath foundForwardPath = flowPathRepository.findById(flow.getForwardPathId()).get();
assertEquals(switchA.getSwitchId(), foundForwardPath.getSrcSwitchId());
assertEquals(switchB.getSwitchId(), foundForwardPath.getDestSwitchId());
Flow foundFlow = flowRepository.findById(TEST_FLOW_ID).get();
assertThat(foundFlow.getPaths(), hasSize(2));
assertEquals(foundFlow.getFlowId(), foundForwardPath.getFlow().getFlowId());
}
use of org.openkilda.model.FlowPath in project open-kilda by telstra.
the class FermaFlowPathRepositoryTest method shouldFindInactivePathBySegmentSwitch.
@Test
public void shouldFindInactivePathBySegmentSwitch() {
Flow activeFlow = Flow.builder().flowId("active flow").srcSwitch(switchA).srcPort(1).destSwitch(switchB).destPort(2).status(FlowStatus.UP).build();
flowRepository.add(activeFlow);
FlowPath activeFlowPath = createFlowPath(activeFlow, "active", 100L, 200L, switchA, switchB);
activeFlow.addPaths(activeFlowPath);
activeFlowPath.getFlow().setStatus(FlowStatus.DOWN);
FlowPath expectedFlowPath = createTestFlowPathWithIntermediate(switchC, 100);
activeFlow.addPaths(expectedFlowPath);
expectedFlowPath.getFlow().setStatus(FlowStatus.DOWN);
Collection<FlowPath> foundPaths = flowPathRepository.findInactiveBySegmentSwitch(switchA.getSwitchId());
assertThat(foundPaths, hasSize(1));
FlowPath actualFlowPath = foundPaths.stream().findFirst().orElse(null);
assertEquals(expectedFlowPath, actualFlowPath);
}
Aggregations