use of org.openkilda.rulemanager.FlowSpeakerData 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()));
}
use of org.openkilda.rulemanager.FlowSpeakerData in project open-kilda by telstra.
the class TablePassThroughDefaultRuleGeneratorTest method shouldBuildCorrectRuleForOf13.
@Test
public void shouldBuildCorrectRuleForOf13() {
Switch sw = buildSwitch("OF_13", Collections.emptySet());
TablePassThroughDefaultRuleGenerator generator = TablePassThroughDefaultRuleGenerator.builder().cookie(new Cookie(MULTITABLE_EGRESS_PASS_THROUGH_COOKIE)).tableId(OfTable.EGRESS).goToTableId(OfTable.TRANSIT).build();
List<SpeakerData> commands = generator.generateCommands(sw);
assertEquals(1, commands.size());
FlowSpeakerData flowCommandData = getCommand(FlowSpeakerData.class, commands);
assertEquals(sw.getSwitchId(), flowCommandData.getSwitchId());
assertEquals(sw.getOfVersion(), flowCommandData.getOfVersion().toString());
assertTrue(flowCommandData.getDependsOn().isEmpty());
assertEquals(new Cookie(MULTITABLE_EGRESS_PASS_THROUGH_COOKIE), flowCommandData.getCookie());
assertEquals(OfTable.EGRESS, flowCommandData.getTable());
assertEquals(MINIMAL_POSITIVE_PRIORITY, flowCommandData.getPriority());
assertTrue(flowCommandData.getMatch().isEmpty());
Instructions instructions = flowCommandData.getInstructions();
assertNull(instructions.getApplyActions());
assertNull(instructions.getWriteActions());
assertNull(instructions.getGoToMeter());
assertEquals(OfTable.TRANSIT, instructions.getGoToTable());
}
use of org.openkilda.rulemanager.FlowSpeakerData in project open-kilda by telstra.
the class SingleTableIngressYRuleGeneratorTest method buildCommandsVlanEncapsulationSingleVlanTest.
@Test
public void buildCommandsVlanEncapsulationSingleVlanTest() {
Flow flow = buildFlow(PATH, OUTER_VLAN_ID_1, 0);
SingleTableIngressYRuleGenerator generator = buildGenerator(PATH, flow, VLAN_ENCAPSULATION);
List<SpeakerData> commands = generator.generateCommands(SWITCH_1);
assertEquals(2, commands.size());
FlowSpeakerData ingressCommand = (FlowSpeakerData) commands.get(0);
MeterSpeakerData meterCommand = (MeterSpeakerData) commands.get(1);
assertEquals(newArrayList(meterCommand.getUuid()), new ArrayList<>(ingressCommand.getDependsOn()));
Set<FieldMatch> expectedIngressMatch = Sets.newHashSet(FieldMatch.builder().field(Field.IN_PORT).value(PORT_NUMBER_1).build(), FieldMatch.builder().field(Field.VLAN_VID).value(OUTER_VLAN_ID_1).build());
List<Action> expectedIngressActions = newArrayList(SetFieldAction.builder().field(Field.VLAN_VID).value(TRANSIT_VLAN_ID).build(), new PortOutAction(new PortNumber(PORT_NUMBER_2)));
assertIngressCommand(ingressCommand, Priority.Y_FLOW_PRIORITY, expectedIngressMatch, expectedIngressActions, SHARED_METER_ID);
assertMeterCommand(meterCommand);
}
use of org.openkilda.rulemanager.FlowSpeakerData in project open-kilda by telstra.
the class MultiTableIngressYRuleGeneratorTest method buildCommandsWithoutMeter.
@Test
public void buildCommandsWithoutMeter() {
Flow oneSwitchFlow = buildFlow(ONE_SWITCH_PATH, OUTER_VLAN_ID_2, 0);
Set<FlowSideAdapter> overlapping = Sets.newHashSet(FlowSideAdapter.makeIngressAdapter(oneSwitchFlow, ONE_SWITCH_PATH));
Flow flow = buildFlow(PATH, OUTER_VLAN_ID_1, INNER_VLAN_ID_1);
MultiTableIngressYRuleGenerator generator = buildGenerator(PATH, flow, VLAN_ENCAPSULATION, overlapping, false);
List<SpeakerData> commands = generator.generateCommands(SWITCH_1);
assertEquals(1, commands.size());
FlowSpeakerData ingressCommand = (FlowSpeakerData) commands.get(0);
assertEquals(newArrayList(SHARED_METER_UUID), new ArrayList<>(ingressCommand.getDependsOn()));
RoutingMetadata ingressMetadata = RoutingMetadata.builder().outerVlanId(OUTER_VLAN_ID_1).build(SWITCH_1.getFeatures());
Set<FieldMatch> expectedIngressMatch = Sets.newHashSet(FieldMatch.builder().field(Field.IN_PORT).value(PORT_NUMBER_1).build(), FieldMatch.builder().field(Field.VLAN_VID).value(INNER_VLAN_ID_1).build(), FieldMatch.builder().field(Field.METADATA).value(ingressMetadata.getValue()).mask(ingressMetadata.getMask()).build());
List<Action> expectedIngressActions = newArrayList(SetFieldAction.builder().field(Field.VLAN_VID).value(TRANSIT_VLAN_ID).build(), new PortOutAction(new PortNumber(PORT_NUMBER_2)));
assertIngressCommand(ingressCommand, Priority.Y_FLOW_DOUBLE_VLAN_PRIORITY, expectedIngressMatch, expectedIngressActions, SHARED_METER_ID, null);
}
use of org.openkilda.rulemanager.FlowSpeakerData in project open-kilda by telstra.
the class EgressMirrorRuleGeneratorTest method buildVlanMultiTableDoubleVlanEgressMirrorRuleTest.
@Test
public void buildVlanMultiTableDoubleVlanEgressMirrorRuleTest() {
FlowPath path = buildPathWithMirror(true);
Flow flow = buildFlow(path, OUTER_VLAN_ID, INNER_VLAN_ID);
EgressMirrorRuleGenerator generator = buildGenerator(path, flow, VLAN_ENCAPSULATION);
List<SpeakerData> commands = generator.generateCommands(SWITCH_2);
assertEquals(2, commands.size());
FlowSpeakerData egressCommand = getCommand(FlowSpeakerData.class, commands);
GroupSpeakerData groupCommand = getCommand(GroupSpeakerData.class, commands);
ArrayList<Action> expectedApplyActions = Lists.newArrayList(SetFieldAction.builder().field(Field.VLAN_VID).value(INNER_VLAN_ID).build(), new PushVlanAction(), SetFieldAction.builder().field(Field.VLAN_VID).value(OUTER_VLAN_ID).build(), new GroupAction(GROUP_ID));
assertEgressCommand(egressCommand, OfTable.EGRESS, VLAN_ENCAPSULATION, expectedApplyActions, groupCommand.getUuid());
assertGroupCommand(groupCommand);
}
Aggregations