use of org.openkilda.model.MeterId in project open-kilda by telstra.
the class FlowMapper method buildPath.
private FlowPath buildPath(FlowDto flowDto) {
Switch srcSwitch = Switch.builder().switchId(flowDto.getSourceSwitch()).build();
Switch destSwitch = Switch.builder().switchId(flowDto.getDestinationSwitch()).build();
return FlowPath.builder().srcSwitch(srcSwitch).destSwitch(destSwitch).cookie(new FlowSegmentCookie(flowDto.getCookie())).bandwidth(flowDto.getBandwidth()).ignoreBandwidth(flowDto.isIgnoreBandwidth()).pathId(new PathId(UUID.randomUUID().toString())).meterId(flowDto.getMeterId() != null ? new MeterId(flowDto.getMeterId()) : null).build();
}
use of org.openkilda.model.MeterId in project open-kilda by telstra.
the class ValidationServiceImplTest method validateMetersMisconfiguredMeters.
@Test
public void validateMetersMisconfiguredMeters() {
ValidationService validationService = new ValidationServiceImpl(persistenceManager().build());
MeterSpeakerData actualMeter = MeterSpeakerData.builder().meterId(new MeterId(32)).rate(10002).burst(10498).ofVersion(OfVersion.OF_13).flags(Sets.newHashSet(MeterFlag.PKTPS, MeterFlag.BURST, MeterFlag.STATS)).build();
String[] actualFlags = new String[] { "PKTPS", "BURST", "STATS" };
MeterSpeakerData expectedMeter = MeterSpeakerData.builder().meterId(new MeterId(32)).rate(10000).burst(10500).ofVersion(OfVersion.OF_13).flags(Sets.newHashSet(MeterFlag.KBPS, MeterFlag.BURST, MeterFlag.STATS)).build();
ValidateMetersResult response = validationService.validateMeters(SWITCH_ID_B, singletonList(actualMeter), singletonList(expectedMeter));
assertTrue(response.getMissingMeters().isEmpty());
assertFalse(response.getMisconfiguredMeters().isEmpty());
assertEquals(10002, (long) response.getMisconfiguredMeters().get(0).getActual().getRate());
assertEquals(10000, (long) response.getMisconfiguredMeters().get(0).getExpected().getRate());
assertEquals(10498L, (long) response.getMisconfiguredMeters().get(0).getActual().getBurstSize());
assertEquals(10500L, (long) response.getMisconfiguredMeters().get(0).getExpected().getBurstSize());
assertTrue(Sets.newHashSet(actualFlags).containsAll(Sets.newHashSet(response.getMisconfiguredMeters().get(0).getActual().getFlags())));
assertTrue(Sets.newHashSet("KBPS", "BURST", "STATS").containsAll(Sets.newHashSet(response.getMisconfiguredMeters().get(0).getExpected().getFlags())));
assertTrue(response.getProperMeters().isEmpty());
assertTrue(response.getExcessMeters().isEmpty());
}
use of org.openkilda.model.MeterId in project open-kilda by telstra.
the class ValidationServiceImplTest method validateMetersMisconfiguredMetersESwitch.
@Test
public void validateMetersMisconfiguredMetersESwitch() {
ValidationService validationService = new ValidationServiceImpl(persistenceManager().build());
long rateESwitch = FLOW_E_BANDWIDTH + (long) (FLOW_E_BANDWIDTH * 0.01) + 1;
long burstSize = (long) (FLOW_E_BANDWIDTH * 1.05);
long burstSizeESwitch = burstSize + (long) (burstSize * 0.01) + 1;
MeterSpeakerData actualMeter = MeterSpeakerData.builder().meterId(new MeterId(32)).rate(rateESwitch).burst(burstSizeESwitch).ofVersion(OfVersion.OF_13).flags(Sets.newHashSet(MeterFlag.PKTPS, MeterFlag.BURST, MeterFlag.STATS)).build();
MeterSpeakerData expectedMeter = MeterSpeakerData.builder().meterId(new MeterId(32)).rate(rateESwitch).burst(burstSize).ofVersion(OfVersion.OF_13).flags(Sets.newHashSet(MeterFlag.PKTPS, MeterFlag.BURST, MeterFlag.STATS)).build();
ValidateMetersResult response = validationService.validateMeters(SWITCH_ID_E, singletonList(actualMeter), singletonList(expectedMeter));
assertTrue(response.getMissingMeters().isEmpty());
assertFalse(response.getMisconfiguredMeters().isEmpty());
assertEquals(10606L, (long) response.getMisconfiguredMeters().get(0).getActual().getBurstSize());
assertEquals(10500L, (long) response.getMisconfiguredMeters().get(0).getExpected().getBurstSize());
assertTrue(response.getProperMeters().isEmpty());
assertTrue(response.getExcessMeters().isEmpty());
}
use of org.openkilda.model.MeterId in project open-kilda by telstra.
the class FermaFlowPathRepositoryTest method createTestFlowPathWithIntermediate.
private FlowPath createTestFlowPathWithIntermediate(Switch intSwitch, int intPort) {
FlowPath flowPath = FlowPath.builder().pathId(new PathId(flow.getFlowId() + "_forward_path")).cookie(new FlowSegmentCookie(FlowPathDirection.FORWARD, 1L)).meterId(new MeterId(1)).srcSwitch(switchA).destSwitch(switchB).status(FlowPathStatus.ACTIVE).build();
PathSegment segment1 = PathSegment.builder().pathId(flowPath.getPathId()).srcSwitch(switchA).srcPort(1).destSwitch(intSwitch).destPort(intPort).build();
PathSegment segment2 = PathSegment.builder().pathId(flowPath.getPathId()).srcSwitch(intSwitch).srcPort(intPort + 100).destSwitch(switchB).destPort(2).build();
flowPath.setSegments(asList(segment1, segment2));
flowPathRepository.add(flowPath);
return flowPath;
}
use of org.openkilda.model.MeterId in project open-kilda by telstra.
the class FermaFlowRepositoryTest method createTestFlow.
private Flow createTestFlow(String flowId, Switch srcSwitch, int srcPort, int srcVlan, Switch destSwitch, int destPort, int destVlan, boolean multiTable) {
Flow flow = Flow.builder().flowId(flowId).srcSwitch(srcSwitch).srcPort(srcPort).srcVlan(srcVlan).destSwitch(destSwitch).destPort(destPort).destVlan(destVlan).encapsulationType(FlowEncapsulationType.TRANSIT_VLAN).status(FlowStatus.UP).build();
flowRepository.add(flow);
FlowPath forwardFlowPath = FlowPath.builder().pathId(new PathId(flowId + "_forward_path")).cookie(new FlowSegmentCookie(FlowPathDirection.FORWARD, 1L)).meterId(new MeterId(1)).srcSwitch(srcSwitch).destSwitch(destSwitch).status(FlowPathStatus.ACTIVE).srcWithMultiTable(multiTable).destWithMultiTable(multiTable).build();
PathSegment forwardSegment = PathSegment.builder().pathId(forwardFlowPath.getPathId()).srcSwitch(srcSwitch).srcPort(srcPort).destSwitch(destSwitch).destPort(destPort).build();
forwardFlowPath.setSegments(Collections.singletonList(forwardSegment));
flowPathRepository.add(forwardFlowPath);
flow.setForwardPath(forwardFlowPath);
FlowPath reverseFlowPath = FlowPath.builder().pathId(new PathId(flowId + "_reverse_path")).cookie(new FlowSegmentCookie(FlowPathDirection.REVERSE, 1L)).meterId(new MeterId(2)).srcSwitch(destSwitch).destSwitch(srcSwitch).status(FlowPathStatus.ACTIVE).srcWithMultiTable(multiTable).destWithMultiTable(multiTable).build();
PathSegment reverseSegment = PathSegment.builder().pathId(reverseFlowPath.getPathId()).srcSwitch(destSwitch).srcPort(destPort).destSwitch(srcSwitch).destPort(srcPort).build();
reverseFlowPath.setSegments(Collections.singletonList(reverseSegment));
flowPathRepository.add(reverseFlowPath);
flow.setReversePath(reverseFlowPath);
return flow;
}
Aggregations