Search in sources :

Example 36 with Instructions

use of org.openkilda.rulemanager.Instructions 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 37 with Instructions

use of org.openkilda.rulemanager.Instructions 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)

Example 38 with Instructions

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

the class BroadCastDiscoveryRuleGeneratorTest method shouldBuildCorrectRuleWithGroupAndWithoutMeterForOf13.

@Test
public void shouldBuildCorrectRuleWithGroupAndWithoutMeterForOf13() {
    sw = buildSwitch("OF_13", Sets.newHashSet(GROUP_PACKET_OUT_CONTROLLER, MATCH_UDP_PORT, 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);
    GroupSpeakerData groupCommandData = getCommand(GroupSpeakerData.class, commands);
    assertEquals(1, flowCommandData.getDependsOn().size());
    assertTrue(flowCommandData.getDependsOn().contains(groupCommandData.getUuid()));
    // Check flow command
    checkFlowCommandBaseProperties(flowCommandData);
    Set<FieldMatch> match = flowCommandData.getMatch();
    assertEquals(4, match.size());
    checkEthDstMatch(match);
    checkUpdDstMatch(match);
    Instructions instructions = flowCommandData.getInstructions();
    assertEquals(1, instructions.getApplyActions().size());
    Action action = instructions.getApplyActions().get(0);
    checkGroupAction(action, groupCommandData.getGroupId());
    assertNull(instructions.getWriteActions());
    assertNull(instructions.getGoToMeter());
    assertNull(instructions.getGoToTable());
    // Check group command
    checkGroupCommand(groupCommandData);
}
Also used : MeterAction(org.openkilda.rulemanager.action.MeterAction) GroupAction(org.openkilda.rulemanager.action.GroupAction) SetFieldAction(org.openkilda.rulemanager.action.SetFieldAction) Action(org.openkilda.rulemanager.action.Action) PortOutAction(org.openkilda.rulemanager.action.PortOutAction) FlowSpeakerData(org.openkilda.rulemanager.FlowSpeakerData) FieldMatch(org.openkilda.rulemanager.match.FieldMatch) GroupSpeakerData(org.openkilda.rulemanager.GroupSpeakerData) Instructions(org.openkilda.rulemanager.Instructions) SpeakerData(org.openkilda.rulemanager.SpeakerData) MeterSpeakerData(org.openkilda.rulemanager.MeterSpeakerData) FlowSpeakerData(org.openkilda.rulemanager.FlowSpeakerData) GroupSpeakerData(org.openkilda.rulemanager.GroupSpeakerData) Test(org.junit.Test)

Example 39 with Instructions

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

the class BroadCastDiscoveryRuleGeneratorTest method shouldBuildCorrectRuleWithMeterAndWithoutGroupForOf13.

@Test
public void shouldBuildCorrectRuleWithMeterAndWithoutGroupForOf13() {
    sw = buildSwitch("OF_13", Sets.newHashSet(METERS, MATCH_UDP_PORT, 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(4, match.size());
    checkEthDstMatch(match);
    checkUpdDstMatch(match);
    Instructions instructions = flowCommandData.getInstructions();
    assertEquals(1, instructions.getApplyActions().size());
    Action first = instructions.getApplyActions().get(0);
    assertTrue(first instanceof PortOutAction);
    PortOutAction portOutAction = (PortOutAction) first;
    assertEquals(SpecialPortType.CONTROLLER, portOutAction.getPortNumber().getPortType());
    assertNull(instructions.getWriteActions());
    assertEquals(meterCommandData.getMeterId(), instructions.getGoToMeter());
    assertNull(instructions.getGoToTable());
    // Check meter command
    checkMeterCommand(meterCommandData);
}
Also used : MeterSpeakerData(org.openkilda.rulemanager.MeterSpeakerData) MeterAction(org.openkilda.rulemanager.action.MeterAction) GroupAction(org.openkilda.rulemanager.action.GroupAction) SetFieldAction(org.openkilda.rulemanager.action.SetFieldAction) Action(org.openkilda.rulemanager.action.Action) PortOutAction(org.openkilda.rulemanager.action.PortOutAction) FlowSpeakerData(org.openkilda.rulemanager.FlowSpeakerData) PortOutAction(org.openkilda.rulemanager.action.PortOutAction) FieldMatch(org.openkilda.rulemanager.match.FieldMatch) Instructions(org.openkilda.rulemanager.Instructions) SpeakerData(org.openkilda.rulemanager.SpeakerData) MeterSpeakerData(org.openkilda.rulemanager.MeterSpeakerData) FlowSpeakerData(org.openkilda.rulemanager.FlowSpeakerData) GroupSpeakerData(org.openkilda.rulemanager.GroupSpeakerData) Test(org.junit.Test)

Example 40 with Instructions

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

the class BroadCastDiscoveryRuleGeneratorTest method shouldBuildCorrectRuleWithoutMeterAndGroupForOf13.

@Test
public void shouldBuildCorrectRuleWithoutMeterAndGroupForOf13() {
    sw = buildSwitch("OF_13", Sets.newHashSet(MATCH_UDP_PORT, 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);
    Set<FieldMatch> match = flowCommandData.getMatch();
    assertEquals(4, match.size());
    checkEthDstMatch(match);
    checkUpdDstMatch(match);
    // Check flow command has correct instructions without meter and group
    Instructions instructions = flowCommandData.getInstructions();
    assertEquals(1, instructions.getApplyActions().size());
    Action first = instructions.getApplyActions().get(0);
    assertTrue(first instanceof PortOutAction);
    PortOutAction portOutAction = (PortOutAction) first;
    assertEquals(SpecialPortType.CONTROLLER, portOutAction.getPortNumber().getPortType());
    assertNull(instructions.getWriteActions());
    assertNull(instructions.getGoToMeter());
    assertNull(instructions.getGoToTable());
}
Also used : MeterAction(org.openkilda.rulemanager.action.MeterAction) GroupAction(org.openkilda.rulemanager.action.GroupAction) SetFieldAction(org.openkilda.rulemanager.action.SetFieldAction) Action(org.openkilda.rulemanager.action.Action) PortOutAction(org.openkilda.rulemanager.action.PortOutAction) FlowSpeakerData(org.openkilda.rulemanager.FlowSpeakerData) PortOutAction(org.openkilda.rulemanager.action.PortOutAction) FieldMatch(org.openkilda.rulemanager.match.FieldMatch) Instructions(org.openkilda.rulemanager.Instructions) SpeakerData(org.openkilda.rulemanager.SpeakerData) MeterSpeakerData(org.openkilda.rulemanager.MeterSpeakerData) FlowSpeakerData(org.openkilda.rulemanager.FlowSpeakerData) GroupSpeakerData(org.openkilda.rulemanager.GroupSpeakerData) Test(org.junit.Test)

Aggregations

Instructions (org.openkilda.rulemanager.Instructions)84 FieldMatch (org.openkilda.rulemanager.match.FieldMatch)55 PortOutAction (org.openkilda.rulemanager.action.PortOutAction)40 FlowSpeakerData (org.openkilda.rulemanager.FlowSpeakerData)35 Action (org.openkilda.rulemanager.action.Action)34 Cookie (org.openkilda.model.cookie.Cookie)31 SpeakerData (org.openkilda.rulemanager.SpeakerData)29 Test (org.junit.Test)26 PortNumber (org.openkilda.rulemanager.ProtoConstants.PortNumber)25 SetFieldAction (org.openkilda.rulemanager.action.SetFieldAction)24 ArrayList (java.util.ArrayList)14 PortColourCookie (org.openkilda.model.cookie.PortColourCookie)14 RoutingMetadata (org.openkilda.rulemanager.utils.RoutingMetadata)13 Switch (org.openkilda.model.Switch)12 Utils.buildSwitch (org.openkilda.rulemanager.Utils.buildSwitch)12 MeterSpeakerData (org.openkilda.rulemanager.MeterSpeakerData)11 PopVxlanAction (org.openkilda.rulemanager.action.PopVxlanAction)10 MeterAction (org.openkilda.rulemanager.action.MeterAction)9 PushVlanAction (org.openkilda.rulemanager.action.PushVlanAction)9 OfMetadata (org.openkilda.rulemanager.OfMetadata)8