use of org.openkilda.model.PathSegment in project open-kilda by telstra.
the class FermaPathSegmentRepositoryTest method createFlowPath.
private FlowPath createFlowPath(PathId pathId) {
Switch srcSwitch = createTestSwitch(1);
Switch dstSwitch = createTestSwitch(2);
Switch intSwitch = createTestSwitch(3);
FlowPath flowPath = FlowPath.builder().pathId(pathId).srcSwitch(srcSwitch).destSwitch(dstSwitch).status(FlowPathStatus.ACTIVE).build();
PathSegment segment1 = PathSegment.builder().pathId(pathId).srcSwitch(srcSwitch).srcPort(1).destSwitch(intSwitch).destPort(3).build();
PathSegment segment2 = PathSegment.builder().pathId(pathId).srcSwitch(intSwitch).srcPort(4).destSwitch(dstSwitch).destPort(2).build();
flowPath.setSegments(asList(segment1, segment2));
flowPathRepository.add(flowPath);
return flowPath;
}
use of org.openkilda.model.PathSegment in project open-kilda by telstra.
the class FermaPathSegmentRepositoryTest method shouldFindSegmentsByPath.
@Test
public void shouldFindSegmentsByPath() {
FlowPath path = createFlowPath(TEST_PATH_ID);
assertThat(flowPathRepository.findAll(), hasSize(1));
List<PathSegment> foundSegments = pathSegmentRepository.findByPathId(TEST_PATH_ID);
assertThat(foundSegments, containsInAnyOrder(path.getSegments().toArray()));
}
use of org.openkilda.model.PathSegment in project open-kilda by telstra.
the class FermaSwitchRepositoryTest method createTwoFlows.
private void createTwoFlows() {
Switch switchA = createTestSwitch(TEST_SWITCH_ID_A.getId());
Switch switchB = createTestSwitch(TEST_SWITCH_ID_B.getId());
// create flow TEST_FLOW_ID_A
Flow flow = Flow.builder().flowId(TEST_FLOW_ID_A).srcSwitch(switchA).srcPort(1).destSwitch(switchB).destPort(4).encapsulationType(FlowEncapsulationType.TRANSIT_VLAN).status(FlowStatus.UP).build();
FlowPath forwardFlowPath = FlowPath.builder().pathId(new PathId(TEST_FLOW_ID_A + "_forward_path")).cookie(new FlowSegmentCookie(FlowPathDirection.FORWARD, 1L)).meterId(new MeterId(1)).srcSwitch(switchA).destSwitch(switchB).status(FlowPathStatus.ACTIVE).build();
flow.setForwardPath(forwardFlowPath);
PathSegment forwardSegment = PathSegment.builder().pathId(forwardFlowPath.getPathId()).srcSwitch(switchA).srcPort(2).destSwitch(switchB).destPort(3).build();
forwardFlowPath.setSegments(Collections.singletonList(forwardSegment));
FlowPath reverseFlowPath = FlowPath.builder().pathId(new PathId(TEST_FLOW_ID_A + "_reverse_path")).cookie(new FlowSegmentCookie(FlowPathDirection.REVERSE, 1L)).meterId(new MeterId(2)).srcSwitch(switchB).destSwitch(switchA).status(FlowPathStatus.ACTIVE).build();
flow.setReversePath(reverseFlowPath);
PathSegment reverseSegment = PathSegment.builder().pathId(reverseFlowPath.getPathId()).srcSwitch(switchB).srcPort(3).destSwitch(switchA).destPort(2).build();
reverseFlowPath.setSegments(Collections.singletonList(reverseSegment));
flowRepository.add(flow);
Switch switchC = createTestSwitch(TEST_SWITCH_ID_C.getId());
// create flow TEST_FLOW_ID_B
flow = Flow.builder().flowId(TEST_FLOW_ID_B).srcSwitch(switchA).srcPort(1).destSwitch(switchC).destPort(7).encapsulationType(FlowEncapsulationType.TRANSIT_VLAN).status(FlowStatus.UP).build();
forwardFlowPath = FlowPath.builder().pathId(new PathId(TEST_FLOW_ID_B + "_forward_path")).cookie(new FlowSegmentCookie(FlowPathDirection.FORWARD, 1L)).meterId(new MeterId(3)).srcSwitch(switchA).destSwitch(switchC).status(FlowPathStatus.ACTIVE).build();
flow.setForwardPath(forwardFlowPath);
PathSegment forwardSegmentA = PathSegment.builder().pathId(forwardFlowPath.getPathId()).srcSwitch(switchA).srcPort(2).destSwitch(switchB).destPort(3).build();
PathSegment forwardSegmentB = PathSegment.builder().pathId(forwardFlowPath.getPathId()).srcSwitch(switchB).srcPort(5).destSwitch(switchC).destPort(6).build();
forwardFlowPath.setSegments(Lists.newArrayList(forwardSegmentA, forwardSegmentB));
reverseFlowPath = FlowPath.builder().pathId(new PathId(TEST_FLOW_ID_B + "_reverse_path")).cookie(new FlowSegmentCookie(FlowPathDirection.REVERSE, 1L)).meterId(new MeterId(4)).srcSwitch(switchC).destSwitch(switchA).status(FlowPathStatus.ACTIVE).build();
flow.setReversePath(reverseFlowPath);
PathSegment reverseSegmentA = PathSegment.builder().pathId(reverseFlowPath.getPathId()).srcSwitch(switchC).srcPort(6).destSwitch(switchB).destPort(5).build();
PathSegment reverseSegmentB = PathSegment.builder().pathId(reverseFlowPath.getPathId()).srcSwitch(switchB).srcPort(3).destSwitch(switchA).destPort(2).build();
reverseFlowPath.setSegments(Lists.newArrayList(reverseSegmentA, reverseSegmentB));
flowRepository.add(flow);
}
Aggregations