use of org.openkilda.rulemanager.SpeakerData in project open-kilda by telstra.
the class RuleManagerHelperTest method sortCommandsByDependencies3Test.
@Test
public void sortCommandsByDependencies3Test() {
FlowSpeakerData command1 = buildFullFlowSpeakerCommandData(METER_ID_1, null);
FlowSpeakerData command2 = buildFullFlowSpeakerCommandData(METER_ID_1, command1.getUuid());
FlowSpeakerData command3 = buildFullFlowSpeakerCommandData(METER_ID_2, command2.getUuid());
List<SpeakerData> result = sortCommandsByDependencies(newArrayList(command3, command2, command1));
assertEquals(3, result.size());
assertEquals(command1.getUuid(), result.get(0).getUuid());
assertEquals(command2.getUuid(), result.get(1).getUuid());
assertEquals(command3.getUuid(), result.get(2).getUuid());
}
use of org.openkilda.rulemanager.SpeakerData in project open-kilda by telstra.
the class Server42IslRttTurningRuleGeneratorTest method server42IslRttTurningRuleGeneratorTest.
@Test
public void server42IslRttTurningRuleGeneratorTest() {
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 Cookie(SERVER_42_ISL_RTT_TURNING_COOKIE), flowCommandData.getCookie());
assertEquals(OfTable.INPUT, flowCommandData.getTable());
assertEquals(SERVER_42_ISL_RTT_TURNING_PRIORITY, flowCommandData.getPriority());
Set<FieldMatch> expectedMatch = Sets.newHashSet(FieldMatch.builder().field(Field.ETH_DST).value(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(SERVER_42_ISL_RTT_FORWARD_UDP_PORT).build());
assertEquals(expectedMatch, flowCommandData.getMatch());
List<Action> expectedApplyActions = Lists.newArrayList(SetFieldAction.builder().field(Field.UDP_SRC).value(SERVER_42_ISL_RTT_REVERSE_UDP_PORT).build(), new PortOutAction(new PortNumber(SpecialPortType.IN_PORT)));
Instructions expectedInstructions = Instructions.builder().applyActions(expectedApplyActions).build();
assertEquals(expectedInstructions, flowCommandData.getInstructions());
}
use of org.openkilda.rulemanager.SpeakerData in project open-kilda by telstra.
the class UnicastVerificationVxlanRuleGeneratorTest method shouldBuildCorrectRuleWithMeterForOf15.
@Test
public void shouldBuildCorrectRuleWithMeterForOf15() {
sw = buildSwitch("OF_15", Sets.newHashSet(NOVIFLOW_PUSH_POP_VXLAN, 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);
checkMatch(flowCommandData.getMatch());
// Check flow command has correct instructions for OF 1.5
Instructions instructions = flowCommandData.getInstructions();
assertEquals(4, instructions.getApplyActions().size());
Action first = instructions.getApplyActions().get(0);
assertTrue(first instanceof PopVxlanAction);
PopVxlanAction popVxlanAction = (PopVxlanAction) first;
assertEquals(ActionType.POP_VXLAN_NOVIFLOW, popVxlanAction.getType());
Action second = instructions.getApplyActions().get(1);
assertTrue(second instanceof PortOutAction);
PortOutAction sendToControllerAction = (PortOutAction) second;
assertEquals(SpecialPortType.CONTROLLER, sendToControllerAction.getPortNumber().getPortType());
Action third = instructions.getApplyActions().get(3);
assertTrue(third instanceof MeterAction);
MeterAction meterAction = (MeterAction) third;
assertEquals(meterCommandData.getMeterId(), meterAction.getMeterId());
assertNull(instructions.getWriteActions());
assertNull(instructions.getGoToMeter());
assertNull(instructions.getGoToTable());
// Check meter command
checkMeterCommand(meterCommandData);
}
use of org.openkilda.rulemanager.SpeakerData in project open-kilda by telstra.
the class EgressIslVlanRuleGeneratorTest method shouldBuildCorrectRule.
@Test
public void shouldBuildCorrectRule() {
Switch sw = buildSwitch("OF_13", Collections.emptySet());
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.MULTI_TABLE_ISL_VLAN_EGRESS_RULES, ISL_PORT), flowCommandData.getCookie());
assertEquals(OfTable.INPUT, flowCommandData.getTable());
assertEquals(ISL_EGRESS_VLAN_RULE_PRIORITY_MULTITABLE, flowCommandData.getPriority());
assertEquals(1, flowCommandData.getMatch().size());
FieldMatch inPortMatch = getMatchByField(Field.IN_PORT, flowCommandData.getMatch());
assertEquals(ISL_PORT, inPortMatch.getValue());
assertFalse(inPortMatch.isMasked());
Instructions instructions = flowCommandData.getInstructions();
assertEquals(OfTable.EGRESS, instructions.getGoToTable());
}
use of org.openkilda.rulemanager.SpeakerData in project open-kilda by telstra.
the class TransitIslVxlanRuleGeneratorTest method shouldBuildCorrectRuleWithNoviflowVxlanFeature.
@Test
public void shouldBuildCorrectRuleWithNoviflowVxlanFeature() {
Switch sw = buildSwitch("OF_13", Sets.newHashSet(SwitchFeature.NOVIFLOW_PUSH_POP_VXLAN));
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.MULTI_TABLE_ISL_VXLAN_TRANSIT_RULES, ISL_PORT), flowCommandData.getCookie());
assertEquals(OfTable.INPUT, flowCommandData.getTable());
assertEquals(ISL_TRANSIT_VXLAN_RULE_PRIORITY_MULTITABLE, flowCommandData.getPriority());
Set<FieldMatch> match = flowCommandData.getMatch();
assertEquals(5, match.size());
checkMatch(match);
Instructions instructions = flowCommandData.getInstructions();
assertEquals(OfTable.TRANSIT, instructions.getGoToTable());
}
Aggregations