Search in sources :

Example 86 with FieldMatch

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());
}
Also used : Cookie(org.openkilda.model.cookie.Cookie) FlowSpeakerData(org.openkilda.rulemanager.FlowSpeakerData) Switch(org.openkilda.model.Switch) Utils.buildSwitch(org.openkilda.rulemanager.Utils.buildSwitch) FieldMatch(org.openkilda.rulemanager.match.FieldMatch) SwitchId(org.openkilda.model.SwitchId) SpeakerData(org.openkilda.rulemanager.SpeakerData) FlowSpeakerData(org.openkilda.rulemanager.FlowSpeakerData) Test(org.junit.Test)

Example 87 with FieldMatch

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());
}
Also used : FieldMatch(org.openkilda.rulemanager.match.FieldMatch) SwitchId(org.openkilda.model.SwitchId)

Example 88 with FieldMatch

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);
}
Also used : MeterSpeakerData(org.openkilda.rulemanager.MeterSpeakerData) FlowSpeakerData(org.openkilda.rulemanager.FlowSpeakerData) FieldMatch(org.openkilda.rulemanager.match.FieldMatch) MeterSpeakerData(org.openkilda.rulemanager.MeterSpeakerData) SpeakerData(org.openkilda.rulemanager.SpeakerData) FlowSpeakerData(org.openkilda.rulemanager.FlowSpeakerData) Test(org.junit.Test)

Example 89 with FieldMatch

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

Example 90 with FieldMatch

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

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