Search in sources :

Example 1 with MeterSpeakerData

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

the class RuleManagerHelperTest method removeDuplicateCommandsDifferentMeterCommandTest.

@Test
public void removeDuplicateCommandsDifferentMeterCommandTest() {
    MeterSpeakerData command1 = buildFullMeterSpeakerCommandData(RATE_1);
    MeterSpeakerData command2 = buildFullMeterSpeakerCommandData(RATE_2);
    assertEquals(2, removeDuplicateCommands(newArrayList(command1, command2)).size());
}
Also used : MeterSpeakerData(org.openkilda.rulemanager.MeterSpeakerData) Test(org.junit.Test)

Example 2 with MeterSpeakerData

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

the class RuleManagerHelperTest method removeDuplicateCommandsFullEqualMeterCommandTest.

@Test
public void removeDuplicateCommandsFullEqualMeterCommandTest() {
    MeterSpeakerData command1 = buildFullMeterSpeakerCommandData();
    MeterSpeakerData command2 = buildFullMeterSpeakerCommandData();
    assertEquals(1, removeDuplicateCommands(newArrayList(command1, command2)).size());
}
Also used : MeterSpeakerData(org.openkilda.rulemanager.MeterSpeakerData) Test(org.junit.Test)

Example 3 with MeterSpeakerData

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

the class BroadCastDiscoveryRuleGeneratorTest method shouldBuildCorrectRuleWithMeterAndWithoutGroupForOf13.

@Test
public void shouldBuildCorrectRuleWithMeterAndWithoutGroupForOf13() {
    sw = buildSwitch("OF_13", Sets.newHashSet(METERS, MATCH_UDP_PORT, 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);
    Set<FieldMatch> match = flowCommandData.getMatch();
    assertEquals(4, match.size());
    checkEthDstMatch(match);
    checkUpdDstMatch(match);
    Instructions instructions = flowCommandData.getInstructions();
    assertEquals(1, instructions.getApplyActions().size());
    Action first = instructions.getApplyActions().get(0);
    assertTrue(first instanceof PortOutAction);
    PortOutAction portOutAction = (PortOutAction) first;
    assertEquals(SpecialPortType.CONTROLLER, portOutAction.getPortNumber().getPortType());
    assertNull(instructions.getWriteActions());
    assertEquals(meterCommandData.getMeterId(), instructions.getGoToMeter());
    assertNull(instructions.getGoToTable());
    // Check meter command
    checkMeterCommand(meterCommandData);
}
Also used : MeterSpeakerData(org.openkilda.rulemanager.MeterSpeakerData) MeterAction(org.openkilda.rulemanager.action.MeterAction) GroupAction(org.openkilda.rulemanager.action.GroupAction) SetFieldAction(org.openkilda.rulemanager.action.SetFieldAction) Action(org.openkilda.rulemanager.action.Action) PortOutAction(org.openkilda.rulemanager.action.PortOutAction) FlowSpeakerData(org.openkilda.rulemanager.FlowSpeakerData) PortOutAction(org.openkilda.rulemanager.action.PortOutAction) FieldMatch(org.openkilda.rulemanager.match.FieldMatch) Instructions(org.openkilda.rulemanager.Instructions) SpeakerData(org.openkilda.rulemanager.SpeakerData) MeterSpeakerData(org.openkilda.rulemanager.MeterSpeakerData) FlowSpeakerData(org.openkilda.rulemanager.FlowSpeakerData) GroupSpeakerData(org.openkilda.rulemanager.GroupSpeakerData) Test(org.junit.Test)

Example 4 with MeterSpeakerData

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

the class BroadCastDiscoveryRuleGeneratorTest method shouldBuildCorrectRuleWithMeterInBytesForOf13.

@Test
public void shouldBuildCorrectRuleWithMeterInBytesForOf13() {
    sw = buildSwitch("OF_13", Sets.newHashSet(METERS, GROUP_PACKET_OUT_CONTROLLER, MATCH_UDP_PORT));
    List<SpeakerData> commands = generator.generateCommands(sw);
    assertEquals(3, 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);
    GroupSpeakerData groupCommandData = getCommand(GroupSpeakerData.class, commands);
    assertEquals(2, flowCommandData.getDependsOn().size());
    assertTrue(flowCommandData.getDependsOn().contains(meterCommandData.getUuid()));
    assertTrue(flowCommandData.getDependsOn().contains(groupCommandData.getUuid()));
    // Check flow command
    checkFlowCommandBaseProperties(flowCommandData);
    Set<FieldMatch> match = flowCommandData.getMatch();
    assertEquals(4, match.size());
    checkEthDstMatch(match);
    checkUpdDstMatch(match);
    checkGroupInstructions(flowCommandData.getInstructions(), meterCommandData.getMeterId(), groupCommandData.getGroupId());
    // Check meter command
    assertEquals(createMeterIdForDefaultRule(VERIFICATION_BROADCAST_RULE_COOKIE), meterCommandData.getMeterId());
    long expectedRate = Meter.convertRateToKiloBits(config.getBroadcastRateLimit(), 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()));
    // Check group command
    checkGroupCommand(groupCommandData);
}
Also used : MeterSpeakerData(org.openkilda.rulemanager.MeterSpeakerData) FlowSpeakerData(org.openkilda.rulemanager.FlowSpeakerData) FieldMatch(org.openkilda.rulemanager.match.FieldMatch) GroupSpeakerData(org.openkilda.rulemanager.GroupSpeakerData) SpeakerData(org.openkilda.rulemanager.SpeakerData) MeterSpeakerData(org.openkilda.rulemanager.MeterSpeakerData) FlowSpeakerData(org.openkilda.rulemanager.FlowSpeakerData) GroupSpeakerData(org.openkilda.rulemanager.GroupSpeakerData) Test(org.junit.Test)

Example 5 with MeterSpeakerData

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

the class BroadCastDiscoveryRuleGeneratorTest method shouldBuildCorrectRuleWithoutUpdDstMatchForOf13.

@Test
public void shouldBuildCorrectRuleWithoutUpdDstMatchForOf13() {
    sw = buildSwitch("OF_13", Sets.newHashSet(METERS, GROUP_PACKET_OUT_CONTROLLER, PKTPS_FLAG));
    List<SpeakerData> commands = generator.generateCommands(sw);
    assertEquals(3, 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);
    GroupSpeakerData groupCommandData = getCommand(GroupSpeakerData.class, commands);
    assertEquals(2, flowCommandData.getDependsOn().size());
    assertTrue(flowCommandData.getDependsOn().contains(meterCommandData.getUuid()));
    assertTrue(flowCommandData.getDependsOn().contains(groupCommandData.getUuid()));
    // Check flow command
    checkFlowCommandBaseProperties(flowCommandData);
    // Check match is only by eth_dst
    Set<FieldMatch> match = flowCommandData.getMatch();
    assertEquals(1, match.size());
    checkEthDstMatch(match);
    checkGroupInstructions(flowCommandData.getInstructions(), meterCommandData.getMeterId(), groupCommandData.getGroupId());
    // Check meter command
    checkMeterCommand(meterCommandData);
    // Check group command
    checkGroupCommand(groupCommandData);
}
Also used : MeterSpeakerData(org.openkilda.rulemanager.MeterSpeakerData) FlowSpeakerData(org.openkilda.rulemanager.FlowSpeakerData) FieldMatch(org.openkilda.rulemanager.match.FieldMatch) GroupSpeakerData(org.openkilda.rulemanager.GroupSpeakerData) SpeakerData(org.openkilda.rulemanager.SpeakerData) MeterSpeakerData(org.openkilda.rulemanager.MeterSpeakerData) FlowSpeakerData(org.openkilda.rulemanager.FlowSpeakerData) GroupSpeakerData(org.openkilda.rulemanager.GroupSpeakerData) 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