use of org.openkilda.rulemanager.match.FieldMatch in project open-kilda by telstra.
the class DropDiscoveryLoopRuleGeneratorTest method shouldBuildCorrectRuleForOf13.
@Test
public void shouldBuildCorrectRuleForOf13() {
Switch sw = buildSwitch("OF_13", Collections.emptySet());
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(DROP_VERIFICATION_LOOP_RULE_COOKIE), flowCommandData.getCookie());
assertEquals(OfTable.INPUT, flowCommandData.getTable());
assertEquals(DROP_DISCOVERY_LOOP_RULE_PRIORITY, flowCommandData.getPriority());
FieldMatch ethDstMatch = getMatchByField(Field.ETH_DST, flowCommandData.getMatch());
assertEquals(new SwitchId(config.getDiscoveryBcastPacketDst()).toLong(), ethDstMatch.getValue());
assertFalse(ethDstMatch.isMasked());
FieldMatch ethSrcMatch = getMatchByField(Field.ETH_SRC, flowCommandData.getMatch());
assertEquals(sw.getSwitchId().toLong(), ethSrcMatch.getValue());
assertFalse(ethSrcMatch.isMasked());
assertNull(flowCommandData.getInstructions().getApplyActions());
assertNull(flowCommandData.getInstructions().getGoToMeter());
assertNull(flowCommandData.getInstructions().getGoToTable());
assertNull(flowCommandData.getInstructions().getWriteMetadata());
assertNull(flowCommandData.getInstructions().getWriteActions());
}
use of org.openkilda.rulemanager.match.FieldMatch in project open-kilda by telstra.
the class UniCastDiscoveryRuleGeneratorTest method checkMatch.
private void checkMatch(Set<FieldMatch> match) {
FieldMatch ethSrcMatch = getMatchByField(Field.ETH_SRC, match);
assertEquals(new SwitchId(config.getFlowPingMagicSrcMacAddress()).toLong(), ethSrcMatch.getValue());
assertTrue(ethSrcMatch.isMasked());
assertEquals(Mask.NO_MASK, ethSrcMatch.getMask().longValue());
FieldMatch ethDstMatch = getMatchByField(Field.ETH_DST, match);
assertEquals(sw.getSwitchId().toLong(), ethDstMatch.getValue());
assertTrue(ethDstMatch.isMasked());
assertEquals(Mask.NO_MASK, ethDstMatch.getMask().longValue());
}
use of org.openkilda.rulemanager.match.FieldMatch 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);
}
use of org.openkilda.rulemanager.match.FieldMatch in project open-kilda by telstra.
the class ArpPostIngressOneSwitchRuleGeneratorTest method checkMatch.
@Override
protected void checkMatch(Set<FieldMatch> match) {
assertEquals(1, match.size());
FieldMatch metadataMatch = getMatchByField(Field.METADATA, match);
RoutingMetadata expectedMetadata = RoutingMetadata.builder().arpFlag(true).oneSwitchFlowFlag(true).build(sw.getFeatures());
assertEquals(expectedMetadata.getValue(), metadataMatch.getValue());
assertTrue(metadataMatch.isMasked());
assertEquals(expectedMetadata.getMask(), metadataMatch.getMask().longValue());
}
use of org.openkilda.rulemanager.match.FieldMatch in project open-kilda by telstra.
the class ArpPostIngressVxlanRuleGeneratorTest method checkMatch.
@Override
protected void checkMatch(Set<FieldMatch> match) {
assertEquals(4, match.size());
FieldMatch metadataMatch = getMatchByField(Field.METADATA, match);
RoutingMetadata expectedMetadata = RoutingMetadata.builder().arpFlag(true).build(sw.getFeatures());
assertEquals(expectedMetadata.getValue(), metadataMatch.getValue());
assertTrue(metadataMatch.isMasked());
assertEquals(expectedMetadata.getMask(), metadataMatch.getMask().longValue());
FieldMatch ipProtoMatch = getMatchByField(Field.IP_PROTO, match);
assertEquals(IpProto.UDP, ipProtoMatch.getValue());
assertFalse(ipProtoMatch.isMasked());
FieldMatch udpSrcMatch = getMatchByField(Field.UDP_SRC, match);
assertEquals(ARP_VXLAN_UDP_SRC, udpSrcMatch.getValue());
assertFalse(udpSrcMatch.isMasked());
FieldMatch updDestMatch = getMatchByField(Field.UDP_DST, match);
assertEquals(VXLAN_UDP_DST, updDestMatch.getValue());
assertFalse(updDestMatch.isMasked());
}
Aggregations