Search in sources :

Example 1 with ValidationService

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());
}
Also used : MeterSpeakerData(org.openkilda.rulemanager.MeterSpeakerData) ValidateMetersResult(org.openkilda.wfm.topology.switchmanager.model.ValidateMetersResult) ValidationService(org.openkilda.wfm.topology.switchmanager.service.ValidationService) MeterId(org.openkilda.model.MeterId) Test(org.junit.Test)

Example 2 with ValidationService

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()));
}
Also used : Cookie(org.openkilda.model.cookie.Cookie) ValidateRulesResult(org.openkilda.wfm.topology.switchmanager.model.ValidateRulesResult) FlowSpeakerData(org.openkilda.rulemanager.FlowSpeakerData) ValidationService(org.openkilda.wfm.topology.switchmanager.service.ValidationService) Test(org.junit.Test)

Example 3 with ValidationService

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());
}
Also used : ValidateRulesResult(org.openkilda.wfm.topology.switchmanager.model.ValidateRulesResult) ValidationService(org.openkilda.wfm.topology.switchmanager.service.ValidationService) Test(org.junit.Test)

Example 4 with ValidationService

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));
}
Also used : LogicalPort(org.openkilda.messaging.model.grpc.LogicalPort) LagLogicalPort(org.openkilda.model.LagLogicalPort) LogicalPortInfoEntry(org.openkilda.messaging.info.switches.LogicalPortInfoEntry) LogicalPortMisconfiguredInfoEntry(org.openkilda.messaging.info.switches.LogicalPortMisconfiguredInfoEntry) ValidationService(org.openkilda.wfm.topology.switchmanager.service.ValidationService) ValidateLogicalPortsResult(org.openkilda.wfm.topology.switchmanager.model.ValidateLogicalPortsResult) Test(org.junit.Test)

Example 5 with ValidationService

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());
}
Also used : MeterSpeakerData(org.openkilda.rulemanager.MeterSpeakerData) ValidateMetersResult(org.openkilda.wfm.topology.switchmanager.model.ValidateMetersResult) ValidationService(org.openkilda.wfm.topology.switchmanager.service.ValidationService) MeterId(org.openkilda.model.MeterId) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)9 ValidationService (org.openkilda.wfm.topology.switchmanager.service.ValidationService)9 ValidateMetersResult (org.openkilda.wfm.topology.switchmanager.model.ValidateMetersResult)6 MeterId (org.openkilda.model.MeterId)5 MeterSpeakerData (org.openkilda.rulemanager.MeterSpeakerData)5 ValidateRulesResult (org.openkilda.wfm.topology.switchmanager.model.ValidateRulesResult)2 LogicalPortInfoEntry (org.openkilda.messaging.info.switches.LogicalPortInfoEntry)1 LogicalPortMisconfiguredInfoEntry (org.openkilda.messaging.info.switches.LogicalPortMisconfiguredInfoEntry)1 LogicalPort (org.openkilda.messaging.model.grpc.LogicalPort)1 LagLogicalPort (org.openkilda.model.LagLogicalPort)1 Cookie (org.openkilda.model.cookie.Cookie)1 FlowSpeakerData (org.openkilda.rulemanager.FlowSpeakerData)1 ValidateLogicalPortsResult (org.openkilda.wfm.topology.switchmanager.model.ValidateLogicalPortsResult)1