use of org.openkilda.rulemanager.match.FieldMatch in project open-kilda by telstra.
the class InputLldpRuleGeneratorTest method buildCorrectRuleForOf13Test.
@Test
public void buildCorrectRuleForOf13Test() {
FlowEndpoint endpoint = new FlowEndpoint(SW.getSwitchId(), PORT_NUMBER_1, 0, 0, true, false);
FlowSideAdapter overlapAdapter = new FlowSourceAdapter(Flow.builder().flowId("some").srcSwitch(SW).destSwitch(buildSwitch("OF_13", Collections.emptySet())).detectConnectedDevices(DetectConnectedDevices.builder().srcLldp(false).srcSwitchLldp(false).build()).build());
InputLldpRuleGenerator generator = InputLldpRuleGenerator.builder().ingressEndpoint(endpoint).multiTable(true).overlappingIngressAdapters(Sets.newHashSet(overlapAdapter)).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 PortColourCookie(CookieType.LLDP_INPUT_CUSTOMER_TYPE, PORT_NUMBER_1), flowCommandData.getCookie());
assertEquals(OfTable.INPUT, flowCommandData.getTable());
assertEquals(Priority.LLDP_INPUT_CUSTOMER_PRIORITY, flowCommandData.getPriority());
Set<FieldMatch> expectedMatch = Sets.newHashSet(FieldMatch.builder().field(Field.IN_PORT).value(PORT_NUMBER_1).build(), FieldMatch.builder().field(Field.ETH_TYPE).value(EthType.LLDP).build());
assertEqualsMatch(expectedMatch, flowCommandData.getMatch());
RoutingMetadata metadata = RoutingMetadata.builder().lldpFlag(true).build(SW.getFeatures());
Instructions expectedInstructions = Instructions.builder().writeMetadata(new OfMetadata(metadata.getValue(), metadata.getMask())).goToTable(OfTable.PRE_INGRESS).build();
assertEquals(expectedInstructions, flowCommandData.getInstructions());
assertTrue(flowCommandData.getFlags().isEmpty());
}
use of org.openkilda.rulemanager.match.FieldMatch in project open-kilda by telstra.
the class TransitYRuleGeneratorTest method assertTransitCommands.
private void assertTransitCommands(List<SpeakerData> commands, OfTable table, FlowTransitEncapsulation encapsulation) {
assertEquals(2, commands.size());
MeterSpeakerData meterCommandData = getCommand(MeterSpeakerData.class, commands);
FlowSpeakerData flowCommandData = getCommand(FlowSpeakerData.class, commands);
assertEquals(SWITCH_1.getSwitchId(), flowCommandData.getSwitchId());
assertEquals(SWITCH_1.getOfVersion(), flowCommandData.getOfVersion().toString());
assertTrue(flowCommandData.getDependsOn().contains(meterCommandData.getUuid()));
assertEquals(COOKIE, flowCommandData.getCookie());
assertEquals(table, flowCommandData.getTable());
assertEquals(Priority.Y_FLOW_PRIORITY, flowCommandData.getPriority());
Set<FieldMatch> expectedMatch;
if (encapsulation.getType().equals(FlowEncapsulationType.TRANSIT_VLAN)) {
expectedMatch = buildExpectedVlanMatch(PORT_NUMBER_1, encapsulation.getId());
} else {
expectedMatch = buildExpectedVxlanMatch(PORT_NUMBER_1, encapsulation.getId());
}
assertEqualsMatch(expectedMatch, flowCommandData.getMatch());
Instructions expectedInstructions = Instructions.builder().applyActions(Lists.newArrayList(new PortOutAction(new PortNumber(PORT_NUMBER_2)))).goToMeter(SHARED_METER_ID).build();
assertEquals(expectedInstructions, flowCommandData.getInstructions());
assertEquals(Sets.newHashSet(OfFlowFlag.RESET_COUNTERS), flowCommandData.getFlags());
}
use of org.openkilda.rulemanager.match.FieldMatch in project open-kilda by telstra.
the class IngressMirrorRuleGeneratorTest method buildSingleTableCommandsOneSwitchFullPortTest.
@Test
public void buildSingleTableCommandsOneSwitchFullPortTest() {
Flow flow = buildFlow(SINGLE_TABLE_ONE_SWITCH_PATH, 0, 0, 0, 0);
IngressMirrorRuleGenerator generator = buildGenerator(SINGLE_TABLE_ONE_SWITCH_PATH, flow, VXLAN_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 GroupAction(GROUP_ID));
assertIngressCommand(ingressCommand, Priority.MIRROR_DEFAULT_FLOW_PRIORITY, INPUT, 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 Server42FlowRttOutputVlanRuleGeneratorTest method shouldBuildCorrectRuleForOf13.
@Test
public void shouldBuildCorrectRuleForOf13() {
Switch sw = buildSwitch("OF_13", Sets.newHashSet(NOVIFLOW_COPY_FIELD));
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(SERVER_42_FLOW_RTT_OUTPUT_VLAN_COOKIE), flowCommandData.getCookie());
assertEquals(OfTable.INPUT, flowCommandData.getTable());
assertEquals(SERVER_42_FLOW_RTT_OUTPUT_VLAN_PRIORITY, flowCommandData.getPriority());
Set<FieldMatch> expectedMatch = Sets.newHashSet(FieldMatch.builder().field(Field.ETH_DST).value(sw.getSwitchId().toMacAddressAsLong()).build(), FieldMatch.builder().field(Field.ETH_TYPE).value(EthType.IPv4).build(), FieldMatch.builder().field(Field.IP_PROTO).value(IpProto.UDP).build(), FieldMatch.builder().field(Field.UDP_SRC).value(SERVER_42_FLOW_RTT_REVERSE_UDP_PORT).build(), FieldMatch.builder().field(Field.UDP_DST).value(SERVER_42_FLOW_RTT_FORWARD_UDP_PORT).build());
assertEquals(expectedMatch, flowCommandData.getMatch());
List<Action> expectedApplyActions = Lists.newArrayList(new PushVlanAction(), SetFieldAction.builder().field(Field.VLAN_VID).value(Utils.SERVER_42_VLAN).build(), SetFieldAction.builder().field(Field.ETH_SRC).value(sw.getSwitchId().toMacAddressAsLong()).build(), SetFieldAction.builder().field(Field.ETH_DST).value(Utils.SERVER_42_MAC_ADDRESS.toLong()).build(), CopyFieldAction.builder().oxmSrcHeader(OpenFlowOxms.NOVIFLOW_TX_TIMESTAMP).oxmDstHeader(OpenFlowOxms.NOVIFLOW_UDP_PAYLOAD_OFFSET).srcOffset(0).dstOffset(NOVIFLOW_TIMESTAMP_SIZE_IN_BITS).numberOfBits(NOVIFLOW_TIMESTAMP_SIZE_IN_BITS).build(), new PortOutAction(new PortNumber(Utils.SERVER_42_PORT)));
Instructions expectedInstructions = Instructions.builder().applyActions(expectedApplyActions).build();
assertEquals(expectedInstructions, flowCommandData.getInstructions());
}
use of org.openkilda.rulemanager.match.FieldMatch in project open-kilda by telstra.
the class EgressIslVxlanRuleGeneratorTest 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_EGRESS_RULES, ISL_PORT), flowCommandData.getCookie());
assertEquals(OfTable.INPUT, flowCommandData.getTable());
assertEquals(ISL_EGRESS_VXLAN_RULE_PRIORITY_MULTITABLE, flowCommandData.getPriority());
Set<FieldMatch> match = flowCommandData.getMatch();
assertEquals(6, match.size());
checkMatch(match, sw.getSwitchId());
FieldMatch ethTypeMatch = getMatchByField(Field.ETH_TYPE, match);
assertEquals(EthType.IPv4, ethTypeMatch.getValue());
assertFalse(ethTypeMatch.isMasked());
Instructions instructions = flowCommandData.getInstructions();
assertEquals(OfTable.EGRESS, instructions.getGoToTable());
}
Aggregations