use of org.openkilda.rulemanager.SpeakerData in project open-kilda by telstra.
the class UniCastDiscoveryRuleGeneratorTest method shouldBuildCorrectRuleWithMeterForOf15.
@Test
public void shouldBuildCorrectRuleWithMeterForOf15() {
sw = buildSwitch("OF_15", Sets.newHashSet(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);
Set<FieldMatch> match = flowCommandData.getMatch();
assertEquals(2, match.size());
checkMatch(match);
// Check flow command has correct instructions for OF 1.5
Instructions instructions = flowCommandData.getInstructions();
assertEquals(3, instructions.getApplyActions().size());
Action first = instructions.getApplyActions().get(0);
assertTrue(first instanceof MeterAction);
MeterAction meterAction = (MeterAction) first;
assertEquals(meterCommandData.getMeterId(), meterAction.getMeterId());
checkPortOutAction(instructions.getApplyActions().get(1));
checkSetFieldAction(instructions.getApplyActions().get(2));
assertNull(instructions.getWriteActions());
assertNull(instructions.getGoToMeter());
assertNull(instructions.getGoToTable());
// Check meter command
checkMeterCommand(meterCommandData);
}
use of org.openkilda.rulemanager.SpeakerData in project open-kilda by telstra.
the class UniCastDiscoveryRuleGeneratorTest method shouldBuildCorrectRuleWithMeterInBytesForOf13.
@Test
public void shouldBuildCorrectRuleWithMeterInBytesForOf13() {
sw = buildSwitch("OF_13", Sets.newHashSet(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);
Set<FieldMatch> match = flowCommandData.getMatch();
assertEquals(2, match.size());
checkMatch(match);
checkInstructions(flowCommandData.getInstructions(), meterCommandData.getMeterId());
// Check meter command
assertEquals(createMeterIdForDefaultRule(VERIFICATION_UNICAST_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()));
}
use of org.openkilda.rulemanager.SpeakerData in project open-kilda by telstra.
the class UniCastDiscoveryRuleGeneratorTest method shouldBuildCorrectRuleWithoutMeterForOf13.
@Test
public void shouldBuildCorrectRuleWithoutMeterForOf13() {
sw = buildSwitch("OF_13", Collections.emptySet());
List<SpeakerData> commands = generator.generateCommands(sw);
assertEquals(1, 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);
assertTrue(flowCommandData.getDependsOn().isEmpty());
// Check flow command
checkFlowCommandBaseProperties(flowCommandData);
Set<FieldMatch> match = flowCommandData.getMatch();
assertEquals(2, match.size());
checkMatch(match);
Instructions instructions = flowCommandData.getInstructions();
assertEquals(2, instructions.getApplyActions().size());
checkPortOutAction(instructions.getApplyActions().get(0));
checkSetFieldAction(instructions.getApplyActions().get(1));
assertNull(instructions.getWriteActions());
assertNull(instructions.getGoToMeter());
assertNull(instructions.getGoToTable());
}
use of org.openkilda.rulemanager.SpeakerData in project open-kilda by telstra.
the class UnicastVerificationVxlanRuleGeneratorTest method shouldBuildCorrectRuleWithoutMeterForOf13.
@Test
public void shouldBuildCorrectRuleWithoutMeterForOf13() {
sw = buildSwitch("OF_13", Sets.newHashSet(NOVIFLOW_PUSH_POP_VXLAN, PKTPS_FLAG));
List<SpeakerData> commands = generator.generateCommands(sw);
assertEquals(1, 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);
assertTrue(flowCommandData.getDependsOn().isEmpty());
// Check flow command
checkFlowCommandBaseProperties(flowCommandData);
checkMatch(flowCommandData.getMatch());
// Check instructions without meter
Instructions instructions = flowCommandData.getInstructions();
assertEquals(3, 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());
assertNull(instructions.getWriteActions());
assertNull(instructions.getGoToMeter());
assertNull(instructions.getGoToTable());
}
use of org.openkilda.rulemanager.SpeakerData in project open-kilda by telstra.
the class IngressMirrorRuleGeneratorTest method oneSwitchFlowFullPortRuleTest.
@Test
public void oneSwitchFlowFullPortRuleTest() {
Flow flow = buildFlow(MULTI_TABLE_ONE_SWITCH_PATH, 0, 0, OUTER_VLAN_ID_2, 0);
IngressMirrorRuleGenerator generator = buildGenerator(MULTI_TABLE_ONE_SWITCH_PATH, flow, VLAN_ENCAPSULATION);
List<SpeakerData> commands = generator.generateCommands(SWITCH_1);
assertEquals(2, commands.size());
FlowSpeakerData ingressCommand = getCommand(FlowSpeakerData.class, commands);
GroupSpeakerData groupCommand = getCommand(GroupSpeakerData.class, commands);
Set<FieldMatch> expectedIngressMatch = Sets.newHashSet(FieldMatch.builder().field(Field.IN_PORT).value(PORT_NUMBER_1).build());
List<Action> expectedIngressActions = newArrayList(new PushVlanAction(), SetFieldAction.builder().field(Field.VLAN_VID).value(OUTER_VLAN_ID_2).build(), new GroupAction(GROUP_ID));
assertIngressCommand(ingressCommand, Priority.MIRROR_DEFAULT_FLOW_PRIORITY, INGRESS, expectedIngressMatch, expectedIngressActions, null, groupCommand.getUuid());
Set<Action> expectedFlowBucketActions = newHashSet(new PortOutAction(new PortNumber(PORT_NUMBER_2)));
assertGroupCommand(groupCommand, expectedFlowBucketActions);
}
Aggregations