use of org.openkilda.wfm.topology.stats.model.FlowStatsAndDescriptor in project open-kilda by telstra.
the class KildaEntryCacheServiceTest method shouldCompleteFlowStats.
@Test
public void shouldCompleteFlowStats() {
Flow flow = buildFlow();
FlowStatsData statsOrigin = getFlowStatsDataSrcSwitch();
service.completeAndForwardFlowStats(statsOrigin);
verify(carrier, atLeastOnce()).emitFlowStats(cookieCacheCaptor.capture());
List<FlowStatsAndDescriptor> statsEntries = cookieCacheCaptor.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.completeAndForwardFlowStats(statsOrigin);
verify(carrier, atLeastOnce()).emitFlowStats(cookieCacheCaptor.capture());
statsEntries = cookieCacheCaptor.getValue().getStatsEntries();
assertDescriptionPopulation(statsEntries, statsOrigin.getStats().size(), 1);
assertCookieCache(statsEntries, forwardPath.getCookie(), new CommonFlowDescriptor(flow.getSrcSwitchId(), INGRESS, flow.getFlowId(), forwardPath.getCookie(), forwardPath.getMeterId()));
FlowPath reversePath = flow.getReversePath();
UpdateFlowPathInfo pathInfo2 = new UpdateFlowPathInfo(flow.getFlowId(), flow.getYFlowId(), reversePath.getCookie(), reversePath.getMeterId(), FlowPathMapper.INSTANCE.mapToPathNodes(reversePath));
service.addOrUpdateCache(pathInfo2);
service.completeAndForwardFlowStats(statsOrigin);
verify(carrier, atLeastOnce()).emitFlowStats(cookieCacheCaptor.capture());
statsEntries = cookieCacheCaptor.getValue().getStatsEntries();
assertDescriptionPopulation(statsEntries, statsOrigin.getStats().size(), 2);
assertCookieCache(statsEntries, forwardPath.getCookie(), new CommonFlowDescriptor(flow.getSrcSwitchId(), INGRESS, flow.getFlowId(), forwardPath.getCookie(), forwardPath.getMeterId()));
assertCookieCache(statsEntries, reversePath.getCookie(), new CommonFlowDescriptor(flow.getSrcSwitchId(), EGRESS, flow.getFlowId(), reversePath.getCookie(), null));
FlowPath protectedReversePath = flow.getProtectedReversePath();
UpdateFlowPathInfo pathInfo3 = new UpdateFlowPathInfo(flow.getFlowId(), flow.getYFlowId(), protectedReversePath.getCookie(), protectedReversePath.getMeterId(), FlowPathMapper.INSTANCE.mapToPathNodes(protectedReversePath));
service.addOrUpdateCache(pathInfo3);
service.completeAndForwardFlowStats(statsOrigin);
verify(carrier, atLeastOnce()).emitFlowStats(cookieCacheCaptor.capture());
statsEntries = cookieCacheCaptor.getValue().getStatsEntries();
assertDescriptionPopulation(statsEntries, statsOrigin.getStats().size(), 3);
assertCookieCache(statsEntries, forwardPath.getCookie(), new CommonFlowDescriptor(flow.getSrcSwitchId(), INGRESS, flow.getFlowId(), forwardPath.getCookie(), forwardPath.getMeterId()));
assertCookieCache(statsEntries, reversePath.getCookie(), new CommonFlowDescriptor(flow.getSrcSwitchId(), EGRESS, flow.getFlowId(), reversePath.getCookie(), null));
assertCookieCache(statsEntries, protectedReversePath.getCookie(), new CommonFlowDescriptor(flow.getSrcSwitchId(), EGRESS, flow.getFlowId(), protectedReversePath.getCookie(), null));
}
Aggregations