Search in sources :

Example 26 with MeterSpeakerData

use of org.openkilda.rulemanager.MeterSpeakerData in project open-kilda by telstra.

the class UnicastVerificationVxlanRuleGeneratorTest method shouldBuildCorrectRuleWithMeterForOf13.

@Test
public void shouldBuildCorrectRuleWithMeterForOf13() {
    sw = buildSwitch("OF_13", Sets.newHashSet(NOVIFLOW_PUSH_POP_VXLAN, METERS, PKTPS_FLAG));
    List<SpeakerData> commands = generator.generateCommands(sw);
    assertEquals(2, commands.size());
    commands.forEach(c -> assertEquals(sw.getSwitchId(), c.getSwitchId()));
    commands.forEach(c -> assertEquals(sw.getOfVersion(), c.getOfVersion().toString()));
    FlowSpeakerData flowCommandData = getCommand(FlowSpeakerData.class, commands);
    MeterSpeakerData meterCommandData = getCommand(MeterSpeakerData.class, commands);
    assertEquals(1, flowCommandData.getDependsOn().size());
    assertTrue(flowCommandData.getDependsOn().contains(meterCommandData.getUuid()));
    // Check flow command
    checkFlowCommandBaseProperties(flowCommandData);
    checkMatch(flowCommandData.getMatch());
    checkInstructions(flowCommandData.getInstructions(), meterCommandData.getMeterId());
    // Check meter command
    checkMeterCommand(meterCommandData);
}
Also used : MeterSpeakerData(org.openkilda.rulemanager.MeterSpeakerData) FlowSpeakerData(org.openkilda.rulemanager.FlowSpeakerData) MeterSpeakerData(org.openkilda.rulemanager.MeterSpeakerData) SpeakerData(org.openkilda.rulemanager.SpeakerData) FlowSpeakerData(org.openkilda.rulemanager.FlowSpeakerData) Test(org.junit.Test)

Example 27 with MeterSpeakerData

use of org.openkilda.rulemanager.MeterSpeakerData in project open-kilda by telstra.

the class UnicastVerificationVxlanRuleGeneratorTest method shouldBuildCorrectRuleWithMeterInBytesForOf13.

@Test
public void shouldBuildCorrectRuleWithMeterInBytesForOf13() {
    sw = buildSwitch("OF_13", Sets.newHashSet(NOVIFLOW_PUSH_POP_VXLAN, METERS));
    List<SpeakerData> commands = generator.generateCommands(sw);
    assertEquals(2, commands.size());
    commands.forEach(c -> assertEquals(sw.getSwitchId(), c.getSwitchId()));
    commands.forEach(c -> assertEquals(sw.getOfVersion(), c.getOfVersion().toString()));
    FlowSpeakerData flowCommandData = getCommand(FlowSpeakerData.class, commands);
    MeterSpeakerData meterCommandData = getCommand(MeterSpeakerData.class, commands);
    assertEquals(1, flowCommandData.getDependsOn().size());
    assertTrue(flowCommandData.getDependsOn().contains(meterCommandData.getUuid()));
    // Check flow command
    checkFlowCommandBaseProperties(flowCommandData);
    checkMatch(flowCommandData.getMatch());
    checkInstructions(flowCommandData.getInstructions(), meterCommandData.getMeterId());
    // Check meter command
    assertEquals(createMeterIdForDefaultRule(VERIFICATION_UNICAST_VXLAN_RULE_COOKIE), meterCommandData.getMeterId());
    long expectedRate = Meter.convertRateToKiloBits(config.getUnicastRateLimit(), config.getDiscoPacketSize());
    assertEquals(expectedRate, meterCommandData.getRate());
    long expectedBurst = Meter.convertBurstSizeToKiloBits(config.getSystemMeterBurstSizeInPackets(), config.getDiscoPacketSize());
    assertEquals(expectedBurst, meterCommandData.getBurst());
    assertEquals(3, meterCommandData.getFlags().size());
    assertTrue(Sets.newHashSet(MeterFlag.BURST, MeterFlag.STATS, MeterFlag.KBPS).containsAll(meterCommandData.getFlags()));
}
Also used : MeterSpeakerData(org.openkilda.rulemanager.MeterSpeakerData) FlowSpeakerData(org.openkilda.rulemanager.FlowSpeakerData) MeterSpeakerData(org.openkilda.rulemanager.MeterSpeakerData) SpeakerData(org.openkilda.rulemanager.SpeakerData) FlowSpeakerData(org.openkilda.rulemanager.FlowSpeakerData) Test(org.junit.Test)

Example 28 with MeterSpeakerData

use of org.openkilda.rulemanager.MeterSpeakerData in project open-kilda by telstra.

the class UnicastVerificationVxlanRuleGeneratorTest method shouldBuildCorrectRuleWithMeterForOf15.

@Test
public void shouldBuildCorrectRuleWithMeterForOf15() {
    sw = buildSwitch("OF_15", Sets.newHashSet(NOVIFLOW_PUSH_POP_VXLAN, METERS, PKTPS_FLAG));
    List<SpeakerData> commands = generator.generateCommands(sw);
    assertEquals(2, commands.size());
    commands.forEach(c -> assertEquals(sw.getSwitchId(), c.getSwitchId()));
    commands.forEach(c -> assertEquals(sw.getOfVersion(), c.getOfVersion().toString()));
    FlowSpeakerData flowCommandData = getCommand(FlowSpeakerData.class, commands);
    MeterSpeakerData meterCommandData = getCommand(MeterSpeakerData.class, commands);
    assertEquals(1, flowCommandData.getDependsOn().size());
    assertTrue(flowCommandData.getDependsOn().contains(meterCommandData.getUuid()));
    // Check flow command
    checkFlowCommandBaseProperties(flowCommandData);
    checkMatch(flowCommandData.getMatch());
    // Check flow command has correct instructions for OF 1.5
    Instructions instructions = flowCommandData.getInstructions();
    assertEquals(4, instructions.getApplyActions().size());
    Action first = instructions.getApplyActions().get(0);
    assertTrue(first instanceof PopVxlanAction);
    PopVxlanAction popVxlanAction = (PopVxlanAction) first;
    assertEquals(ActionType.POP_VXLAN_NOVIFLOW, popVxlanAction.getType());
    Action second = instructions.getApplyActions().get(1);
    assertTrue(second instanceof PortOutAction);
    PortOutAction sendToControllerAction = (PortOutAction) second;
    assertEquals(SpecialPortType.CONTROLLER, sendToControllerAction.getPortNumber().getPortType());
    Action third = instructions.getApplyActions().get(3);
    assertTrue(third instanceof MeterAction);
    MeterAction meterAction = (MeterAction) third;
    assertEquals(meterCommandData.getMeterId(), meterAction.getMeterId());
    assertNull(instructions.getWriteActions());
    assertNull(instructions.getGoToMeter());
    assertNull(instructions.getGoToTable());
    // Check meter command
    checkMeterCommand(meterCommandData);
}
Also used : MeterSpeakerData(org.openkilda.rulemanager.MeterSpeakerData) MeterAction(org.openkilda.rulemanager.action.MeterAction) Action(org.openkilda.rulemanager.action.Action) PopVxlanAction(org.openkilda.rulemanager.action.PopVxlanAction) PortOutAction(org.openkilda.rulemanager.action.PortOutAction) FlowSpeakerData(org.openkilda.rulemanager.FlowSpeakerData) PortOutAction(org.openkilda.rulemanager.action.PortOutAction) PopVxlanAction(org.openkilda.rulemanager.action.PopVxlanAction) MeterAction(org.openkilda.rulemanager.action.MeterAction) Instructions(org.openkilda.rulemanager.Instructions) MeterSpeakerData(org.openkilda.rulemanager.MeterSpeakerData) SpeakerData(org.openkilda.rulemanager.SpeakerData) FlowSpeakerData(org.openkilda.rulemanager.FlowSpeakerData) Test(org.junit.Test)

Example 29 with MeterSpeakerData

use of org.openkilda.rulemanager.MeterSpeakerData 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 30 with MeterSpeakerData

use of org.openkilda.rulemanager.MeterSpeakerData 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

MeterSpeakerData (org.openkilda.rulemanager.MeterSpeakerData)38 Test (org.junit.Test)30 FlowSpeakerData (org.openkilda.rulemanager.FlowSpeakerData)30 SpeakerData (org.openkilda.rulemanager.SpeakerData)27 FieldMatch (org.openkilda.rulemanager.match.FieldMatch)17 PortOutAction (org.openkilda.rulemanager.action.PortOutAction)14 Action (org.openkilda.rulemanager.action.Action)13 SetFieldAction (org.openkilda.rulemanager.action.SetFieldAction)11 PortNumber (org.openkilda.rulemanager.ProtoConstants.PortNumber)9 Flow (org.openkilda.model.Flow)8 GroupSpeakerData (org.openkilda.rulemanager.GroupSpeakerData)8 PopVlanAction (org.openkilda.rulemanager.action.PopVlanAction)8 PushVlanAction (org.openkilda.rulemanager.action.PushVlanAction)8 PushVxlanAction (org.openkilda.rulemanager.action.PushVxlanAction)8 MeterId (org.openkilda.model.MeterId)7 Instructions (org.openkilda.rulemanager.Instructions)6 RoutingMetadata (org.openkilda.rulemanager.utils.RoutingMetadata)6 ValidateMetersResult (org.openkilda.wfm.topology.switchmanager.model.ValidateMetersResult)6 ValidationService (org.openkilda.wfm.topology.switchmanager.service.ValidationService)6 MeterAction (org.openkilda.rulemanager.action.MeterAction)5