use of org.openkilda.model.cookie.FlowSegmentCookie in project open-kilda by telstra.
the class FermaIslRepositoryTest method createFlowWithPath.
private Flow createFlowWithPath(int forwardBandwidth, int reverseBandwidth) {
Flow flow = Flow.builder().flowId(TEST_FLOW_ID).srcSwitch(switchA).destSwitch(switchB).status(FlowStatus.UP).build();
FlowPath forwardPath = FlowPath.builder().srcSwitch(switchA).destSwitch(switchB).pathId(new PathId(TEST_FLOW_ID + "_forward_path")).cookie(new FlowSegmentCookie(1)).meterId(new MeterId(1)).status(FlowPathStatus.ACTIVE).bandwidth(forwardBandwidth).ignoreBandwidth(false).build();
flow.setForwardPath(forwardPath);
PathSegment forwardSegment = PathSegment.builder().pathId(forwardPath.getPathId()).srcSwitch(switchA).srcPort(1).destSwitch(switchB).destPort(2).build();
forwardPath.setSegments(Collections.singletonList(forwardSegment));
FlowPath reversePath = FlowPath.builder().srcSwitch(switchB).destSwitch(switchA).pathId(new PathId(TEST_FLOW_ID + "_reverse_path")).cookie(new FlowSegmentCookie(2)).meterId(new MeterId(2)).status(FlowPathStatus.ACTIVE).bandwidth(reverseBandwidth).ignoreBandwidth(false).build();
flow.setReversePath(reversePath);
PathSegment reverseSegment = PathSegment.builder().pathId(reversePath.getPathId()).srcSwitch(switchB).srcPort(2).destSwitch(switchA).destPort(1).build();
reversePath.setSegments(Collections.singletonList(reverseSegment));
flowRepository.add(flow);
return flow;
}
use of org.openkilda.model.cookie.FlowSegmentCookie in project open-kilda by telstra.
the class FlowSegmentCookieConverterTest method shouldConvertLongToId.
@Test
public void shouldConvertLongToId() {
// given
FlowSegmentCookie cookie = new FlowSegmentCookie((long) 0x123);
// when
FlowSegmentCookie actualEntity = FlowSegmentCookieConverter.INSTANCE.toEntityAttribute(cookie.getValue());
// then
assertEquals(cookie, actualEntity);
}
use of org.openkilda.model.cookie.FlowSegmentCookie in project open-kilda by telstra.
the class FlowOperationsServiceTest method createOrphanFlowPaths.
private void createOrphanFlowPaths(Flow flow, Switch srcSwitch, int srcPort, Switch dstSwitch, int dstPort, PathId forwardPartId, PathId reversePathId, Switch transitSwitch) {
FlowPath forwardPath = FlowPath.builder().pathId(forwardPartId).srcSwitch(srcSwitch).destSwitch(dstSwitch).cookie(new FlowSegmentCookie(FlowPathDirection.FORWARD, UNMASKED_COOKIE)).build();
FlowPath reversePath = FlowPath.builder().pathId(reversePathId).srcSwitch(dstSwitch).destSwitch(srcSwitch).cookie(new FlowSegmentCookie(FlowPathDirection.REVERSE, UNMASKED_COOKIE)).build();
if (!srcSwitch.getSwitchId().equals(dstSwitch.getSwitchId())) {
if (transitSwitch == null) {
// direct paths between src and dst switches
forwardPath.setSegments(newArrayList(createPathSegment(forwardPath.getPathId(), srcSwitch, srcPort, dstSwitch, dstPort)));
reversePath.setSegments(newArrayList(createPathSegment(reversePath.getPathId(), dstSwitch, dstPort, srcSwitch, srcPort)));
} else {
// src switch ==> transit switch ==> dst switch
forwardPath.setSegments(newArrayList(createPathSegment(forwardPath.getPathId(), srcSwitch, srcPort, transitSwitch, srcPort), createPathSegment(forwardPath.getPathId(), transitSwitch, dstPort, dstSwitch, dstPort)));
reversePath.setSegments(newArrayList(createPathSegment(reversePath.getPathId(), dstSwitch, dstPort, transitSwitch, dstPort), createPathSegment(reversePath.getPathId(), transitSwitch, srcPort, srcSwitch, srcPort)));
}
}
flowPathRepository.add(forwardPath);
flowPathRepository.add(reversePath);
flow.addPaths(forwardPath, reversePath);
}
use of org.openkilda.model.cookie.FlowSegmentCookie in project open-kilda by telstra.
the class CommandBuilderImplTest method shouldBuildRemoveFlowWithoutMeterFromFlowEntryWithStringOutPort.
@Test
public void shouldBuildRemoveFlowWithoutMeterFromFlowEntryWithStringOutPort() {
Long cookie = new FlowSegmentCookie(FlowPathDirection.FORWARD, 1).getValue();
String inPort = "1";
String inVlan = "10";
String outPort = "in_port";
FlowEntry flowEntry = buildFlowEntry(cookie, inPort, inVlan, outPort, null, false, null, null);
RemoveFlow removeFlow = commandBuilder.buildRemoveFlowWithoutMeterFromFlowEntry(SWITCH_ID_A, flowEntry);
assertEquals(cookie, removeFlow.getCookie());
DeleteRulesCriteria criteria = removeFlow.getCriteria();
assertEquals(cookie, criteria.getCookie());
assertEquals(Integer.valueOf(inPort), criteria.getInPort());
assertEquals(Integer.valueOf(inVlan), criteria.getEncapsulationId());
assertNull(criteria.getOutPort());
assertNull(criteria.getMetadataValue());
assertNull(criteria.getMetadataMask());
}
use of org.openkilda.model.cookie.FlowSegmentCookie in project open-kilda by telstra.
the class CommandBuilderImplTest method shouldBuildRemoveFlowWithoutMeterFromFlowEntryWithVxlanEncapsulationIngress.
@Test
public void shouldBuildRemoveFlowWithoutMeterFromFlowEntryWithVxlanEncapsulationIngress() {
Long cookie = new FlowSegmentCookie(FlowPathDirection.FORWARD, 1).getValue();
String inPort = "1";
String outPort = "2";
String tunnelId = "10";
String metadataValue = "0x15";
String metadataMask = "0xFF";
FlowEntry flowEntry = buildFlowEntry(cookie, inPort, null, outPort, tunnelId, true, metadataValue, metadataMask);
RemoveFlow removeFlow = commandBuilder.buildRemoveFlowWithoutMeterFromFlowEntry(SWITCH_ID_A, flowEntry);
assertEquals(cookie, removeFlow.getCookie());
DeleteRulesCriteria criteria = removeFlow.getCriteria();
assertEquals(cookie, criteria.getCookie());
assertEquals(Integer.valueOf(inPort), criteria.getInPort());
assertNull(criteria.getEncapsulationId());
assertEquals(Integer.valueOf(outPort), criteria.getOutPort());
assertEquals(Long.decode(metadataValue), criteria.getMetadataValue());
assertEquals(Long.decode(metadataMask), criteria.getMetadataMask());
}
Aggregations