use of org.openkilda.rulemanager.action.Action in project open-kilda by telstra.
the class MultiTableServer42IngressRuleGeneratorTest method assertInputCommand.
private void assertInputCommand(FlowSpeakerData command) {
assertEquals(SWITCH_1.getSwitchId(), command.getSwitchId());
assertEquals(SWITCH_1.getOfVersion(), command.getOfVersion().toString());
assertEquals(new PortColourCookie(SERVER_42_FLOW_RTT_INPUT, PORT_NUMBER_1), command.getCookie());
assertEquals(OfTable.INPUT, command.getTable());
assertEquals(Priority.SERVER_42_FLOW_RTT_INPUT_PRIORITY, command.getPriority());
assertTrue(command.getDependsOn().isEmpty());
Set<FieldMatch> expectedMatch = Sets.newHashSet(FieldMatch.builder().field(Field.IN_PORT).value(SERVER_42_PORT_NUMBER).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(PORT_NUMBER_1 + PORT_OFFSET).build(), FieldMatch.builder().field(Field.ETH_SRC).value(SERVER_42_MAC_ADDRESS.toLong()).build());
assertEqualsMatch(expectedMatch, command.getMatch());
List<Action> expectedApplyActions = newArrayList(SetFieldAction.builder().field(Field.UDP_SRC).value(SERVER_42_FLOW_RTT_FORWARD_UDP_PORT).build(), SetFieldAction.builder().field(Field.UDP_DST).value(SERVER_42_FLOW_RTT_FORWARD_UDP_PORT).build());
Instructions expectedInstructions = Instructions.builder().applyActions(expectedApplyActions).goToTable(OfTable.PRE_INGRESS).writeMetadata(mapMetadata(RoutingMetadata.builder().inputPort(PORT_NUMBER_1).build(SWITCH_1.getFeatures()))).build();
assertEquals(expectedInstructions, command.getInstructions());
assertTrue(command.getFlags().isEmpty());
}
use of org.openkilda.rulemanager.action.Action in project open-kilda by telstra.
the class MultiTableServer42IngressRuleGeneratorTest method buildTransformActionsVxlanEncapsulationFullPortTest.
@Test
public void buildTransformActionsVxlanEncapsulationFullPortTest() {
Flow flow = buildFlow(PATH, 0, 0);
MultiTableServer42IngressRuleGenerator generator = buildGenerator(PATH, flow, VXLAN_ENCAPSULATION);
List<Action> transformActions = generator.buildTransformActions(0, FEATURES);
List<Action> expectedActions = newArrayList(buildPushVxlan());
assertEquals(expectedActions, transformActions);
}
use of org.openkilda.rulemanager.action.Action in project open-kilda by telstra.
the class MultiTableServer42IngressRuleGeneratorTest method buildCommandsVxlanEncapsulationSingleVlanTest.
@Test
public void buildCommandsVxlanEncapsulationSingleVlanTest() {
Flow flow = buildFlow(PATH, OUTER_VLAN_ID_1, 0);
MultiTableServer42IngressRuleGenerator generator = buildGenerator(PATH, flow, VXLAN_ENCAPSULATION);
List<SpeakerData> commands = generator.generateCommands(SWITCH_1);
assertEquals(3, commands.size());
FlowSpeakerData ingressCommand = (FlowSpeakerData) commands.get(0);
FlowSpeakerData preIngressCommand = (FlowSpeakerData) commands.get(1);
FlowSpeakerData inputCustomerCommand = (FlowSpeakerData) commands.get(2);
assertPreIngressCommand(preIngressCommand, newArrayList(new PopVlanAction()));
assertInputCommand(inputCustomerCommand);
RoutingMetadata ingressMetadata = RoutingMetadata.builder().inputPort(PORT_NUMBER_1).outerVlanId(OUTER_VLAN_ID_1).build(SWITCH_1.getFeatures());
Set<FieldMatch> expectedIngressMatch = Sets.newHashSet(FieldMatch.builder().field(Field.IN_PORT).value(SERVER_42_PORT_NUMBER).build(), FieldMatch.builder().field(Field.METADATA).value(ingressMetadata.getValue()).mask(ingressMetadata.getMask()).build());
List<Action> expectedIngressActions = newArrayList(buildPushVxlan(), new PortOutAction(new PortNumber(PORT_NUMBER_2)));
assertIngressCommand(ingressCommand, Priority.SERVER_42_INGRESS_SINGLE_VLAN_FLOW_PRIORITY, expectedIngressMatch, expectedIngressActions);
}
use of org.openkilda.rulemanager.action.Action in project open-kilda by telstra.
the class MultiTableServer42IngressRuleGeneratorTest method buildTransformActionsVlanEncapsulationFullPortTest.
@Test
public void buildTransformActionsVlanEncapsulationFullPortTest() {
Flow flow = buildFlow(PATH, 0, 0);
MultiTableServer42IngressRuleGenerator generator = buildGenerator(PATH, flow, VLAN_ENCAPSULATION);
List<Action> transformActions = generator.buildTransformActions(0, FEATURES);
List<Action> expectedActions = newArrayList(SetFieldAction.builder().field(Field.ETH_SRC).value(SWITCH_ID_1.toMacAddressAsLong()).build(), SetFieldAction.builder().field(Field.ETH_DST).value(SWITCH_ID_2.toMacAddressAsLong()).build(), new PushVlanAction(), SetFieldAction.builder().field(Field.VLAN_VID).value(TRANSIT_VLAN_ID).build());
assertEquals(expectedActions, transformActions);
}
use of org.openkilda.rulemanager.action.Action in project open-kilda by telstra.
the class MultiTableServer42IngressRuleGeneratorTest method buildCommandsVlanEncapsulationDoubleVlanTest.
@Test
public void buildCommandsVlanEncapsulationDoubleVlanTest() {
Flow flow = buildFlow(PATH, OUTER_VLAN_ID_1, INNER_VLAN_ID_1);
MultiTableServer42IngressRuleGenerator generator = buildGenerator(PATH, flow, VLAN_ENCAPSULATION);
List<SpeakerData> commands = generator.generateCommands(SWITCH_1);
assertEquals(3, commands.size());
FlowSpeakerData ingressCommand = (FlowSpeakerData) commands.get(0);
FlowSpeakerData preIngressCommand = (FlowSpeakerData) commands.get(1);
FlowSpeakerData inputCustomerCommand = (FlowSpeakerData) commands.get(2);
assertPreIngressCommand(preIngressCommand, newArrayList(new PopVlanAction()));
assertInputCommand(inputCustomerCommand);
RoutingMetadata ingressMetadata = RoutingMetadata.builder().inputPort(PORT_NUMBER_1).outerVlanId(OUTER_VLAN_ID_1).build(SWITCH_1.getFeatures());
Set<FieldMatch> expectedIngressMatch = Sets.newHashSet(FieldMatch.builder().field(Field.IN_PORT).value(SERVER_42_PORT_NUMBER).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.ETH_SRC).value(SWITCH_ID_1.toMacAddressAsLong()).build(), SetFieldAction.builder().field(Field.ETH_DST).value(SWITCH_ID_2.toMacAddressAsLong()).build(), SetFieldAction.builder().field(Field.VLAN_VID).value(TRANSIT_VLAN_ID).build(), new PortOutAction(new PortNumber(PORT_NUMBER_2)));
assertIngressCommand(ingressCommand, Priority.SERVER_42_INGRESS_DOUBLE_VLAN_FLOW_PRIORITY, expectedIngressMatch, expectedIngressActions);
}
Aggregations