Search in sources :

Example 6 with ValidationService

use of org.openkilda.wfm.topology.switchmanager.service.ValidationService in project open-kilda by telstra.

the class ValidationServiceImplTest method validateMetersMissingAndExcessMeters.

@Test
public void validateMetersMissingAndExcessMeters() {
    ValidationService validationService = new ValidationServiceImpl(persistenceManager().build());
    MeterSpeakerData actualMeter = MeterSpeakerData.builder().meterId(new MeterId(33)).rate(10000).burst(10500).ofVersion(OfVersion.OF_13).flags(Sets.newHashSet(MeterFlag.KBPS, MeterFlag.BURST, MeterFlag.STATS)).build();
    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));
    assertFalse(response.getMissingMeters().isEmpty());
    assertMeter(response.getMissingMeters().get(0), 32, 10000, 10500, new String[] { "KBPS", "BURST", "STATS" });
    assertTrue(response.getMisconfiguredMeters().isEmpty());
    assertTrue(response.getProperMeters().isEmpty());
    assertFalse(response.getExcessMeters().isEmpty());
    assertMeter(response.getExcessMeters().get(0), 33, 10000, 10500, new String[] { "KBPS", "BURST", "STATS" });
}
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 7 with ValidationService

use of org.openkilda.wfm.topology.switchmanager.service.ValidationService 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());
}
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 8 with ValidationService

use of org.openkilda.wfm.topology.switchmanager.service.ValidationService in project open-kilda by telstra.

the class ValidationServiceImplTest method validateMetersEmpty.

@Test
public void validateMetersEmpty() {
    ValidationService validationService = new ValidationServiceImpl(persistenceManager().build());
    ValidateMetersResult response = validationService.validateMeters(SWITCH_ID_A, emptyList(), emptyList());
    assertTrue(response.getMissingMeters().isEmpty());
    assertTrue(response.getMisconfiguredMeters().isEmpty());
    assertTrue(response.getProperMeters().isEmpty());
    assertTrue(response.getExcessMeters().isEmpty());
}
Also used : ValidateMetersResult(org.openkilda.wfm.topology.switchmanager.model.ValidateMetersResult) ValidationService(org.openkilda.wfm.topology.switchmanager.service.ValidationService) Test(org.junit.Test)

Example 9 with ValidationService

use of org.openkilda.wfm.topology.switchmanager.service.ValidationService 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());
}
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