use of org.openkilda.rulemanager.match.FieldMatch in project open-kilda by telstra.
the class ArpIngressRuleGeneratorTest 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).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 UnicastVerificationVxlanRuleGeneratorTest method checkMatch.
private void checkMatch(Set<FieldMatch> match) {
assertEquals(5, match.size());
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());
FieldMatch ipProtoMatch = getMatchByField(Field.IP_PROTO, match);
assertEquals(IpProto.UDP, ipProtoMatch.getValue());
assertFalse(ipProtoMatch.isMasked());
FieldMatch ethTypeMatch = getMatchByField(Field.ETH_TYPE, match);
assertEquals(EthType.IPv4, ethTypeMatch.getValue());
assertFalse(ethTypeMatch.isMasked());
FieldMatch updDestMatch = getMatchByField(Field.UDP_SRC, match);
assertEquals(STUB_VXLAN_UDP_SRC, updDestMatch.getValue());
assertFalse(updDestMatch.isMasked());
}
use of org.openkilda.rulemanager.match.FieldMatch in project open-kilda by telstra.
the class ArpTransitRuleGeneratorTest method checkMatch.
@Override
protected void checkMatch(Set<FieldMatch> match) {
assertEquals(1, match.size());
FieldMatch ethTypeMatch = getMatchByField(Field.ETH_TYPE, match);
assertEquals(EthType.ARP, ethTypeMatch.getValue());
assertFalse(ethTypeMatch.isMasked());
}
use of org.openkilda.rulemanager.match.FieldMatch 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);
}
use of org.openkilda.rulemanager.match.FieldMatch in project open-kilda by telstra.
the class BroadCastDiscoveryRuleGeneratorTest method shouldBuildCorrectRuleWithGroupAndWithoutMeterForOf13.
@Test
public void shouldBuildCorrectRuleWithGroupAndWithoutMeterForOf13() {
sw = buildSwitch("OF_13", Sets.newHashSet(GROUP_PACKET_OUT_CONTROLLER, MATCH_UDP_PORT, 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);
GroupSpeakerData groupCommandData = getCommand(GroupSpeakerData.class, commands);
assertEquals(1, flowCommandData.getDependsOn().size());
assertTrue(flowCommandData.getDependsOn().contains(groupCommandData.getUuid()));
// Check flow command
checkFlowCommandBaseProperties(flowCommandData);
Set<FieldMatch> match = flowCommandData.getMatch();
assertEquals(4, match.size());
checkEthDstMatch(match);
checkUpdDstMatch(match);
Instructions instructions = flowCommandData.getInstructions();
assertEquals(1, instructions.getApplyActions().size());
Action action = instructions.getApplyActions().get(0);
checkGroupAction(action, groupCommandData.getGroupId());
assertNull(instructions.getWriteActions());
assertNull(instructions.getGoToMeter());
assertNull(instructions.getGoToTable());
// Check group command
checkGroupCommand(groupCommandData);
}
Aggregations