use of org.openkilda.rulemanager.SpeakerData in project open-kilda by telstra.
the class ConnectedDevicesRuleGeneratorTest method shouldBuildCorrectRuleWithMeterForOf13.
@Test
public void shouldBuildCorrectRuleWithMeterForOf13() {
sw = buildSwitch("OF_13", 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());
checkInstructions(flowCommandData.getInstructions(), meterCommandData.getMeterId());
// Check meter command
checkMeterCommand(meterCommandData);
}
use of org.openkilda.rulemanager.SpeakerData in project open-kilda by telstra.
the class ConnectedDevicesRuleGeneratorTest method shouldBuildCorrectRuleWithoutMeterForOf13.
@Test
public void shouldBuildCorrectRuleWithoutMeterForOf13() {
expectedFeatures.remove(METERS);
sw = buildSwitch("OF_13", expectedFeatures);
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());
checkInstructions(flowCommandData.getInstructions(), null);
}
use of org.openkilda.rulemanager.SpeakerData in project open-kilda by telstra.
the class RoundTripLatencyRuleGeneratorTest method shouldBuildCorrectRuleForOf13.
@Test
public void shouldBuildCorrectRuleForOf13() {
Switch sw = buildSwitch("OF_13", Sets.newHashSet(NOVIFLOW_COPY_FIELD));
RoundTripLatencyRuleGenerator generator = RoundTripLatencyRuleGenerator.builder().config(config).build();
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 Cookie(ROUND_TRIP_LATENCY_RULE_COOKIE), flowCommandData.getCookie());
assertEquals(OfTable.INPUT, flowCommandData.getTable());
assertEquals(ROUND_TRIP_LATENCY_RULE_PRIORITY, flowCommandData.getPriority());
FieldMatch ethSrcMatch = getMatchByField(Field.ETH_SRC, flowCommandData.getMatch());
assertEquals(sw.getSwitchId().toLong(), ethSrcMatch.getValue());
assertFalse(ethSrcMatch.isMasked());
FieldMatch ethDstMatch = getMatchByField(Field.ETH_DST, flowCommandData.getMatch());
assertEquals(new SwitchId(config.getDiscoveryBcastPacketDst()).toLong(), ethDstMatch.getValue());
assertFalse(ethDstMatch.isMasked());
FieldMatch ethTypeMatch = getMatchByField(Field.ETH_TYPE, flowCommandData.getMatch());
assertEquals(EthType.IPv4, ethTypeMatch.getValue());
assertFalse(ethTypeMatch.isMasked());
FieldMatch ipProtoMatch = getMatchByField(Field.IP_PROTO, flowCommandData.getMatch());
assertEquals(IpProto.UDP, ipProtoMatch.getValue());
assertFalse(ipProtoMatch.isMasked());
FieldMatch udpDstMatch = getMatchByField(Field.UDP_DST, flowCommandData.getMatch());
assertEquals(Constants.LATENCY_PACKET_UDP_PORT, udpDstMatch.getValue());
assertFalse(udpDstMatch.isMasked());
Instructions instructions = flowCommandData.getInstructions();
assertEquals(2, instructions.getApplyActions().size());
Action first = instructions.getApplyActions().get(0);
assertTrue(first instanceof CopyFieldAction);
CopyFieldAction copyFieldAction = (CopyFieldAction) first;
assertEquals(ROUND_TRIP_LATENCY_TIMESTAMP_SIZE, copyFieldAction.getNumberOfBits());
assertEquals(0, copyFieldAction.getSrcOffset());
assertEquals(ROUND_TRIP_LATENCY_T1_OFFSET, copyFieldAction.getDstOffset());
assertEquals(NOVIFLOW_RX_TIMESTAMP, copyFieldAction.getOxmSrcHeader());
assertEquals(NOVIFLOW_PACKET_OFFSET, copyFieldAction.getOxmDstHeader());
Action second = instructions.getApplyActions().get(1);
assertTrue(second instanceof PortOutAction);
PortOutAction portOutAction = (PortOutAction) second;
assertEquals(SpecialPortType.CONTROLLER, portOutAction.getPortNumber().getPortType());
}
use of org.openkilda.rulemanager.SpeakerData in project open-kilda by telstra.
the class RoundTripLatencyRuleGeneratorTest method shouldSkipRuleWhenNoCopyFieldFeatureForOf13.
@Test
public void shouldSkipRuleWhenNoCopyFieldFeatureForOf13() {
Switch sw = buildSwitch("OF_13", Collections.emptySet());
BfdCatchRuleGenerator generator = new BfdCatchRuleGenerator();
List<SpeakerData> commands = generator.generateCommands(sw);
assertTrue(commands.isEmpty());
}
use of org.openkilda.rulemanager.SpeakerData in project open-kilda by telstra.
the class SingleTableServer42IngressRuleGeneratorTest method buildCommandsVxlanEncapsulationSingleVlanTest.
@Test
public void buildCommandsVxlanEncapsulationSingleVlanTest() {
Flow flow = buildFlow(PATH, OUTER_VLAN_ID_1);
SingleTableServer42IngressRuleGenerator generator = buildGenerator(PATH, flow, VXLAN_ENCAPSULATION);
List<SpeakerData> commands = generator.generateCommands(SWITCH_1);
assertEquals(1, commands.size());
FlowSpeakerData ingressCommand = (FlowSpeakerData) commands.get(0);
Set<FieldMatch> expectedIngressMatch = Sets.newHashSet(FieldMatch.builder().field(Field.IN_PORT).value(SERVER_42_PORT_NUMBER).build(), FieldMatch.builder().field(Field.ETH_SRC).value(SERVER_42_MAC_ADDRESS.toLong()).build(), FieldMatch.builder().field(Field.ETH_TYPE).value(EthType.IPv4).build(), FieldMatch.builder().field(Field.IP_PROTO).value(IpProto.UDP).build(), FieldMatch.builder().field(Field.UDP_SRC).value(PORT_OFFSET + PORT_NUMBER_1).build(), FieldMatch.builder().field(Field.VLAN_VID).value(OUTER_VLAN_ID_1).build());
List<Action> expectedIngressActions = newArrayList(new PopVlanAction(), COPY_FIELD_ACTION, buildPushVxlan(), new PortOutAction(new PortNumber(PORT_NUMBER_2)));
assertIngressCommand(ingressCommand, Priority.SERVER_42_INGRESS_SINGLE_VLAN_FLOW_PRIORITY, expectedIngressMatch, expectedIngressActions);
}
Aggregations