Search in sources :

Example 6 with MeterStatsData

use of org.openkilda.messaging.info.stats.MeterStatsData in project open-kilda by telstra.

the class StatsTopologyTest method lldpMeterStatsTest.

@Test
public void lldpMeterStatsTest() {
    long lldpMeterId = MeterId.MIN_FLOW_METER_ID;
    MeterStatsEntry meterStats = new MeterStatsEntry(lldpMeterId, 400L, 500L);
    sendStatsMessage(new MeterStatsData(SWITCH_ID_1, Collections.singletonList(meterStats)));
    List<Datapoint> datapoints = pollDatapoints(3);
    Map<String, Datapoint> datapointMap = createDatapointMap(datapoints);
    assertEquals(meterStats.getPacketsInCount(), datapointMap.get(METRIC_PREFIX + "flow.meter.packets").getValue().longValue());
    assertEquals(meterStats.getByteInCount(), datapointMap.get(METRIC_PREFIX + "flow.meter.bytes").getValue().longValue());
    assertEquals(meterStats.getByteInCount() * 8, datapointMap.get(METRIC_PREFIX + "flow.meter.bits").getValue().longValue());
    datapoints.forEach(datapoint -> {
        assertEquals(5, datapoint.getTags().size());
        assertEquals(SWITCH_ID_1.toOtsdFormat(), datapoint.getTags().get("switchid"));
        assertEquals(String.valueOf(lldpMeterId), datapoint.getTags().get("meterid"));
        assertEquals("unknown", datapoint.getTags().get("direction"));
        assertEquals("unknown", datapoint.getTags().get("cookie"));
        assertEquals("unknown", datapoint.getTags().get("flowid"));
        assertEquals(timestamp, datapoint.getTime().longValue());
    });
}
Also used : MeterStatsData(org.openkilda.messaging.info.stats.MeterStatsData) Datapoint(org.openkilda.messaging.info.Datapoint) MeterStatsEntry(org.openkilda.messaging.info.stats.MeterStatsEntry) AbstractStormTest(org.openkilda.wfm.AbstractStormTest) Test(org.junit.Test)

Example 7 with MeterStatsData

use of org.openkilda.messaging.info.stats.MeterStatsData in project open-kilda by telstra.

the class KildaEntryCacheServiceTest method shouldHandleRemovingMeterFromCache.

@Test
public void shouldHandleRemovingMeterFromCache() {
    Flow flow = buildFlow();
    MeterStatsData statsOrigin = getMeterStatsDataSrcSwitch();
    service.completeAndForwardMeterStats(statsOrigin);
    verify(carrier, atLeastOnce()).emitMeterStats(meterCacheCaptor.capture());
    List<MeterStatsAndDescriptor> statsEntries = meterCacheCaptor.getValue().getStatsEntries();
    assertDescriptionPopulation(statsEntries, statsOrigin.getStats().size(), 0);
    FlowPath forwardPath = flow.getForwardPath();
    UpdateFlowPathInfo pathInfo = new UpdateFlowPathInfo(flow.getFlowId(), flow.getYFlowId(), forwardPath.getCookie(), forwardPath.getMeterId(), FlowPathMapper.INSTANCE.mapToPathNodes(forwardPath));
    service.addOrUpdateCache(pathInfo);
    service.completeAndForwardMeterStats(statsOrigin);
    verify(carrier, atLeastOnce()).emitMeterStats(meterCacheCaptor.capture());
    statsEntries = meterCacheCaptor.getValue().getStatsEntries();
    assertDescriptionPopulation(statsEntries, statsOrigin.getStats().size(), 1);
    assertMeterCache(statsEntries, forwardPath.getMeterId().getValue(), new CommonFlowDescriptor(flow.getSrcSwitchId(), INGRESS, flow.getFlowId(), forwardPath.getCookie(), forwardPath.getMeterId()));
    RemoveFlowPathInfo pathInfo2 = new RemoveFlowPathInfo(flow.getFlowId(), flow.getYFlowId(), forwardPath.getCookie(), forwardPath.getMeterId(), FlowPathMapper.INSTANCE.mapToPathNodes(forwardPath));
    service.removeCached(pathInfo2);
    service.completeAndForwardMeterStats(statsOrigin);
    verify(carrier, atLeastOnce()).emitMeterStats(meterCacheCaptor.capture());
    statsEntries = meterCacheCaptor.getValue().getStatsEntries();
    assertDescriptionPopulation(statsEntries, statsOrigin.getStats().size(), 0);
}
Also used : MeterStatsData(org.openkilda.messaging.info.stats.MeterStatsData) MeterStatsAndDescriptor(org.openkilda.wfm.topology.stats.model.MeterStatsAndDescriptor) CommonFlowDescriptor(org.openkilda.wfm.topology.stats.model.CommonFlowDescriptor) UpdateFlowPathInfo(org.openkilda.messaging.info.stats.UpdateFlowPathInfo) FlowPath(org.openkilda.model.FlowPath) RemoveFlowPathInfo(org.openkilda.messaging.info.stats.RemoveFlowPathInfo) Flow(org.openkilda.model.Flow) YFlow(org.openkilda.model.YFlow) Test(org.junit.Test)

Example 8 with MeterStatsData

use of org.openkilda.messaging.info.stats.MeterStatsData in project open-kilda by telstra.

the class KildaEntryCacheServiceTest method shouldRefreshYFlowMeterCache.

@Test
public void shouldRefreshYFlowMeterCache() {
    FlowEndpoint sharedEndpoint = new FlowEndpoint(SRC_SWITCH_ID, 1);
    FlowEndpoint splitEndEndpoint = new FlowEndpoint(DST_SWITCH_ID, 2);
    Switch sharedSwitch = Switch.builder().switchId(sharedEndpoint.getSwitchId()).build();
    Switch splitEndSwitch = Switch.builder().switchId(splitEndEndpoint.getSwitchId()).build();
    Switch yPointSwitch = Switch.builder().switchId(TRANSIT_SWITCH_ID).build();
    Flow subFlowAlpha = new TestFlowBuilder().srcSwitch(sharedSwitch).destSwitch(splitEndSwitch).addTransitionEndpoint(sharedSwitch, sharedEndpoint.getPortNumber()).addTransitionEndpoint(yPointSwitch, 1).addTransitionEndpoint(yPointSwitch, 2).addTransitionEndpoint(splitEndSwitch, sharedEndpoint.getPortNumber()).build();
    Flow subFlowBeta = new TestFlowBuilder().srcSwitch(sharedSwitch).destSwitch(splitEndSwitch).addTransitionEndpoint(sharedSwitch, sharedEndpoint.getPortNumber()).addTransitionEndpoint(yPointSwitch, 1).addTransitionEndpoint(yPointSwitch, 2).addTransitionEndpoint(splitEndSwitch, sharedEndpoint.getPortNumber()).build();
    YFlow yFlow = new TestYFlowBuilder().sharedEndpoint(new YFlow.SharedEndpoint(sharedEndpoint.getSwitchId(), sharedEndpoint.getPortNumber())).sharedEndpointMeterId(new MeterId(100)).yPoint(yPointSwitch.getSwitchId()).meterId(new MeterId(110)).subFlow(new TestYSubFlowBuilder().flow(subFlowAlpha).sharedEndpointVlan(10).endpoint(new FlowEndpoint(DST_SWITCH_ID, 2, 30))).subFlow(new TestYSubFlowBuilder().flow(subFlowBeta).sharedEndpointVlan(20).endpoint(new FlowEndpoint(DST_SWITCH_ID, 2, 40))).build();
    when(flowRepository.findAll()).thenReturn(Collections.emptyList());
    when(yFlowRepository.findAll()).thenReturn(Collections.singletonList(yFlow));
    service.refreshCache();
    // shared endpoint
    service.completeAndForwardMeterStats(new MeterStatsData(yFlow.getSharedEndpoint().getSwitchId(), Collections.singletonList(new MeterStatsEntry(yFlow.getSharedEndpointMeterId().getValue(), 0, 0))));
    verify(carrier, atLeastOnce()).emitMeterStats(meterCacheCaptor.capture());
    List<MeterStatsAndDescriptor> statsEntries = meterCacheCaptor.getValue().getStatsEntries();
    assertDescriptionPopulation(statsEntries, 1, 1);
    assertMeterCache(statsEntries, yFlow.getSharedEndpointMeterId().getValue(), new YFlowDescriptor(yFlow.getSharedEndpoint().getSwitchId(), Y_FLOW_SHARED, yFlow.getYFlowId(), yFlow.getSharedEndpointMeterId()));
    // y-point
    service.completeAndForwardMeterStats(new MeterStatsData(yFlow.getYPoint(), Collections.singletonList(new MeterStatsEntry(yFlow.getMeterId().getValue(), 0, 0))));
    verify(carrier, atLeastOnce()).emitMeterStats(meterCacheCaptor.capture());
    statsEntries = meterCacheCaptor.getValue().getStatsEntries();
    assertDescriptionPopulation(statsEntries, 1, 1);
    assertMeterCache(statsEntries, yFlow.getMeterId().getValue(), new YFlowDescriptor(yFlow.getYPoint(), Y_FLOW_Y_POINT, yFlow.getYFlowId(), yFlow.getMeterId()));
}
Also used : YFlow(org.openkilda.model.YFlow) MeterStatsAndDescriptor(org.openkilda.wfm.topology.stats.model.MeterStatsAndDescriptor) TestFlowBuilder(org.openkilda.wfm.share.flow.TestFlowBuilder) Flow(org.openkilda.model.Flow) YFlow(org.openkilda.model.YFlow) TestYFlowBuilder(org.openkilda.wfm.share.yflow.TestYFlowBuilder) MeterId(org.openkilda.model.MeterId) MeterStatsData(org.openkilda.messaging.info.stats.MeterStatsData) FlowEndpoint(org.openkilda.model.FlowEndpoint) Switch(org.openkilda.model.Switch) YFlowDescriptor(org.openkilda.wfm.topology.stats.model.YFlowDescriptor) MeterStatsEntry(org.openkilda.messaging.info.stats.MeterStatsEntry) TestYSubFlowBuilder(org.openkilda.wfm.share.yflow.TestYSubFlowBuilder) Test(org.junit.Test)

Example 9 with MeterStatsData

use of org.openkilda.messaging.info.stats.MeterStatsData in project open-kilda by telstra.

the class KildaEntryCacheServiceTest method shouldCompleteMeterStats.

@Test
public void shouldCompleteMeterStats() {
    Flow flow = buildFlow();
    MeterStatsData statsOrigin = getMeterStatsDataSrcSwitch();
    service.completeAndForwardMeterStats(statsOrigin);
    verify(carrier, atLeastOnce()).emitMeterStats(meterCacheCaptor.capture());
    List<MeterStatsAndDescriptor> statsEntries = meterCacheCaptor.getValue().getStatsEntries();
    assertDescriptionPopulation(statsEntries, statsOrigin.getStats().size(), 0);
    FlowPath forwardPath = flow.getForwardPath();
    UpdateFlowPathInfo pathInfo = new UpdateFlowPathInfo(flow.getFlowId(), flow.getYFlowId(), forwardPath.getCookie(), forwardPath.getMeterId(), FlowPathMapper.INSTANCE.mapToPathNodes(forwardPath));
    service.addOrUpdateCache(pathInfo);
    service.completeAndForwardMeterStats(statsOrigin);
    verify(carrier, atLeastOnce()).emitMeterStats(meterCacheCaptor.capture());
    statsEntries = meterCacheCaptor.getValue().getStatsEntries();
    assertDescriptionPopulation(statsEntries, statsOrigin.getStats().size(), 1);
    assertMeterCache(statsEntries, forwardPath.getMeterId().getValue(), new CommonFlowDescriptor(flow.getSrcSwitchId(), INGRESS, flow.getFlowId(), forwardPath.getCookie(), forwardPath.getMeterId()));
    FlowPath protectedForwardPath = flow.getProtectedForwardPath();
    UpdateFlowPathInfo pathInfo2 = new UpdateFlowPathInfo(flow.getFlowId(), flow.getYFlowId(), protectedForwardPath.getCookie(), protectedForwardPath.getMeterId(), FlowPathMapper.INSTANCE.mapToPathNodes(protectedForwardPath));
    service.addOrUpdateCache(pathInfo2);
    service.completeAndForwardMeterStats(statsOrigin);
    verify(carrier, atLeastOnce()).emitMeterStats(meterCacheCaptor.capture());
    statsEntries = meterCacheCaptor.getValue().getStatsEntries();
    assertDescriptionPopulation(statsEntries, statsOrigin.getStats().size(), 2);
    assertMeterCache(statsEntries, forwardPath.getMeterId().getValue(), new CommonFlowDescriptor(flow.getSrcSwitchId(), INGRESS, flow.getFlowId(), forwardPath.getCookie(), forwardPath.getMeterId()));
    assertMeterCache(statsEntries, protectedForwardPath.getMeterId().getValue(), new CommonFlowDescriptor(flow.getSrcSwitchId(), INGRESS, flow.getFlowId(), protectedForwardPath.getCookie(), protectedForwardPath.getMeterId()));
}
Also used : MeterStatsData(org.openkilda.messaging.info.stats.MeterStatsData) MeterStatsAndDescriptor(org.openkilda.wfm.topology.stats.model.MeterStatsAndDescriptor) CommonFlowDescriptor(org.openkilda.wfm.topology.stats.model.CommonFlowDescriptor) UpdateFlowPathInfo(org.openkilda.messaging.info.stats.UpdateFlowPathInfo) FlowPath(org.openkilda.model.FlowPath) Flow(org.openkilda.model.Flow) YFlow(org.openkilda.model.YFlow) Test(org.junit.Test)

Aggregations

MeterStatsData (org.openkilda.messaging.info.stats.MeterStatsData)9 Test (org.junit.Test)8 MeterStatsEntry (org.openkilda.messaging.info.stats.MeterStatsEntry)5 Flow (org.openkilda.model.Flow)5 YFlow (org.openkilda.model.YFlow)4 MeterStatsAndDescriptor (org.openkilda.wfm.topology.stats.model.MeterStatsAndDescriptor)4 Datapoint (org.openkilda.messaging.info.Datapoint)3 FlowPath (org.openkilda.model.FlowPath)3 AbstractStormTest (org.openkilda.wfm.AbstractStormTest)3 CommonFlowDescriptor (org.openkilda.wfm.topology.stats.model.CommonFlowDescriptor)3 UpdateFlowPathInfo (org.openkilda.messaging.info.stats.UpdateFlowPathInfo)2 MeterId (org.openkilda.model.MeterId)2 ImmutablePair (org.apache.commons.lang3.tuple.ImmutablePair)1 Values (org.apache.storm.tuple.Values)1 Message (org.openkilda.messaging.Message)1 InfoData (org.openkilda.messaging.info.InfoData)1 InfoMessage (org.openkilda.messaging.info.InfoMessage)1 GetPacketInOutStatsResponse (org.openkilda.messaging.info.grpc.GetPacketInOutStatsResponse)1 FlowStatsData (org.openkilda.messaging.info.stats.FlowStatsData)1 MeterConfigStatsData (org.openkilda.messaging.info.stats.MeterConfigStatsData)1