use of org.openkilda.rulemanager.FlowSpeakerData in project open-kilda by telstra.
the class UniCastDiscoveryRuleGeneratorTest method shouldBuildCorrectRuleWithMeterForOf13.
@Test
public void shouldBuildCorrectRuleWithMeterForOf13() {
sw = buildSwitch("OF_13", Sets.newHashSet(METERS, 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(2, match.size());
checkMatch(match);
checkInstructions(flowCommandData.getInstructions(), meterCommandData.getMeterId());
// Check meter command
checkMeterCommand(meterCommandData);
}
use of org.openkilda.rulemanager.FlowSpeakerData in project open-kilda by telstra.
the class Server42FlowRttTurningRuleGeneratorTest method testOutputRule.
private void testOutputRule(Switch sw, ActionType expectedSwapFieldType) {
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(SERVER_42_FLOW_RTT_TURNING_COOKIE), flowCommandData.getCookie());
assertEquals(OfTable.INPUT, flowCommandData.getTable());
assertEquals(SERVER_42_FLOW_RTT_TURNING_PRIORITY, flowCommandData.getPriority());
Set<FieldMatch> expectedMatch = Sets.newHashSet(FieldMatch.builder().field(Field.ETH_DST).value(sw.getSwitchId().toMacAddressAsLong()).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(SERVER_42_FLOW_RTT_FORWARD_UDP_PORT).build());
assertEquals(expectedMatch, flowCommandData.getMatch());
List<Action> expectedApplyActions = Lists.newArrayList(SetFieldAction.builder().field(Field.UDP_SRC).value(SERVER_42_FLOW_RTT_REVERSE_UDP_PORT).build(), SwapFieldAction.builder().type(expectedSwapFieldType).numberOfBits(MAC_ADDRESS_SIZE_IN_BITS).srcOffset(0).dstOffset(0).oxmSrcHeader(OpenFlowOxms.ETH_SRC).oxmDstHeader(OpenFlowOxms.ETH_DST).build(), new PortOutAction(new PortNumber(SpecialPortType.IN_PORT)));
Instructions expectedInstructions = Instructions.builder().applyActions(expectedApplyActions).build();
assertEquals(expectedInstructions, flowCommandData.getInstructions());
}
use of org.openkilda.rulemanager.FlowSpeakerData in project open-kilda by telstra.
the class Server42IslRttInputRuleGeneratorTest method server42IslRttInputRuleGeneratorTest.
@Test
public void server42IslRttInputRuleGeneratorTest() {
Switch sw = buildSwitch("OF_13", Sets.newHashSet(NOVIFLOW_COPY_FIELD));
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 PortColourCookie(CookieType.SERVER_42_ISL_RTT_INPUT, ISL_PORT), flowCommandData.getCookie());
assertEquals(OfTable.INPUT, flowCommandData.getTable());
assertEquals(SERVER_42_ISL_RTT_INPUT_PRIORITY, flowCommandData.getPriority());
Set<FieldMatch> expectedMatch = Sets.newHashSet(FieldMatch.builder().field(Field.IN_PORT).value(Utils.SERVER_42_PORT).build(), FieldMatch.builder().field(Field.ETH_DST).value(sw.getSwitchId().toMacAddressAsLong()).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(OFFSET + ISL_PORT).build());
assertEquals(expectedMatch, flowCommandData.getMatch());
List<Action> expectedApplyActions = Lists.newArrayList(SetFieldAction.builder().field(Field.UDP_SRC).value(SERVER_42_ISL_RTT_FORWARD_UDP_PORT).build(), SetFieldAction.builder().field(Field.ETH_DST).value(MAC_ADDRESS.toLong()).build(), new PortOutAction(new PortNumber(ISL_PORT)));
Instructions expectedInstructions = Instructions.builder().applyActions(expectedApplyActions).build();
assertEquals(expectedInstructions, flowCommandData.getInstructions());
}
use of org.openkilda.rulemanager.FlowSpeakerData in project open-kilda by telstra.
the class RuleManagerHelperTest method checkCircularDependenciesCycle3Test.
@Test(expected = IllegalStateException.class)
public void checkCircularDependenciesCycle3Test() {
FlowSpeakerData command1 = buildFullFlowSpeakerCommandData(METER_ID_1, null);
FlowSpeakerData command2 = buildFullFlowSpeakerCommandData(METER_ID_1, command1.getUuid());
FlowSpeakerData command3 = buildFullFlowSpeakerCommandData(METER_ID_2, command2.getUuid());
command1.getDependsOn().add(command3.getUuid());
checkCircularDependencies(newArrayList(command1, command2, command3));
}
use of org.openkilda.rulemanager.FlowSpeakerData in project open-kilda by telstra.
the class RuleManagerHelperTest method removeDuplicateCommandsEqualVlanMatchTest.
@Test
public void removeDuplicateCommandsEqualVlanMatchTest() {
FlowSpeakerData command1 = buildVlanMatchCommand(1);
FlowSpeakerData command2 = buildVlanMatchCommand(1);
assertEquals(1, removeDuplicateCommands(newArrayList(command1, command2)).size());
}
Aggregations