use of org.openkilda.model.PathId in project open-kilda by telstra.
the class SimpleSwitchRuleConverterTest method buildFlow.
private Flow buildFlow(FlowEncapsulationType flowEncapsulationType, boolean checkWithGroup) {
Switch switchA = Switch.builder().switchId(TEST_SWITCH_ID_A).description("").build();
Switch switchB = Switch.builder().switchId(TEST_SWITCH_ID_B).description("").build();
Switch switchC = Switch.builder().switchId(TEST_SWITCH_ID_C).description("").build();
Flow flow = Flow.builder().flowId(TEST_FLOW_ID_A).srcSwitch(switchA).srcPort(FLOW_A_SRC_PORT).srcVlan(FLOW_A_SRC_VLAN).destSwitch(switchC).destPort(FLOW_A_DST_PORT).destVlan(FLOW_A_DST_VLAN).allocateProtectedPath(true).encapsulationType(flowEncapsulationType).bandwidth(FLOW_A_BANDWIDTH).status(FlowStatus.UP).build();
FlowPath forwardFlowPath = FlowPath.builder().pathId(FLOW_A_FORWARD_PATH_ID).cookie(new FlowSegmentCookie(FLOW_A_FORWARD_COOKIE_VALUE)).meterId(new MeterId(FLOW_A_FORWARD_METER_ID)).srcSwitch(switchA).destSwitch(switchC).status(FlowPathStatus.ACTIVE).bandwidth(FLOW_A_BANDWIDTH).build();
flow.setForwardPath(forwardFlowPath);
PathSegment forwardSegmentA = PathSegment.builder().pathId(forwardFlowPath.getPathId()).srcSwitch(switchA).srcPort(FLOW_A_SEGMENT_A_SRC_PORT).destSwitch(switchB).destPort(FLOW_A_SEGMENT_A_DST_PORT).build();
PathSegment forwardSegmentB = PathSegment.builder().pathId(forwardFlowPath.getPathId()).srcSwitch(switchB).srcPort(FLOW_A_SEGMENT_B_SRC_PORT).destSwitch(switchC).destPort(FLOW_A_SEGMENT_B_DST_PORT).build();
forwardFlowPath.setSegments(Lists.newArrayList(forwardSegmentA, forwardSegmentB));
if (checkWithGroup) {
FlowMirrorPoints flowMirrorPoints = FlowMirrorPoints.builder().mirrorSwitch(switchA).mirrorGroup(MirrorGroup.builder().switchId(TEST_SWITCH_ID_A).groupId(new GroupId(FLOW_GROUP_ID_A)).pathId(FLOW_A_FORWARD_PATH_ID).flowId(TEST_FLOW_ID_A).mirrorGroupType(MirrorGroupType.TRAFFIC_INTEGRITY).mirrorDirection(MirrorDirection.INGRESS).build()).build();
FlowMirrorPath flowMirrorPath = FlowMirrorPath.builder().pathId(new PathId("mirror_path")).mirrorSwitch(switchA).egressSwitch(switchA).egressPort(FLOW_GROUP_ID_A_OUT_PORT).egressOuterVlan(FLOW_GROUP_ID_A_OUT_VLAN).build();
flowMirrorPoints.addPaths(flowMirrorPath);
forwardFlowPath.addFlowMirrorPoints(flowMirrorPoints);
}
return flow;
}
use of org.openkilda.model.PathId in project open-kilda by telstra.
the class SimpleSwitchRuleConverterTest method buildOneSwitchPortFlow.
private Flow buildOneSwitchPortFlow() {
Switch switchD = Switch.builder().switchId(TEST_SWITCH_ID_D).description("").build();
Flow flow = Flow.builder().flowId(TEST_FLOW_ID_B).srcSwitch(switchD).srcPort(FLOW_B_SRC_PORT).srcVlan(FLOW_B_SRC_VLAN).destSwitch(switchD).destPort(FLOW_B_SRC_PORT).destVlan(FLOW_B_DST_VLAN).encapsulationType(FlowEncapsulationType.TRANSIT_VLAN).bandwidth(FLOW_B_BANDWIDTH).status(FlowStatus.UP).build();
FlowPath forwardFlowPath = FlowPath.builder().pathId(new PathId(TEST_FLOW_ID_B + "_forward_path")).cookie(new FlowSegmentCookie(FLOW_B_FORWARD_COOKIE_VALUE)).meterId(new MeterId(FLOW_B_FORWARD_METER_ID)).srcSwitch(switchD).destSwitch(switchD).status(FlowPathStatus.ACTIVE).bandwidth(FLOW_B_BANDWIDTH).build();
flow.setForwardPath(forwardFlowPath);
return flow;
}
use of org.openkilda.model.PathId in project open-kilda by telstra.
the class FlowPathBuilderTest method shouldBuildFlowPathFor2SwitchPath.
@Test
public void shouldBuildFlowPathFor2SwitchPath() {
SwitchId switchId1 = new SwitchId(1);
SwitchId switchId2 = new SwitchId(2);
Path path = Path.builder().srcSwitchId(switchId1).destSwitchId(switchId2).segments(Collections.singletonList(Segment.builder().srcSwitchId(switchId1).srcPort(1).destSwitchId(switchId2).destPort(2).build())).build();
Flow flow = Flow.builder().flowId("test_flow").srcSwitch(Switch.builder().switchId(switchId1).build()).destSwitch(Switch.builder().switchId(switchId2).build()).build();
PathId pathId = new PathId("test_path_id");
MeterId meterId = new MeterId(MeterId.MIN_FLOW_METER_ID);
PathResources pathResources = PathResources.builder().pathId(pathId).meterId(meterId).build();
FlowSegmentCookie cookie = new FlowSegmentCookie(FlowPathDirection.FORWARD, 1);
FlowPath flowPath = builder.buildFlowPath(flow, pathResources, path, cookie, false, flow.getFlowId());
assertEquals(switchId1, flowPath.getSrcSwitchId());
assertEquals(switchId2, flowPath.getDestSwitchId());
assertEquals(pathId, flowPath.getPathId());
assertEquals(meterId, flowPath.getMeterId());
assertEquals(cookie, flowPath.getCookie());
assertThat(flowPath.getSegments(), hasSize(1));
}
use of org.openkilda.model.PathId in project open-kilda by telstra.
the class FlowPathBuilderTest method shouldDetectDifferenceInPortsFor2SwitchPaths.
@Test
public void shouldDetectDifferenceInPortsFor2SwitchPaths() {
SwitchId switchId1 = new SwitchId(1);
Switch switch1 = Switch.builder().switchId(switchId1).build();
SwitchId switchId2 = new SwitchId(2);
Switch switch2 = Switch.builder().switchId(switchId2).build();
Path path = Path.builder().srcSwitchId(switchId1).destSwitchId(switchId2).segments(Collections.singletonList(Segment.builder().srcSwitchId(switchId1).srcPort(1).destSwitchId(switchId2).destPort(2).build())).build();
PathId flowPathId = new PathId("test_path_id");
FlowPath flowPath = FlowPath.builder().srcSwitch(switch1).destSwitch(switch2).pathId(flowPathId).segments(Collections.singletonList(PathSegment.builder().pathId(flowPathId).srcSwitch(switch1).srcPort(2).destSwitch(switch2).destPort(3).build())).build();
assertFalse(builder.isSamePath(path, flowPath));
}
use of org.openkilda.model.PathId in project open-kilda by telstra.
the class FlowPathBuilderTest method shouldDetectSameSwitchPaths.
@Test
public void shouldDetectSameSwitchPaths() {
SwitchId switchId = new SwitchId(1);
Switch switchEntity = Switch.builder().switchId(switchId).build();
Path path = Path.builder().srcSwitchId(switchId).destSwitchId(switchId).segments(Collections.emptyList()).build();
FlowPath flowPath = FlowPath.builder().srcSwitch(switchEntity).destSwitch(switchEntity).pathId(new PathId("test_path_id")).build();
assertTrue(builder.isSamePath(path, flowPath));
}
Aggregations