use of org.openkilda.rulemanager.FlowSpeakerData in project open-kilda by telstra.
the class RuleManagerHelperTest method removeDuplicateCommandsFullEqualFlowCommandTest.
@Test
public void removeDuplicateCommandsFullEqualFlowCommandTest() {
FlowSpeakerData command1 = buildFullFlowSpeakerCommandData();
FlowSpeakerData command2 = buildFullFlowSpeakerCommandData();
assertEquals(1, removeDuplicateCommands(newArrayList(command1, command2)).size());
}
use of org.openkilda.rulemanager.FlowSpeakerData in project open-kilda by telstra.
the class RuleManagerHelperTest method removeDuplicateCommandsDifferentVlanMatchTest.
@Test
public void removeDuplicateCommandsDifferentVlanMatchTest() {
FlowSpeakerData command1 = buildVlanMatchCommand(1);
FlowSpeakerData command2 = buildVlanMatchCommand(2);
assertEquals(2, removeDuplicateCommands(newArrayList(command1, command2)).size());
}
use of org.openkilda.rulemanager.FlowSpeakerData in project open-kilda by telstra.
the class RuleManagerHelperTest method removeDuplicateCommandsDifferentFlowCommandTest.
@Test
public void removeDuplicateCommandsDifferentFlowCommandTest() {
FlowSpeakerData command1 = buildFullFlowSpeakerCommandData(METER_ID_1);
FlowSpeakerData command2 = buildFullFlowSpeakerCommandData(METER_ID_2);
assertEquals(2, removeDuplicateCommands(newArrayList(command1, command2)).size());
}
use of org.openkilda.rulemanager.FlowSpeakerData in project open-kilda by telstra.
the class ValidationServiceImplTest method validateRules.
@Test
public void validateRules() {
ValidationService validationService = new ValidationServiceImpl(persistenceManager().build());
List<FlowSpeakerData> actualFlows = Lists.newArrayList(FlowSpeakerData.builder().cookie(new Cookie(0x8000000000000001L)).priority(1).build(), FlowSpeakerData.builder().cookie(new Cookie(0x8000000000000001L)).priority(2).build(), FlowSpeakerData.builder().cookie(new Cookie(0x8000000000000002L)).priority(1).build(), FlowSpeakerData.builder().cookie(new Cookie(0x8000000000000002L)).priority(2).build(), FlowSpeakerData.builder().cookie(new Cookie(0x8000000000000004L)).priority(1).build());
List<FlowSpeakerData> expectedFlows = Lists.newArrayList(FlowSpeakerData.builder().cookie(new Cookie(0x8000000000000001L)).priority(1).build(), FlowSpeakerData.builder().cookie(new Cookie(0x8000000000000002L)).priority(3).build(), FlowSpeakerData.builder().cookie(new Cookie(0x8000000000000003L)).priority(1).build());
ValidateRulesResult response = validationService.validateRules(SWITCH_ID_A, actualFlows, expectedFlows);
assertEquals(ImmutableSet.of(0x8000000000000001L), new HashSet<>(response.getProperRules()));
assertEquals(ImmutableSet.of(0x8000000000000001L, 0x8000000000000002L), new HashSet<>(response.getMisconfiguredRules()));
assertEquals(ImmutableSet.of(0x8000000000000003L), new HashSet<>(response.getMissingRules()));
assertEquals(ImmutableSet.of(0x8000000000000004L), new HashSet<>(response.getExcessRules()));
}
use of org.openkilda.rulemanager.FlowSpeakerData in project open-kilda by telstra.
the class BfdCatchRuleGeneratorTest method shouldBuildCorrectRuleForOf13.
@Test
public void shouldBuildCorrectRuleForOf13() {
Switch sw = buildSwitch("OF_13", Sets.newHashSet(BFD));
BfdCatchRuleGenerator generator = new BfdCatchRuleGenerator();
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(CATCH_BFD_RULE_COOKIE), flowCommandData.getCookie());
assertEquals(OfTable.INPUT, flowCommandData.getTable());
assertEquals(CATCH_BFD_RULE_PRIORITY, flowCommandData.getPriority());
FieldMatch ethDstMatch = getMatchByField(Field.ETH_DST, flowCommandData.getMatch());
assertEquals(sw.getSwitchId().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.BDF_DEFAULT_PORT, udpDstMatch.getValue());
assertFalse(udpDstMatch.isMasked());
Instructions instructions = flowCommandData.getInstructions();
assertEquals(1, instructions.getApplyActions().size());
Action action = instructions.getApplyActions().get(0);
assertTrue(action instanceof PortOutAction);
PortOutAction portOutAction = (PortOutAction) action;
assertEquals(SpecialPortType.LOCAL, portOutAction.getPortNumber().getPortType());
}
Aggregations