Search in sources :

Example 91 with FlowSpeakerData

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

the class EgressMirrorRuleGeneratorTest method buildVxlanSingleTableOuterVlanEgressMirrorRuleTest.

@Test
public void buildVxlanSingleTableOuterVlanEgressMirrorRuleTest() {
    FlowPath path = buildPathWithMirror(false);
    Flow flow = buildFlow(path, OUTER_VLAN_ID, 0);
    EgressMirrorRuleGenerator generator = buildGenerator(path, flow, VXLAN_ENCAPSULATION);
    List<SpeakerData> commands = generator.generateCommands(SWITCH_2);
    assertEquals(2, commands.size());
    FlowSpeakerData egressCommand = getCommand(FlowSpeakerData.class, commands);
    GroupSpeakerData groupCommand = getCommand(GroupSpeakerData.class, commands);
    ArrayList<Action> expectedApplyActions = Lists.newArrayList(new PopVxlanAction(ActionType.POP_VXLAN_NOVIFLOW), new PushVlanAction(), SetFieldAction.builder().field(Field.VLAN_VID).value(OUTER_VLAN_ID).build(), new GroupAction(GROUP_ID));
    assertEgressCommand(egressCommand, OfTable.INPUT, VXLAN_ENCAPSULATION, expectedApplyActions, groupCommand.getUuid());
    assertGroupCommand(groupCommand);
}
Also used : GroupAction(org.openkilda.rulemanager.action.GroupAction) GroupAction(org.openkilda.rulemanager.action.GroupAction) SetFieldAction(org.openkilda.rulemanager.action.SetFieldAction) Action(org.openkilda.rulemanager.action.Action) PopVxlanAction(org.openkilda.rulemanager.action.PopVxlanAction) PushVlanAction(org.openkilda.rulemanager.action.PushVlanAction) PopVlanAction(org.openkilda.rulemanager.action.PopVlanAction) PortOutAction(org.openkilda.rulemanager.action.PortOutAction) FlowSpeakerData(org.openkilda.rulemanager.FlowSpeakerData) PopVxlanAction(org.openkilda.rulemanager.action.PopVxlanAction) PushVlanAction(org.openkilda.rulemanager.action.PushVlanAction) GroupSpeakerData(org.openkilda.rulemanager.GroupSpeakerData) FlowPath(org.openkilda.model.FlowPath) SpeakerData(org.openkilda.rulemanager.SpeakerData) FlowSpeakerData(org.openkilda.rulemanager.FlowSpeakerData) GroupSpeakerData(org.openkilda.rulemanager.GroupSpeakerData) Flow(org.openkilda.model.Flow) Test(org.junit.Test)

Example 92 with FlowSpeakerData

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

the class EgressMirrorRuleGeneratorTest method buildVxlanMultiTableOuterInnerVlanEgressMirrorRuleTest.

@Test
public void buildVxlanMultiTableOuterInnerVlanEgressMirrorRuleTest() {
    FlowPath path = buildPathWithMirror(true);
    Flow flow = buildFlow(path, OUTER_VLAN_ID, INNER_VLAN_ID);
    EgressMirrorRuleGenerator generator = buildGenerator(path, flow, VXLAN_ENCAPSULATION);
    List<SpeakerData> commands = generator.generateCommands(SWITCH_2);
    assertEquals(2, commands.size());
    FlowSpeakerData egressCommand = getCommand(FlowSpeakerData.class, commands);
    GroupSpeakerData groupCommand = getCommand(GroupSpeakerData.class, commands);
    ArrayList<Action> expectedApplyActions = Lists.newArrayList(new PopVxlanAction(ActionType.POP_VXLAN_NOVIFLOW), new PushVlanAction(), SetFieldAction.builder().field(Field.VLAN_VID).value(INNER_VLAN_ID).build(), new PushVlanAction(), SetFieldAction.builder().field(Field.VLAN_VID).value(OUTER_VLAN_ID).build(), new GroupAction(GROUP_ID));
    assertEgressCommand(egressCommand, OfTable.EGRESS, VXLAN_ENCAPSULATION, expectedApplyActions, groupCommand.getUuid());
    assertGroupCommand(groupCommand);
}
Also used : GroupAction(org.openkilda.rulemanager.action.GroupAction) GroupAction(org.openkilda.rulemanager.action.GroupAction) SetFieldAction(org.openkilda.rulemanager.action.SetFieldAction) Action(org.openkilda.rulemanager.action.Action) PopVxlanAction(org.openkilda.rulemanager.action.PopVxlanAction) PushVlanAction(org.openkilda.rulemanager.action.PushVlanAction) PopVlanAction(org.openkilda.rulemanager.action.PopVlanAction) PortOutAction(org.openkilda.rulemanager.action.PortOutAction) FlowSpeakerData(org.openkilda.rulemanager.FlowSpeakerData) PopVxlanAction(org.openkilda.rulemanager.action.PopVxlanAction) PushVlanAction(org.openkilda.rulemanager.action.PushVlanAction) GroupSpeakerData(org.openkilda.rulemanager.GroupSpeakerData) FlowPath(org.openkilda.model.FlowPath) SpeakerData(org.openkilda.rulemanager.SpeakerData) FlowSpeakerData(org.openkilda.rulemanager.FlowSpeakerData) GroupSpeakerData(org.openkilda.rulemanager.GroupSpeakerData) Flow(org.openkilda.model.Flow) Test(org.junit.Test)

Example 93 with FlowSpeakerData

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

the class EgressMirrorRuleGeneratorTest method buildVlanMultiTableOuterVlanEgressMirrorRuleTest.

@Test
public void buildVlanMultiTableOuterVlanEgressMirrorRuleTest() {
    FlowPath path = buildPathWithMirror(true);
    Flow flow = buildFlow(path, OUTER_VLAN_ID, 0);
    EgressMirrorRuleGenerator generator = buildGenerator(path, flow, VLAN_ENCAPSULATION);
    List<SpeakerData> commands = generator.generateCommands(SWITCH_2);
    assertEquals(2, commands.size());
    FlowSpeakerData egressCommand = getCommand(FlowSpeakerData.class, commands);
    GroupSpeakerData groupCommand = getCommand(GroupSpeakerData.class, commands);
    ArrayList<Action> expectedApplyActions = Lists.newArrayList(SetFieldAction.builder().field(Field.VLAN_VID).value(OUTER_VLAN_ID).build(), new GroupAction(GROUP_ID));
    assertEgressCommand(egressCommand, OfTable.EGRESS, VLAN_ENCAPSULATION, expectedApplyActions, groupCommand.getUuid());
    assertGroupCommand(groupCommand);
}
Also used : GroupAction(org.openkilda.rulemanager.action.GroupAction) GroupAction(org.openkilda.rulemanager.action.GroupAction) SetFieldAction(org.openkilda.rulemanager.action.SetFieldAction) Action(org.openkilda.rulemanager.action.Action) PopVxlanAction(org.openkilda.rulemanager.action.PopVxlanAction) PushVlanAction(org.openkilda.rulemanager.action.PushVlanAction) PopVlanAction(org.openkilda.rulemanager.action.PopVlanAction) PortOutAction(org.openkilda.rulemanager.action.PortOutAction) FlowSpeakerData(org.openkilda.rulemanager.FlowSpeakerData) GroupSpeakerData(org.openkilda.rulemanager.GroupSpeakerData) FlowPath(org.openkilda.model.FlowPath) SpeakerData(org.openkilda.rulemanager.SpeakerData) FlowSpeakerData(org.openkilda.rulemanager.FlowSpeakerData) GroupSpeakerData(org.openkilda.rulemanager.GroupSpeakerData) Flow(org.openkilda.model.Flow) Test(org.junit.Test)

Example 94 with FlowSpeakerData

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

the class EgressRuleGeneratorTest method assertEgressCommands.

private void assertEgressCommands(List<SpeakerData> commands, OfTable table, FlowTransitEncapsulation encapsulation, List<Action> expectedApplyActions) {
    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(COOKIE, flowCommandData.getCookie());
    assertEquals(table, flowCommandData.getTable());
    assertEquals(Priority.FLOW_PRIORITY, flowCommandData.getPriority());
    Set<FieldMatch> expectedMatch;
    if (encapsulation.getType().equals(FlowEncapsulationType.TRANSIT_VLAN)) {
        expectedMatch = buildExpectedVlanMatch(PORT_NUMBER_3, encapsulation.getId());
    } else {
        expectedMatch = buildExpectedVxlanMatch(PORT_NUMBER_3, encapsulation.getId());
    }
    assertEqualsMatch(expectedMatch, flowCommandData.getMatch());
    Instructions expectedInstructions = Instructions.builder().applyActions(expectedApplyActions).build();
    assertEquals(expectedInstructions, flowCommandData.getInstructions());
    assertTrue(flowCommandData.getFlags().isEmpty());
}
Also used : FlowSpeakerData(org.openkilda.rulemanager.FlowSpeakerData) FieldMatch(org.openkilda.rulemanager.match.FieldMatch) Instructions(org.openkilda.rulemanager.Instructions)

Example 95 with FlowSpeakerData

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

the class ConnectedDevicesRuleGeneratorTest method shouldBuildCorrectRuleWithMeterForOf15.

@Test
public void shouldBuildCorrectRuleWithMeterForOf15() {
    sw = buildSwitch("OF_15", expectedFeatures);
    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()));
    assertTrue(meterCommandData.getDependsOn().isEmpty());
    // Check flow command
    checkFlowCommandBaseProperties(flowCommandData);
    checkMatch(flowCommandData.getMatch());
    // Check correct meter instructions for OF 1.5
    checkInstructionsOf15(flowCommandData.getInstructions(), meterCommandData.getMeterId());
    // Check meter command
    checkMeterCommand(meterCommandData);
}
Also used : MeterSpeakerData(org.openkilda.rulemanager.MeterSpeakerData) FlowSpeakerData(org.openkilda.rulemanager.FlowSpeakerData) 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