use of org.openkilda.wfm.topology.switchmanager.service.ValidationService in project open-kilda by telstra.
the class ValidationServiceImplTest method validateMetersProperMeters.
@Test
public void validateMetersProperMeters() {
ValidationService validationService = new ValidationServiceImpl(persistenceManager().build());
MeterSpeakerData meter = 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(meter), singletonList(meter));
assertTrue(response.getMissingMeters().isEmpty());
assertTrue(response.getMisconfiguredMeters().isEmpty());
assertFalse(response.getProperMeters().isEmpty());
assertEquals(meter.getMeterId().getValue(), response.getProperMeters().get(0).getMeterId().longValue());
assertMeter(response.getProperMeters().get(0), 32, 10000, 10500, new String[] { "KBPS", "BURST", "STATS" });
assertTrue(response.getExcessMeters().isEmpty());
}
use of org.openkilda.wfm.topology.switchmanager.service.ValidationService in project open-kilda by telstra.
the class ValidationServiceImplTest method validateRules.
@Test
public void validateRules() {
ValidationService validationService = new ValidationServiceImpl(persistenceManager().build());
List<FlowSpeakerData> actualFlows = Lists.newArrayList(FlowSpeakerData.builder().cookie(new Cookie(0x8000000000000001L)).priority(1).build(), FlowSpeakerData.builder().cookie(new Cookie(0x8000000000000001L)).priority(2).build(), FlowSpeakerData.builder().cookie(new Cookie(0x8000000000000002L)).priority(1).build(), FlowSpeakerData.builder().cookie(new Cookie(0x8000000000000002L)).priority(2).build(), FlowSpeakerData.builder().cookie(new Cookie(0x8000000000000004L)).priority(1).build());
List<FlowSpeakerData> expectedFlows = Lists.newArrayList(FlowSpeakerData.builder().cookie(new Cookie(0x8000000000000001L)).priority(1).build(), FlowSpeakerData.builder().cookie(new Cookie(0x8000000000000002L)).priority(3).build(), FlowSpeakerData.builder().cookie(new Cookie(0x8000000000000003L)).priority(1).build());
ValidateRulesResult response = validationService.validateRules(SWITCH_ID_A, actualFlows, expectedFlows);
assertEquals(ImmutableSet.of(0x8000000000000001L), new HashSet<>(response.getProperRules()));
assertEquals(ImmutableSet.of(0x8000000000000001L, 0x8000000000000002L), new HashSet<>(response.getMisconfiguredRules()));
assertEquals(ImmutableSet.of(0x8000000000000003L), new HashSet<>(response.getMissingRules()));
assertEquals(ImmutableSet.of(0x8000000000000004L), new HashSet<>(response.getExcessRules()));
}
use of org.openkilda.wfm.topology.switchmanager.service.ValidationService in project open-kilda by telstra.
the class ValidationServiceImplTest method validateRulesEmpty.
@Test
public void validateRulesEmpty() {
ValidationService validationService = new ValidationServiceImpl(persistenceManager().build());
ValidateRulesResult response = validationService.validateRules(SWITCH_ID_A, emptyList(), emptyList());
assertTrue(response.getMissingRules().isEmpty());
assertTrue(response.getProperRules().isEmpty());
assertTrue(response.getExcessRules().isEmpty());
}
use of org.openkilda.wfm.topology.switchmanager.service.ValidationService in project open-kilda by telstra.
the class ValidationServiceImplTest method validateLogicalPorts.
@Test
public void validateLogicalPorts() {
ValidationService validationService = new ValidationServiceImpl(persistenceManager().build());
LogicalPort proper = buildLogicalPort(LOGICAL_PORT_NUMBER_1, PHYSICAL_PORT_2, PHYSICAL_PORT_1);
LogicalPort misconfigured = buildLogicalPort(LOGICAL_PORT_NUMBER_2, LogicalPortType.BFD, PHYSICAL_PORT_3);
LogicalPort excess = buildLogicalPort(LOGICAL_PORT_NUMBER_4, PHYSICAL_PORT_6);
LogicalPort bfdExcess = buildLogicalPort(LOGICAL_PORT_NUMBER_5, LogicalPortType.BFD, PHYSICAL_PORT_7);
ValidateLogicalPortsResult result = validationService.validateLogicalPorts(SWITCH_ID_A, Lists.newArrayList(proper, misconfigured, excess, bfdExcess));
assertEquals(1, result.getProperLogicalPorts().size());
// bfdExcess port shouldn't be in this list
assertEquals(1, result.getExcessLogicalPorts().size());
assertEquals(1, result.getMissingLogicalPorts().size());
assertEquals(1, result.getMisconfiguredLogicalPorts().size());
assertEqualLogicalPort(proper, result.getProperLogicalPorts().get(0));
assertEqualLogicalPort(excess, result.getExcessLogicalPorts().get(0));
LogicalPortInfoEntry missing = LogicalPortInfoEntry.builder().type(org.openkilda.messaging.info.switches.LogicalPortType.LAG).logicalPortNumber(LOGICAL_PORT_NUMBER_3).physicalPorts(Lists.newArrayList(PHYSICAL_PORT_5, PHYSICAL_PORT_6)).build();
assertEquals(missing, result.getMissingLogicalPorts().get(0));
LogicalPortInfoEntry misconfiguredEntry = LogicalPortInfoEntry.builder().type(org.openkilda.messaging.info.switches.LogicalPortType.BFD).logicalPortNumber(LOGICAL_PORT_NUMBER_2).physicalPorts(Lists.newArrayList(PHYSICAL_PORT_3)).actual(new LogicalPortMisconfiguredInfoEntry(org.openkilda.messaging.info.switches.LogicalPortType.BFD, Lists.newArrayList(PHYSICAL_PORT_3))).expected(new LogicalPortMisconfiguredInfoEntry(org.openkilda.messaging.info.switches.LogicalPortType.LAG, Lists.newArrayList(PHYSICAL_PORT_3, PHYSICAL_PORT_4))).build();
assertEquals(misconfiguredEntry, result.getMisconfiguredLogicalPorts().get(0));
}
use of org.openkilda.wfm.topology.switchmanager.service.ValidationService in project open-kilda by telstra.
the class ValidationServiceImplTest method validateMetersProperMetersESwitch.
@Test
public void validateMetersProperMetersESwitch() {
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 meter = MeterSpeakerData.builder().meterId(new MeterId(32)).rate(rateESwitch).burst(burstSizeESwitch).ofVersion(OfVersion.OF_13).flags(Sets.newHashSet(MeterFlag.KBPS, MeterFlag.BURST, MeterFlag.STATS)).build();
ValidateMetersResult response = validationService.validateMeters(SWITCH_ID_E, singletonList(meter), singletonList(meter));
assertTrue(response.getMissingMeters().isEmpty());
assertTrue(response.getMisconfiguredMeters().isEmpty());
assertFalse(response.getProperMeters().isEmpty());
assertEquals(32L, (long) response.getProperMeters().get(0).getMeterId());
assertMeter(response.getProperMeters().get(0), 32, rateESwitch, burstSizeESwitch, new String[] { "KBPS", "BURST", "STATS" });
assertTrue(response.getExcessMeters().isEmpty());
}
Aggregations