Search in sources :

Example 11 with MeterSpeakerData

use of org.openkilda.rulemanager.MeterSpeakerData in project open-kilda by telstra.

the class ValidationServiceImplTest method validateMetersMissingAndExcessMeters.

@Test
public void validateMetersMissingAndExcessMeters() {
    ValidationService validationService = new ValidationServiceImpl(persistenceManager().build());
    MeterSpeakerData actualMeter = MeterSpeakerData.builder().meterId(new MeterId(33)).rate(10000).burst(10500).ofVersion(OfVersion.OF_13).flags(Sets.newHashSet(MeterFlag.KBPS, MeterFlag.BURST, MeterFlag.STATS)).build();
    MeterSpeakerData expectedMeter = MeterSpeakerData.builder().meterId(new MeterId(32)).rate(10000).burst(10500).ofVersion(OfVersion.OF_13).flags(Sets.newHashSet(MeterFlag.KBPS, MeterFlag.BURST, MeterFlag.STATS)).build();
    ValidateMetersResult response = validationService.validateMeters(SWITCH_ID_B, singletonList(actualMeter), singletonList(expectedMeter));
    assertFalse(response.getMissingMeters().isEmpty());
    assertMeter(response.getMissingMeters().get(0), 32, 10000, 10500, new String[] { "KBPS", "BURST", "STATS" });
    assertTrue(response.getMisconfiguredMeters().isEmpty());
    assertTrue(response.getProperMeters().isEmpty());
    assertFalse(response.getExcessMeters().isEmpty());
    assertMeter(response.getExcessMeters().get(0), 33, 10000, 10500, new String[] { "KBPS", "BURST", "STATS" });
}
Also used : MeterSpeakerData(org.openkilda.rulemanager.MeterSpeakerData) ValidateMetersResult(org.openkilda.wfm.topology.switchmanager.model.ValidateMetersResult) ValidationService(org.openkilda.wfm.topology.switchmanager.service.ValidationService) MeterId(org.openkilda.model.MeterId) Test(org.junit.Test)

Example 12 with MeterSpeakerData

use of org.openkilda.rulemanager.MeterSpeakerData in project open-kilda by telstra.

the class ValidationServiceImplTest method validateMetersProperMeters.

@Test
public void validateMetersProperMeters() {
    ValidationService validationService = new ValidationServiceImpl(persistenceManager().build());
    MeterSpeakerData meter = MeterSpeakerData.builder().meterId(new MeterId(32)).rate(10000).burst(10500).ofVersion(OfVersion.OF_13).flags(Sets.newHashSet(MeterFlag.KBPS, MeterFlag.BURST, MeterFlag.STATS)).build();
    ValidateMetersResult response = validationService.validateMeters(SWITCH_ID_B, singletonList(meter), singletonList(meter));
    assertTrue(response.getMissingMeters().isEmpty());
    assertTrue(response.getMisconfiguredMeters().isEmpty());
    assertFalse(response.getProperMeters().isEmpty());
    assertEquals(meter.getMeterId().getValue(), response.getProperMeters().get(0).getMeterId().longValue());
    assertMeter(response.getProperMeters().get(0), 32, 10000, 10500, new String[] { "KBPS", "BURST", "STATS" });
    assertTrue(response.getExcessMeters().isEmpty());
}
Also used : MeterSpeakerData(org.openkilda.rulemanager.MeterSpeakerData) ValidateMetersResult(org.openkilda.wfm.topology.switchmanager.model.ValidateMetersResult) ValidationService(org.openkilda.wfm.topology.switchmanager.service.ValidationService) MeterId(org.openkilda.model.MeterId) Test(org.junit.Test)

Example 13 with MeterSpeakerData

use of org.openkilda.rulemanager.MeterSpeakerData in project open-kilda by telstra.

the class ConnectedDevicesRuleGeneratorTest method shouldBuildCorrectRuleWithMeterForOf13.

@Test
public void shouldBuildCorrectRuleWithMeterForOf13() {
    sw = buildSwitch("OF_13", expectedFeatures);
    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()));
    assertTrue(meterCommandData.getDependsOn().isEmpty());
    // Check flow command
    checkFlowCommandBaseProperties(flowCommandData);
    checkMatch(flowCommandData.getMatch());
    checkInstructions(flowCommandData.getInstructions(), meterCommandData.getMeterId());
    // Check meter command
    checkMeterCommand(meterCommandData);
}
Also used : MeterSpeakerData(org.openkilda.rulemanager.MeterSpeakerData) FlowSpeakerData(org.openkilda.rulemanager.FlowSpeakerData) MeterSpeakerData(org.openkilda.rulemanager.MeterSpeakerData) SpeakerData(org.openkilda.rulemanager.SpeakerData) FlowSpeakerData(org.openkilda.rulemanager.FlowSpeakerData) Test(org.junit.Test)

Example 14 with MeterSpeakerData

use of org.openkilda.rulemanager.MeterSpeakerData in project open-kilda by telstra.

the class TransitYRuleGeneratorTest method assertTransitCommands.

private void assertTransitCommands(List<SpeakerData> commands, OfTable table, FlowTransitEncapsulation encapsulation) {
    assertEquals(2, commands.size());
    MeterSpeakerData meterCommandData = getCommand(MeterSpeakerData.class, commands);
    FlowSpeakerData flowCommandData = getCommand(FlowSpeakerData.class, commands);
    assertEquals(SWITCH_1.getSwitchId(), flowCommandData.getSwitchId());
    assertEquals(SWITCH_1.getOfVersion(), flowCommandData.getOfVersion().toString());
    assertTrue(flowCommandData.getDependsOn().contains(meterCommandData.getUuid()));
    assertEquals(COOKIE, flowCommandData.getCookie());
    assertEquals(table, flowCommandData.getTable());
    assertEquals(Priority.Y_FLOW_PRIORITY, flowCommandData.getPriority());
    Set<FieldMatch> expectedMatch;
    if (encapsulation.getType().equals(FlowEncapsulationType.TRANSIT_VLAN)) {
        expectedMatch = buildExpectedVlanMatch(PORT_NUMBER_1, encapsulation.getId());
    } else {
        expectedMatch = buildExpectedVxlanMatch(PORT_NUMBER_1, encapsulation.getId());
    }
    assertEqualsMatch(expectedMatch, flowCommandData.getMatch());
    Instructions expectedInstructions = Instructions.builder().applyActions(Lists.newArrayList(new PortOutAction(new PortNumber(PORT_NUMBER_2)))).goToMeter(SHARED_METER_ID).build();
    assertEquals(expectedInstructions, flowCommandData.getInstructions());
    assertEquals(Sets.newHashSet(OfFlowFlag.RESET_COUNTERS), flowCommandData.getFlags());
}
Also used : MeterSpeakerData(org.openkilda.rulemanager.MeterSpeakerData) FlowSpeakerData(org.openkilda.rulemanager.FlowSpeakerData) PortOutAction(org.openkilda.rulemanager.action.PortOutAction) FieldMatch(org.openkilda.rulemanager.match.FieldMatch) Instructions(org.openkilda.rulemanager.Instructions) PortNumber(org.openkilda.rulemanager.ProtoConstants.PortNumber)

Example 15 with MeterSpeakerData

use of org.openkilda.rulemanager.MeterSpeakerData in project open-kilda by telstra.

the class MultiTableIngressRuleGeneratorTest method buildCommandsVlanEncapsulationDoubleVlanPortOverlappingTest.

@Test
public void buildCommandsVlanEncapsulationDoubleVlanPortOverlappingTest() {
    Flow oneSwitchFlow = buildFlow(ONE_SWITCH_PATH, OUTER_VLAN_ID_2, 0);
    Set<FlowSideAdapter> overlapping = Sets.newHashSet(FlowSideAdapter.makeIngressAdapter(oneSwitchFlow, ONE_SWITCH_PATH));
    Flow flow = buildFlow(PATH, OUTER_VLAN_ID_1, INNER_VLAN_ID_1);
    MultiTableIngressRuleGenerator generator = buildGenerator(PATH, flow, VLAN_ENCAPSULATION, overlapping);
    List<SpeakerData> commands = generator.generateCommands(SWITCH_1);
    assertEquals(3, commands.size());
    FlowSpeakerData ingressCommand = (FlowSpeakerData) commands.get(0);
    FlowSpeakerData preIngressCommand = (FlowSpeakerData) commands.get(1);
    MeterSpeakerData meterCommand = (MeterSpeakerData) commands.get(2);
    assertEquals(newArrayList(meterCommand.getUuid()), new ArrayList<>(ingressCommand.getDependsOn()));
    RoutingMetadata ingressMetadata = RoutingMetadata.builder().outerVlanId(OUTER_VLAN_ID_1).build(SWITCH_1.getFeatures());
    Set<FieldMatch> expectedIngressMatch = Sets.newHashSet(FieldMatch.builder().field(Field.IN_PORT).value(PORT_NUMBER_1).build(), FieldMatch.builder().field(Field.VLAN_VID).value(INNER_VLAN_ID_1).build(), FieldMatch.builder().field(Field.METADATA).value(ingressMetadata.getValue()).mask(ingressMetadata.getMask()).build());
    List<Action> expectedIngressActions = newArrayList(SetFieldAction.builder().field(Field.VLAN_VID).value(TRANSIT_VLAN_ID).build(), new PortOutAction(new PortNumber(PORT_NUMBER_2)));
    Set<FieldMatch> expectedPreIngressMatch = Sets.newHashSet(FieldMatch.builder().field(Field.IN_PORT).value(PORT_NUMBER_1).build(), FieldMatch.builder().field(Field.VLAN_VID).value(OUTER_VLAN_ID_1).build());
    FlowSharedSegmentCookie preIngressCookie = FlowSharedSegmentCookie.builder(SharedSegmentType.QINQ_OUTER_VLAN).portNumber(PORT_NUMBER_1).vlanId(OUTER_VLAN_ID_1).build();
    RoutingMetadata preIngressMetadata = RoutingMetadata.builder().outerVlanId(OUTER_VLAN_ID_1).build(SWITCH_1.getFeatures());
    assertPreIngressCommand(preIngressCommand, preIngressCookie, Priority.FLOW_PRIORITY, expectedPreIngressMatch, newArrayList(new PopVlanAction()), mapMetadata(preIngressMetadata));
    assertIngressCommand(ingressCommand, Priority.DOUBLE_VLAN_FLOW_PRIORITY, expectedIngressMatch, expectedIngressActions, METER_ID, null);
    assertMeterCommand(meterCommand);
}
Also used : SetFieldAction(org.openkilda.rulemanager.action.SetFieldAction) Action(org.openkilda.rulemanager.action.Action) PushVxlanAction(org.openkilda.rulemanager.action.PushVxlanAction) PushVlanAction(org.openkilda.rulemanager.action.PushVlanAction) PopVlanAction(org.openkilda.rulemanager.action.PopVlanAction) PortOutAction(org.openkilda.rulemanager.action.PortOutAction) PortOutAction(org.openkilda.rulemanager.action.PortOutAction) FieldMatch(org.openkilda.rulemanager.match.FieldMatch) FlowSharedSegmentCookie(org.openkilda.model.cookie.FlowSharedSegmentCookie) RoutingMetadata(org.openkilda.rulemanager.utils.RoutingMetadata) Flow(org.openkilda.model.Flow) PopVlanAction(org.openkilda.rulemanager.action.PopVlanAction) MeterSpeakerData(org.openkilda.rulemanager.MeterSpeakerData) FlowSpeakerData(org.openkilda.rulemanager.FlowSpeakerData) FlowSideAdapter(org.openkilda.adapter.FlowSideAdapter) PortNumber(org.openkilda.rulemanager.ProtoConstants.PortNumber) SpeakerData(org.openkilda.rulemanager.SpeakerData) MeterSpeakerData(org.openkilda.rulemanager.MeterSpeakerData) FlowSpeakerData(org.openkilda.rulemanager.FlowSpeakerData) Test(org.junit.Test)

Aggregations

MeterSpeakerData (org.openkilda.rulemanager.MeterSpeakerData)38 Test (org.junit.Test)30 FlowSpeakerData (org.openkilda.rulemanager.FlowSpeakerData)30 SpeakerData (org.openkilda.rulemanager.SpeakerData)27 FieldMatch (org.openkilda.rulemanager.match.FieldMatch)17 PortOutAction (org.openkilda.rulemanager.action.PortOutAction)14 Action (org.openkilda.rulemanager.action.Action)13 SetFieldAction (org.openkilda.rulemanager.action.SetFieldAction)11 PortNumber (org.openkilda.rulemanager.ProtoConstants.PortNumber)9 Flow (org.openkilda.model.Flow)8 GroupSpeakerData (org.openkilda.rulemanager.GroupSpeakerData)8 PopVlanAction (org.openkilda.rulemanager.action.PopVlanAction)8 PushVlanAction (org.openkilda.rulemanager.action.PushVlanAction)8 PushVxlanAction (org.openkilda.rulemanager.action.PushVxlanAction)8 MeterId (org.openkilda.model.MeterId)7 Instructions (org.openkilda.rulemanager.Instructions)6 RoutingMetadata (org.openkilda.rulemanager.utils.RoutingMetadata)6 ValidateMetersResult (org.openkilda.wfm.topology.switchmanager.model.ValidateMetersResult)6 ValidationService (org.openkilda.wfm.topology.switchmanager.service.ValidationService)6 MeterAction (org.openkilda.rulemanager.action.MeterAction)5