use of org.openkilda.rulemanager.FlowSpeakerData 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
}
use of org.openkilda.rulemanager.FlowSpeakerData in project open-kilda by telstra.
the class RuleManagerHelperTest method sortCommandsByDependencies2Test.
@Test
public void sortCommandsByDependencies2Test() {
FlowSpeakerData command1 = buildFullFlowSpeakerCommandData(METER_ID_1, null);
FlowSpeakerData command2 = buildFullFlowSpeakerCommandData(METER_ID_1, command1.getUuid());
FlowSpeakerData command3 = buildFullFlowSpeakerCommandData(METER_ID_1, null);
List<SpeakerData> result = sortCommandsByDependencies(newArrayList(command3, command2, command1));
assertEquals(3, result.size());
int command1Pos = -1;
int command2Pos = -1;
for (int i = 0; i < result.size(); i++) {
if (result.get(i).getUuid().equals(command1.getUuid())) {
command1Pos = i;
}
if (result.get(i).getUuid().equals(command2.getUuid())) {
command2Pos = i;
}
}
assertTrue(command1Pos < command2Pos);
}
use of org.openkilda.rulemanager.FlowSpeakerData in project open-kilda by telstra.
the class RuleManagerHelperTest method checkCircularDependenciesLoopTest.
@Test(expected = IllegalStateException.class)
public void checkCircularDependenciesLoopTest() {
FlowSpeakerData command = buildFullFlowSpeakerCommandData(METER_ID_1, null);
command.getDependsOn().add(command.getUuid());
checkCircularDependencies(newArrayList(command));
}
use of org.openkilda.rulemanager.FlowSpeakerData in project open-kilda by telstra.
the class UnicastVerificationVxlanRuleGeneratorTest method shouldBuildCorrectRuleWithMeterForOf13WithOvsVxlan.
@Test
public void shouldBuildCorrectRuleWithMeterForOf13WithOvsVxlan() {
sw = buildSwitch("OF_13", Sets.newHashSet(KILDA_OVS_PUSH_POP_MATCH_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());
Instructions instructions = flowCommandData.getInstructions();
assertEquals(3, instructions.getApplyActions().size());
Action first = instructions.getApplyActions().get(0);
assertTrue(first instanceof PopVxlanAction);
PopVxlanAction popVxlanAction = (PopVxlanAction) first;
assertEquals(ActionType.POP_VXLAN_OVS, popVxlanAction.getType());
Action second = instructions.getApplyActions().get(1);
assertTrue(second instanceof PortOutAction);
PortOutAction sendToControllerAction = (PortOutAction) second;
assertEquals(SpecialPortType.CONTROLLER, sendToControllerAction.getPortNumber().getPortType());
assertNull(instructions.getWriteActions());
assertEquals(instructions.getGoToMeter(), meterCommandData.getMeterId());
assertNull(instructions.getGoToTable());
// Check meter command
checkMeterCommand(meterCommandData);
}
use of org.openkilda.rulemanager.FlowSpeakerData in project open-kilda by telstra.
the class UnicastVerificationVxlanRuleGeneratorTest method shouldBuildCorrectRuleWithMeterForOf13.
@Test
public void shouldBuildCorrectRuleWithMeterForOf13() {
sw = buildSwitch("OF_13", 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());
checkInstructions(flowCommandData.getInstructions(), meterCommandData.getMeterId());
// Check meter command
checkMeterCommand(meterCommandData);
}
Aggregations