Search in sources :

Example 6 with FlowSpeakerData

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());
}
Also used : FlowSpeakerData(org.openkilda.rulemanager.FlowSpeakerData) Test(org.junit.Test)

Example 7 with FlowSpeakerData

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());
}
Also used : FlowSpeakerData(org.openkilda.rulemanager.FlowSpeakerData) Test(org.junit.Test)

Example 8 with FlowSpeakerData

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());
}
Also used : FlowSpeakerData(org.openkilda.rulemanager.FlowSpeakerData) Test(org.junit.Test)

Example 9 with FlowSpeakerData

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()));
}
Also used : Cookie(org.openkilda.model.cookie.Cookie) ValidateRulesResult(org.openkilda.wfm.topology.switchmanager.model.ValidateRulesResult) FlowSpeakerData(org.openkilda.rulemanager.FlowSpeakerData) ValidationService(org.openkilda.wfm.topology.switchmanager.service.ValidationService) Test(org.junit.Test)

Example 10 with FlowSpeakerData

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());
}
Also used : Cookie(org.openkilda.model.cookie.Cookie) Action(org.openkilda.rulemanager.action.Action) PortOutAction(org.openkilda.rulemanager.action.PortOutAction) FlowSpeakerData(org.openkilda.rulemanager.FlowSpeakerData) Utils.buildSwitch(org.openkilda.rulemanager.Utils.buildSwitch) Switch(org.openkilda.model.Switch) PortOutAction(org.openkilda.rulemanager.action.PortOutAction) FieldMatch(org.openkilda.rulemanager.match.FieldMatch) Instructions(org.openkilda.rulemanager.Instructions) SpeakerData(org.openkilda.rulemanager.SpeakerData) FlowSpeakerData(org.openkilda.rulemanager.FlowSpeakerData) Test(org.junit.Test)

Aggregations

FlowSpeakerData (org.openkilda.rulemanager.FlowSpeakerData)106 SpeakerData (org.openkilda.rulemanager.SpeakerData)88 Test (org.junit.Test)83 PortOutAction (org.openkilda.rulemanager.action.PortOutAction)58 FieldMatch (org.openkilda.rulemanager.match.FieldMatch)55 Action (org.openkilda.rulemanager.action.Action)54 SetFieldAction (org.openkilda.rulemanager.action.SetFieldAction)49 MeterSpeakerData (org.openkilda.rulemanager.MeterSpeakerData)42 PushVlanAction (org.openkilda.rulemanager.action.PushVlanAction)38 Flow (org.openkilda.model.Flow)35 Instructions (org.openkilda.rulemanager.Instructions)35 PortNumber (org.openkilda.rulemanager.ProtoConstants.PortNumber)35 PopVlanAction (org.openkilda.rulemanager.action.PopVlanAction)35 GroupSpeakerData (org.openkilda.rulemanager.GroupSpeakerData)33 GroupAction (org.openkilda.rulemanager.action.GroupAction)23 PushVxlanAction (org.openkilda.rulemanager.action.PushVxlanAction)22 PopVxlanAction (org.openkilda.rulemanager.action.PopVxlanAction)18 Cookie (org.openkilda.model.cookie.Cookie)15 FlowPath (org.openkilda.model.FlowPath)14 Switch (org.openkilda.model.Switch)14