use of org.openkilda.rulemanager.SpeakerData in project open-kilda by telstra.
the class TransitIslVxlanRuleGeneratorTest method shouldSkipRuleWhenNoVxlanFeatures.
@Test
public void shouldSkipRuleWhenNoVxlanFeatures() {
Switch sw = buildSwitch("OF_13", Collections.emptySet());
List<SpeakerData> commands = generator.generateCommands(sw);
assertTrue(commands.isEmpty());
}
use of org.openkilda.rulemanager.SpeakerData in project open-kilda by telstra.
the class IngressMirrorRuleGeneratorTest method buildSingleTableCommandsVlanEncapsulationSingleVlanTest.
@Test
public void buildSingleTableCommandsVlanEncapsulationSingleVlanTest() {
Flow flow = buildFlow(SINGLE_TABLE_PATH, OUTER_VLAN_ID_1, 0);
IngressMirrorRuleGenerator generator = buildGenerator(SINGLE_TABLE_PATH, flow, VLAN_ENCAPSULATION);
List<SpeakerData> commands = generator.generateCommands(SWITCH_1);
assertEquals(2, commands.size());
FlowSpeakerData ingressCommand = getCommand(FlowSpeakerData.class, commands);
GroupSpeakerData groupCommand = getCommand(GroupSpeakerData.class, commands);
Set<FieldMatch> expectedIngressMatch = Sets.newHashSet(FieldMatch.builder().field(Field.IN_PORT).value(PORT_NUMBER_1).build(), FieldMatch.builder().field(Field.VLAN_VID).value(OUTER_VLAN_ID_1).build());
List<Action> expectedIngressActions = newArrayList(new PopVlanAction(), new GroupAction(GROUP_ID));
assertIngressCommand(ingressCommand, Priority.MIRROR_FLOW_PRIORITY, INPUT, expectedIngressMatch, expectedIngressActions, METER_ID, groupCommand.getUuid());
Set<Action> expectedFlowBucketActions = newHashSet(new PushVlanAction(), SetFieldAction.builder().field(Field.VLAN_VID).value(TRANSIT_VLAN_ID).build(), new PortOutAction(new PortNumber(PORT_NUMBER_2)));
assertGroupCommand(groupCommand, expectedFlowBucketActions);
}
use of org.openkilda.rulemanager.SpeakerData 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);
}
use of org.openkilda.rulemanager.SpeakerData 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);
}
use of org.openkilda.rulemanager.SpeakerData 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);
}
Aggregations