use of org.openkilda.rulemanager.MeterSpeakerData in project open-kilda by telstra.
the class ConnectedDevicesRuleGeneratorTest method shouldBuildCorrectRuleWithMeterInBytesForOf13.
@Test
public void shouldBuildCorrectRuleWithMeterInBytesForOf13() {
expectedFeatures.remove(PKTPS_FLAG);
sw = buildSwitch("OF_13", expectedFeatures);
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()));
assertTrue(meterCommandData.getDependsOn().isEmpty());
// Check flow command
checkFlowCommandBaseProperties(flowCommandData);
checkMatch(flowCommandData.getMatch());
checkInstructions(flowCommandData.getInstructions(), meterCommandData.getMeterId());
// Check meter command
checkMeterInBytesCommand(meterCommandData);
}
use of org.openkilda.rulemanager.MeterSpeakerData in project open-kilda by telstra.
the class MultiTableIngressRuleGeneratorTest method buildCommandsVlanEncapsulationDoubleVlanTest.
@Test
public void buildCommandsVlanEncapsulationDoubleVlanTest() {
Flow flow = buildFlow(PATH, OUTER_VLAN_ID_1, INNER_VLAN_ID_1);
MultiTableIngressRuleGenerator generator = buildGenerator(PATH, flow, VLAN_ENCAPSULATION);
List<SpeakerData> commands = generator.generateCommands(SWITCH_1);
assertEquals(4, commands.size());
FlowSpeakerData ingressCommand = (FlowSpeakerData) commands.get(0);
FlowSpeakerData preIngressCommand = (FlowSpeakerData) commands.get(1);
FlowSpeakerData inputCustomerCommand = (FlowSpeakerData) commands.get(2);
MeterSpeakerData meterCommand = (MeterSpeakerData) commands.get(3);
assertEquals(newArrayList(meterCommand.getUuid()), new ArrayList<>(ingressCommand.getDependsOn()));
Set<FieldMatch> expectedPreIngressMatch = 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());
FlowSharedSegmentCookie preIngressCookie = FlowSharedSegmentCookie.builder(SharedSegmentType.QINQ_OUTER_VLAN).portNumber(PORT_NUMBER_1).vlanId(OUTER_VLAN_ID_1).build();
RoutingMetadata preIngressMetadata = RoutingMetadata.builder().outerVlanId(OUTER_VLAN_ID_1).build(SWITCH_1.getFeatures());
assertPreIngressCommand(preIngressCommand, preIngressCookie, Priority.FLOW_PRIORITY, expectedPreIngressMatch, newArrayList(new PopVlanAction()), mapMetadata(preIngressMetadata));
assertInputCustomerCommand(inputCustomerCommand, new PortColourCookie(MULTI_TABLE_INGRESS_RULES, PORT_NUMBER_1), Sets.newHashSet(FieldMatch.builder().field(Field.IN_PORT).value(PORT_NUMBER_1).build()));
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.DOUBLE_VLAN_FLOW_PRIORITY, expectedIngressMatch, expectedIngressActions, METER_ID, null);
assertMeterCommand(meterCommand);
}
use of org.openkilda.rulemanager.MeterSpeakerData in project open-kilda by telstra.
the class UniCastDiscoveryRuleGeneratorTest method shouldBuildCorrectRuleWithMeterForOf13.
@Test
public void shouldBuildCorrectRuleWithMeterForOf13() {
sw = buildSwitch("OF_13", 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);
checkInstructions(flowCommandData.getInstructions(), meterCommandData.getMeterId());
// Check meter command
checkMeterCommand(meterCommandData);
}
Aggregations