Search in sources :

Example 21 with GroupSpeakerData

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

the class IngressMirrorRuleGeneratorTest method buildCommandsVxlanEncapsulationDoubleVlanTest.

@Test
public void buildCommandsVxlanEncapsulationDoubleVlanTest() {
    Flow flow = buildFlow(MULTI_TABLE_PATH, OUTER_VLAN_ID_1, INNER_VLAN_ID_1);
    IngressMirrorRuleGenerator generator = buildGenerator(MULTI_TABLE_PATH, flow, VXLAN_ENCAPSULATION);
    List<SpeakerData> commands = generator.generateCommands(SWITCH_1);
    assertEquals(2, commands.size());
    FlowSpeakerData ingressCommand = getCommand(FlowSpeakerData.class, commands);
    GroupSpeakerData groupCommand = getCommand(GroupSpeakerData.class, commands);
    RoutingMetadata ingressMetadata = RoutingMetadata.builder().outerVlanId(OUTER_VLAN_ID_1).build(SWITCH_1.getFeatures());
    Set<FieldMatch> expectedIngressMatch = Sets.newHashSet(FieldMatch.builder().field(Field.IN_PORT).value(PORT_NUMBER_1).build(), FieldMatch.builder().field(Field.VLAN_VID).value(INNER_VLAN_ID_1).build(), FieldMatch.builder().field(Field.METADATA).value(ingressMetadata.getValue()).mask(ingressMetadata.getMask()).build());
    List<Action> expectedIngressActions = newArrayList(new PopVlanAction(), new GroupAction(GROUP_ID));
    assertIngressCommand(ingressCommand, Priority.MIRROR_DOUBLE_VLAN_FLOW_PRIORITY, INGRESS, expectedIngressMatch, expectedIngressActions, METER_ID, groupCommand.getUuid());
    Set<Action> expectedFlowBucketActions = newHashSet(buildPushVxlan(), new PortOutAction(new PortNumber(PORT_NUMBER_2)));
    assertGroupCommand(groupCommand, expectedFlowBucketActions);
}
Also used : GroupAction(org.openkilda.rulemanager.action.GroupAction) SetFieldAction(org.openkilda.rulemanager.action.SetFieldAction) Action(org.openkilda.rulemanager.action.Action) PushVxlanAction(org.openkilda.rulemanager.action.PushVxlanAction) PushVlanAction(org.openkilda.rulemanager.action.PushVlanAction) PopVlanAction(org.openkilda.rulemanager.action.PopVlanAction) PortOutAction(org.openkilda.rulemanager.action.PortOutAction) PortOutAction(org.openkilda.rulemanager.action.PortOutAction) FieldMatch(org.openkilda.rulemanager.match.FieldMatch) GroupSpeakerData(org.openkilda.rulemanager.GroupSpeakerData) RoutingMetadata(org.openkilda.rulemanager.utils.RoutingMetadata) Flow(org.openkilda.model.Flow) PopVlanAction(org.openkilda.rulemanager.action.PopVlanAction) GroupAction(org.openkilda.rulemanager.action.GroupAction) FlowSpeakerData(org.openkilda.rulemanager.FlowSpeakerData) PortNumber(org.openkilda.rulemanager.ProtoConstants.PortNumber) SpeakerData(org.openkilda.rulemanager.SpeakerData) FlowSpeakerData(org.openkilda.rulemanager.FlowSpeakerData) GroupSpeakerData(org.openkilda.rulemanager.GroupSpeakerData) Test(org.junit.Test)

Example 22 with GroupSpeakerData

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

the class BroadCastDiscoveryRuleGeneratorTest method shouldBuildCorrectRuleWithMeterAndGroupForOf13.

@Test
public void shouldBuildCorrectRuleWithMeterAndGroupForOf13() {
    sw = buildSwitch("OF_13", Sets.newHashSet(METERS, GROUP_PACKET_OUT_CONTROLLER, MATCH_UDP_PORT, PKTPS_FLAG));
    List<SpeakerData> commands = generator.generateCommands(sw);
    assertEquals(3, 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);
    GroupSpeakerData groupCommandData = getCommand(GroupSpeakerData.class, commands);
    assertEquals(2, flowCommandData.getDependsOn().size());
    assertTrue(flowCommandData.getDependsOn().contains(meterCommandData.getUuid()));
    assertTrue(flowCommandData.getDependsOn().contains(groupCommandData.getUuid()));
    // Check flow command
    checkFlowCommandBaseProperties(flowCommandData);
    Set<FieldMatch> match = flowCommandData.getMatch();
    assertEquals(4, match.size());
    checkEthDstMatch(match);
    checkUpdDstMatch(match);
    checkGroupInstructions(flowCommandData.getInstructions(), meterCommandData.getMeterId(), groupCommandData.getGroupId());
    // Check meter command
    checkMeterCommand(meterCommandData);
    // Check group command
    checkGroupCommand(groupCommandData);
}
Also used : MeterSpeakerData(org.openkilda.rulemanager.MeterSpeakerData) FlowSpeakerData(org.openkilda.rulemanager.FlowSpeakerData) FieldMatch(org.openkilda.rulemanager.match.FieldMatch) GroupSpeakerData(org.openkilda.rulemanager.GroupSpeakerData) 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 23 with GroupSpeakerData

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

the class BroadCastDiscoveryRuleGeneratorTest method shouldBuildCorrectRuleWithMeterAndGroupForOf15.

@Test
public void shouldBuildCorrectRuleWithMeterAndGroupForOf15() {
    sw = buildSwitch("OF_15", Sets.newHashSet(METERS, GROUP_PACKET_OUT_CONTROLLER, MATCH_UDP_PORT, PKTPS_FLAG));
    List<SpeakerData> commands = generator.generateCommands(sw);
    assertEquals(3, 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);
    GroupSpeakerData groupCommandData = getCommand(GroupSpeakerData.class, commands);
    assertEquals(2, flowCommandData.getDependsOn().size());
    assertTrue(flowCommandData.getDependsOn().contains(meterCommandData.getUuid()));
    assertTrue(flowCommandData.getDependsOn().contains(groupCommandData.getUuid()));
    // Check flow command
    checkFlowCommandBaseProperties(flowCommandData);
    Set<FieldMatch> match = flowCommandData.getMatch();
    assertEquals(4, match.size());
    checkEthDstMatch(match);
    checkUpdDstMatch(match);
    // Check flow command has correct instructions for OF 1.5
    Instructions instructions = flowCommandData.getInstructions();
    assertEquals(2, instructions.getApplyActions().size());
    Action first = instructions.getApplyActions().get(0);
    assertTrue(first instanceof MeterAction);
    MeterAction meterAction = (MeterAction) first;
    assertEquals(meterCommandData.getMeterId(), meterAction.getMeterId());
    checkGroupAction(instructions.getApplyActions().get(1), groupCommandData.getGroupId());
    assertNull(instructions.getWriteActions());
    assertNull(instructions.getGoToMeter());
    assertNull(instructions.getGoToTable());
    // Check meter command
    checkMeterCommand(meterCommandData);
    // Check group command
    checkGroupCommand(groupCommandData);
}
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) FieldMatch(org.openkilda.rulemanager.match.FieldMatch) GroupSpeakerData(org.openkilda.rulemanager.GroupSpeakerData) MeterAction(org.openkilda.rulemanager.action.MeterAction) 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 24 with GroupSpeakerData

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

the class RuleManagerHelperTest method checkCircularDependenciesTest.

@Test
public void checkCircularDependenciesTest() {
    checkCircularDependencies(new ArrayList<>());
    GroupSpeakerData groupCommand = buildFullGroupSpeakerCommandData(GROUP_ID_1);
    groupCommand.getDependsOn().clear();
    checkCircularDependencies(newArrayList(groupCommand));
    FlowSpeakerData command1 = buildFullFlowSpeakerCommandData(METER_ID_1, null);
    FlowSpeakerData command2 = buildFullFlowSpeakerCommandData(METER_ID_1, command1.getUuid());
    FlowSpeakerData command3 = buildFullFlowSpeakerCommandData(METER_ID_2, command2.getUuid());
    checkCircularDependencies(newArrayList(command1, command2, command3));
// if there are no exceptions - test passed
}
Also used : FlowSpeakerData(org.openkilda.rulemanager.FlowSpeakerData) GroupSpeakerData(org.openkilda.rulemanager.GroupSpeakerData) Test(org.junit.Test)

Example 25 with GroupSpeakerData

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

the class EgressMirrorRuleGeneratorTest method buildVlanMultiTableDoubleVlanEgressMirrorRuleTest.

@Test
public void buildVlanMultiTableDoubleVlanEgressMirrorRuleTest() {
    FlowPath path = buildPathWithMirror(true);
    Flow flow = buildFlow(path, OUTER_VLAN_ID, INNER_VLAN_ID);
    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(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, 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) 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)

Aggregations

GroupSpeakerData (org.openkilda.rulemanager.GroupSpeakerData)32 Test (org.junit.Test)28 FlowSpeakerData (org.openkilda.rulemanager.FlowSpeakerData)25 SpeakerData (org.openkilda.rulemanager.SpeakerData)24 PortOutAction (org.openkilda.rulemanager.action.PortOutAction)23 Action (org.openkilda.rulemanager.action.Action)20 GroupAction (org.openkilda.rulemanager.action.GroupAction)20 SetFieldAction (org.openkilda.rulemanager.action.SetFieldAction)20 Flow (org.openkilda.model.Flow)17 PopVlanAction (org.openkilda.rulemanager.action.PopVlanAction)17 PushVlanAction (org.openkilda.rulemanager.action.PushVlanAction)17 FlowPath (org.openkilda.model.FlowPath)14 PopVxlanAction (org.openkilda.rulemanager.action.PopVxlanAction)13 FieldMatch (org.openkilda.rulemanager.match.FieldMatch)9 PortNumber (org.openkilda.rulemanager.ProtoConstants.PortNumber)8 MeterSpeakerData (org.openkilda.rulemanager.MeterSpeakerData)6 ArrayList (java.util.ArrayList)5 PushVxlanAction (org.openkilda.rulemanager.action.PushVxlanAction)4 GroupId (org.openkilda.model.GroupId)3 Instructions (org.openkilda.rulemanager.Instructions)3