use of org.openkilda.wfm.topology.stats.model.CommonFlowDescriptor 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()));
}
Aggregations