Search in sources :

Example 76 with FieldMatch

use of org.openkilda.rulemanager.match.FieldMatch in project open-kilda by telstra.

the class ArpPostIngressRuleGeneratorTest 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());
}
Also used : FieldMatch(org.openkilda.rulemanager.match.FieldMatch) RoutingMetadata(org.openkilda.rulemanager.utils.RoutingMetadata)

Example 77 with FieldMatch

use of org.openkilda.rulemanager.match.FieldMatch in project open-kilda by telstra.

the class EgressIslVlanRuleGeneratorTest method shouldBuildCorrectRule.

@Test
public void shouldBuildCorrectRule() {
    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 PortColourCookie(CookieType.MULTI_TABLE_ISL_VLAN_EGRESS_RULES, ISL_PORT), flowCommandData.getCookie());
    assertEquals(OfTable.INPUT, flowCommandData.getTable());
    assertEquals(ISL_EGRESS_VLAN_RULE_PRIORITY_MULTITABLE, flowCommandData.getPriority());
    assertEquals(1, flowCommandData.getMatch().size());
    FieldMatch inPortMatch = getMatchByField(Field.IN_PORT, flowCommandData.getMatch());
    assertEquals(ISL_PORT, inPortMatch.getValue());
    assertFalse(inPortMatch.isMasked());
    Instructions instructions = flowCommandData.getInstructions();
    assertEquals(OfTable.EGRESS, instructions.getGoToTable());
}
Also used : FlowSpeakerData(org.openkilda.rulemanager.FlowSpeakerData) Switch(org.openkilda.model.Switch) Utils.buildSwitch(org.openkilda.rulemanager.Utils.buildSwitch) FieldMatch(org.openkilda.rulemanager.match.FieldMatch) Instructions(org.openkilda.rulemanager.Instructions) SpeakerData(org.openkilda.rulemanager.SpeakerData) FlowSpeakerData(org.openkilda.rulemanager.FlowSpeakerData) PortColourCookie(org.openkilda.model.cookie.PortColourCookie) Test(org.junit.Test)

Example 78 with FieldMatch

use of org.openkilda.rulemanager.match.FieldMatch in project open-kilda by telstra.

the class TransitIslVxlanRuleGeneratorTest method shouldBuildCorrectRuleWithNoviflowVxlanFeature.

@Test
public void shouldBuildCorrectRuleWithNoviflowVxlanFeature() {
    Switch sw = buildSwitch("OF_13", Sets.newHashSet(SwitchFeature.NOVIFLOW_PUSH_POP_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);
    Instructions instructions = flowCommandData.getInstructions();
    assertEquals(OfTable.TRANSIT, instructions.getGoToTable());
}
Also used : FlowSpeakerData(org.openkilda.rulemanager.FlowSpeakerData) Utils.buildSwitch(org.openkilda.rulemanager.Utils.buildSwitch) Switch(org.openkilda.model.Switch) FieldMatch(org.openkilda.rulemanager.match.FieldMatch) Instructions(org.openkilda.rulemanager.Instructions) SpeakerData(org.openkilda.rulemanager.SpeakerData) FlowSpeakerData(org.openkilda.rulemanager.FlowSpeakerData) PortColourCookie(org.openkilda.model.cookie.PortColourCookie) Test(org.junit.Test)

Example 79 with FieldMatch

use of org.openkilda.rulemanager.match.FieldMatch in project open-kilda by telstra.

the class LldpPostIngressRuleGeneratorTest method checkMatch.

@Override
protected void checkMatch(Set<FieldMatch> match) {
    assertEquals(1, match.size());
    FieldMatch metadataMatch = getMatchByField(Field.METADATA, match);
    RoutingMetadata expectedMetadata = RoutingMetadata.builder().lldpFlag(true).build(sw.getFeatures());
    assertEquals(expectedMetadata.getValue(), metadataMatch.getValue());
    assertTrue(metadataMatch.isMasked());
    assertEquals(expectedMetadata.getMask(), metadataMatch.getMask().longValue());
}
Also used : FieldMatch(org.openkilda.rulemanager.match.FieldMatch) RoutingMetadata(org.openkilda.rulemanager.utils.RoutingMetadata)

Example 80 with FieldMatch

use of org.openkilda.rulemanager.match.FieldMatch in project open-kilda by telstra.

the class FlowLoopTransitRuleGeneratorTest method assertTransitCommands.

private void assertTransitCommands(List<SpeakerData> commands, OfTable table, FlowTransitEncapsulation encapsulation) {
    assertEquals(1, commands.size());
    FlowSpeakerData flowCommandData = getCommand(FlowSpeakerData.class, commands);
    assertEquals(SWITCH_2.getSwitchId(), flowCommandData.getSwitchId());
    assertEquals(SWITCH_2.getOfVersion(), flowCommandData.getOfVersion().toString());
    assertTrue(flowCommandData.getDependsOn().isEmpty());
    assertEquals(LOOP_COOKIE, flowCommandData.getCookie());
    assertEquals(table, flowCommandData.getTable());
    assertEquals(Priority.LOOP_FLOW_PRIORITY, flowCommandData.getPriority());
    Set<FieldMatch> expectedMatch;
    List<Action> expectedApplyActions = new ArrayList<>();
    if (encapsulation.getType().equals(FlowEncapsulationType.TRANSIT_VLAN)) {
        expectedMatch = buildExpectedVlanMatch(PORT_NUMBER_1, encapsulation.getId());
    } else {
        expectedMatch = buildExpectedVxlanMatch(PORT_NUMBER_1, encapsulation.getId());
        expectedApplyActions.add(SetFieldAction.builder().field(Field.ETH_SRC).value(SWITCH_ID_2.getId()).build());
        expectedApplyActions.add(SetFieldAction.builder().field(Field.ETH_DST).value(SWITCH_ID_1.getId()).build());
    }
    assertEqualsMatch(expectedMatch, flowCommandData.getMatch());
    expectedApplyActions.add(new PortOutAction(new PortNumber(SpecialPortType.IN_PORT)));
    Instructions expectedInstructions = Instructions.builder().applyActions(expectedApplyActions).build();
    assertEquals(expectedInstructions, flowCommandData.getInstructions());
    assertTrue(flowCommandData.getFlags().isEmpty());
}
Also used : Action(org.openkilda.rulemanager.action.Action) PortOutAction(org.openkilda.rulemanager.action.PortOutAction) SetFieldAction(org.openkilda.rulemanager.action.SetFieldAction) FlowSpeakerData(org.openkilda.rulemanager.FlowSpeakerData) PortOutAction(org.openkilda.rulemanager.action.PortOutAction) FieldMatch(org.openkilda.rulemanager.match.FieldMatch) ArrayList(java.util.ArrayList) Instructions(org.openkilda.rulemanager.Instructions) PortNumber(org.openkilda.rulemanager.ProtoConstants.PortNumber)

Aggregations

FieldMatch (org.openkilda.rulemanager.match.FieldMatch)121 Test (org.junit.Test)61 FlowSpeakerData (org.openkilda.rulemanager.FlowSpeakerData)55 Instructions (org.openkilda.rulemanager.Instructions)55 SpeakerData (org.openkilda.rulemanager.SpeakerData)50 PortOutAction (org.openkilda.rulemanager.action.PortOutAction)50 Action (org.openkilda.rulemanager.action.Action)46 PortNumber (org.openkilda.rulemanager.ProtoConstants.PortNumber)41 SetFieldAction (org.openkilda.rulemanager.action.SetFieldAction)41 RoutingMetadata (org.openkilda.rulemanager.utils.RoutingMetadata)37 Flow (org.openkilda.model.Flow)31 Cookie (org.openkilda.model.cookie.Cookie)30 PushVlanAction (org.openkilda.rulemanager.action.PushVlanAction)27 MeterSpeakerData (org.openkilda.rulemanager.MeterSpeakerData)25 PopVlanAction (org.openkilda.rulemanager.action.PopVlanAction)24 PushVxlanAction (org.openkilda.rulemanager.action.PushVxlanAction)23 PortColourCookie (org.openkilda.model.cookie.PortColourCookie)15 FlowSourceAdapter (org.openkilda.adapter.FlowSourceAdapter)12 Switch (org.openkilda.model.Switch)12 GroupSpeakerData (org.openkilda.rulemanager.GroupSpeakerData)12