Search in sources :

Example 46 with FlowSpeakerData

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

the class TransitIslVxlanRuleGeneratorTest 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_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);
    FieldMatch ethTypeMatch = getMatchByField(Field.ETH_TYPE, match);
    assertEquals(EthType.IPv4, ethTypeMatch.getValue());
    assertFalse(ethTypeMatch.isMasked());
    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 47 with FlowSpeakerData

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

the class UniCastDiscoveryRuleGeneratorTest method shouldBuildCorrectRuleWithMeterForOf15.

@Test
public void shouldBuildCorrectRuleWithMeterForOf15() {
    sw = buildSwitch("OF_15", 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);
    // Check flow command has correct instructions for OF 1.5
    Instructions instructions = flowCommandData.getInstructions();
    assertEquals(3, instructions.getApplyActions().size());
    Action first = instructions.getApplyActions().get(0);
    assertTrue(first instanceof MeterAction);
    MeterAction meterAction = (MeterAction) first;
    assertEquals(meterCommandData.getMeterId(), meterAction.getMeterId());
    checkPortOutAction(instructions.getApplyActions().get(1));
    checkSetFieldAction(instructions.getApplyActions().get(2));
    assertNull(instructions.getWriteActions());
    assertNull(instructions.getGoToMeter());
    assertNull(instructions.getGoToTable());
    // Check meter command
    checkMeterCommand(meterCommandData);
}
Also used : MeterSpeakerData(org.openkilda.rulemanager.MeterSpeakerData) MeterAction(org.openkilda.rulemanager.action.MeterAction) Action(org.openkilda.rulemanager.action.Action) PortOutAction(org.openkilda.rulemanager.action.PortOutAction) SetFieldAction(org.openkilda.rulemanager.action.SetFieldAction) FlowSpeakerData(org.openkilda.rulemanager.FlowSpeakerData) FieldMatch(org.openkilda.rulemanager.match.FieldMatch) MeterAction(org.openkilda.rulemanager.action.MeterAction) Instructions(org.openkilda.rulemanager.Instructions) MeterSpeakerData(org.openkilda.rulemanager.MeterSpeakerData) SpeakerData(org.openkilda.rulemanager.SpeakerData) FlowSpeakerData(org.openkilda.rulemanager.FlowSpeakerData) Test(org.junit.Test)

Example 48 with FlowSpeakerData

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

the class UniCastDiscoveryRuleGeneratorTest method shouldBuildCorrectRuleWithMeterInBytesForOf13.

@Test
public void shouldBuildCorrectRuleWithMeterInBytesForOf13() {
    sw = buildSwitch("OF_13", Sets.newHashSet(METERS));
    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
    assertEquals(createMeterIdForDefaultRule(VERIFICATION_UNICAST_RULE_COOKIE), meterCommandData.getMeterId());
    long expectedRate = Meter.convertRateToKiloBits(config.getUnicastRateLimit(), config.getDiscoPacketSize());
    assertEquals(expectedRate, meterCommandData.getRate());
    long expectedBurst = Meter.convertBurstSizeToKiloBits(config.getSystemMeterBurstSizeInPackets(), config.getDiscoPacketSize());
    assertEquals(expectedBurst, meterCommandData.getBurst());
    assertEquals(3, meterCommandData.getFlags().size());
    assertTrue(Sets.newHashSet(MeterFlag.BURST, MeterFlag.STATS, MeterFlag.KBPS).containsAll(meterCommandData.getFlags()));
}
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 49 with FlowSpeakerData

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

the class UniCastDiscoveryRuleGeneratorTest method shouldBuildCorrectRuleWithoutMeterForOf13.

@Test
public void shouldBuildCorrectRuleWithoutMeterForOf13() {
    sw = buildSwitch("OF_13", Collections.emptySet());
    List<SpeakerData> commands = generator.generateCommands(sw);
    assertEquals(1, 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);
    assertTrue(flowCommandData.getDependsOn().isEmpty());
    // Check flow command
    checkFlowCommandBaseProperties(flowCommandData);
    Set<FieldMatch> match = flowCommandData.getMatch();
    assertEquals(2, match.size());
    checkMatch(match);
    Instructions instructions = flowCommandData.getInstructions();
    assertEquals(2, instructions.getApplyActions().size());
    checkPortOutAction(instructions.getApplyActions().get(0));
    checkSetFieldAction(instructions.getApplyActions().get(1));
    assertNull(instructions.getWriteActions());
    assertNull(instructions.getGoToMeter());
    assertNull(instructions.getGoToTable());
}
Also used : FlowSpeakerData(org.openkilda.rulemanager.FlowSpeakerData) FieldMatch(org.openkilda.rulemanager.match.FieldMatch) Instructions(org.openkilda.rulemanager.Instructions) MeterSpeakerData(org.openkilda.rulemanager.MeterSpeakerData) SpeakerData(org.openkilda.rulemanager.SpeakerData) FlowSpeakerData(org.openkilda.rulemanager.FlowSpeakerData) Test(org.junit.Test)

Example 50 with FlowSpeakerData

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

the class UnicastVerificationVxlanRuleGeneratorTest method shouldBuildCorrectRuleWithoutMeterForOf13.

@Test
public void shouldBuildCorrectRuleWithoutMeterForOf13() {
    sw = buildSwitch("OF_13", Sets.newHashSet(NOVIFLOW_PUSH_POP_VXLAN, PKTPS_FLAG));
    List<SpeakerData> commands = generator.generateCommands(sw);
    assertEquals(1, 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);
    assertTrue(flowCommandData.getDependsOn().isEmpty());
    // Check flow command
    checkFlowCommandBaseProperties(flowCommandData);
    checkMatch(flowCommandData.getMatch());
    // Check instructions without meter
    Instructions instructions = flowCommandData.getInstructions();
    assertEquals(3, instructions.getApplyActions().size());
    Action first = instructions.getApplyActions().get(0);
    assertTrue(first instanceof PopVxlanAction);
    PopVxlanAction popVxlanAction = (PopVxlanAction) first;
    assertEquals(ActionType.POP_VXLAN_NOVIFLOW, popVxlanAction.getType());
    Action second = instructions.getApplyActions().get(1);
    assertTrue(second instanceof PortOutAction);
    PortOutAction sendToControllerAction = (PortOutAction) second;
    assertEquals(SpecialPortType.CONTROLLER, sendToControllerAction.getPortNumber().getPortType());
    assertNull(instructions.getWriteActions());
    assertNull(instructions.getGoToMeter());
    assertNull(instructions.getGoToTable());
}
Also used : MeterAction(org.openkilda.rulemanager.action.MeterAction) Action(org.openkilda.rulemanager.action.Action) PopVxlanAction(org.openkilda.rulemanager.action.PopVxlanAction) PortOutAction(org.openkilda.rulemanager.action.PortOutAction) FlowSpeakerData(org.openkilda.rulemanager.FlowSpeakerData) PortOutAction(org.openkilda.rulemanager.action.PortOutAction) PopVxlanAction(org.openkilda.rulemanager.action.PopVxlanAction) Instructions(org.openkilda.rulemanager.Instructions) MeterSpeakerData(org.openkilda.rulemanager.MeterSpeakerData) SpeakerData(org.openkilda.rulemanager.SpeakerData) FlowSpeakerData(org.openkilda.rulemanager.FlowSpeakerData) Test(org.junit.Test)

Aggregations

FlowSpeakerData (org.openkilda.rulemanager.FlowSpeakerData)106 SpeakerData (org.openkilda.rulemanager.SpeakerData)88 Test (org.junit.Test)83 PortOutAction (org.openkilda.rulemanager.action.PortOutAction)58 FieldMatch (org.openkilda.rulemanager.match.FieldMatch)55 Action (org.openkilda.rulemanager.action.Action)54 SetFieldAction (org.openkilda.rulemanager.action.SetFieldAction)49 MeterSpeakerData (org.openkilda.rulemanager.MeterSpeakerData)42 PushVlanAction (org.openkilda.rulemanager.action.PushVlanAction)38 Flow (org.openkilda.model.Flow)35 Instructions (org.openkilda.rulemanager.Instructions)35 PortNumber (org.openkilda.rulemanager.ProtoConstants.PortNumber)35 PopVlanAction (org.openkilda.rulemanager.action.PopVlanAction)35 GroupSpeakerData (org.openkilda.rulemanager.GroupSpeakerData)33 GroupAction (org.openkilda.rulemanager.action.GroupAction)23 PushVxlanAction (org.openkilda.rulemanager.action.PushVxlanAction)22 PopVxlanAction (org.openkilda.rulemanager.action.PopVxlanAction)18 Cookie (org.openkilda.model.cookie.Cookie)15 FlowPath (org.openkilda.model.FlowPath)14 Switch (org.openkilda.model.Switch)14