use of org.openkilda.rulemanager.match.FieldMatch in project open-kilda by telstra.
the class TransitIslVxlanRuleGeneratorTest method shouldBuildCorrectRuleWithOpenKildaVxlanFeature.
@Test
public void shouldBuildCorrectRuleWithOpenKildaVxlanFeature() {
Switch sw = buildSwitch("OF_13", Sets.newHashSet(KILDA_OVS_PUSH_POP_MATCH_VXLAN));
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 PortColourCookie(CookieType.MULTI_TABLE_ISL_VXLAN_TRANSIT_RULES, ISL_PORT), flowCommandData.getCookie());
assertEquals(OfTable.INPUT, flowCommandData.getTable());
assertEquals(ISL_TRANSIT_VXLAN_RULE_PRIORITY_MULTITABLE, flowCommandData.getPriority());
Set<FieldMatch> match = flowCommandData.getMatch();
assertEquals(5, match.size());
checkMatch(match);
FieldMatch ethTypeMatch = getMatchByField(Field.ETH_TYPE, match);
assertEquals(EthType.IPv4, ethTypeMatch.getValue());
assertFalse(ethTypeMatch.isMasked());
Instructions instructions = flowCommandData.getInstructions();
assertEquals(OfTable.TRANSIT, instructions.getGoToTable());
}
use of org.openkilda.rulemanager.match.FieldMatch in project open-kilda by telstra.
the class LldpInputPreDropRuleGeneratorTest method checkMatch.
@Override
protected void checkMatch(Set<FieldMatch> match) {
assertEquals(1, match.size());
FieldMatch ethTypeMatch = getMatchByField(Field.ETH_TYPE, match);
assertEquals(EthType.LLDP, ethTypeMatch.getValue());
assertFalse(ethTypeMatch.isMasked());
}
use of org.openkilda.rulemanager.match.FieldMatch 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.match.FieldMatch 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.match.FieldMatch 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());
}
Aggregations