use of org.openkilda.wfm.topology.stats.model.CommonFlowDescriptor in project open-kilda by telstra.
the class KildaEntryCacheServiceTest method shouldCacheServiceRefreshMeterCache.
@Test
public void shouldCacheServiceRefreshMeterCache() {
Flow flow = buildFlow();
when(flowRepository.findAll()).thenReturn(Collections.singletonList(flow));
service.refreshCache();
MeterStatsData statsOriginSrc = getMeterStatsDataSrcSwitch();
service.completeAndForwardMeterStats(statsOriginSrc);
final MeterId forwardMeterId = flow.getForwardPath().getMeterId();
@SuppressWarnings({ "ConstantConditions" }) final MeterId forwardProtectedMeterId = flow.getProtectedForwardPath().getMeterId();
verify(carrier, atLeastOnce()).emitMeterStats(meterCacheCaptor.capture());
List<MeterStatsAndDescriptor> statsEntries = meterCacheCaptor.getValue().getStatsEntries();
assertDescriptionPopulation(statsEntries, statsOriginSrc.getStats().size(), 2);
assertMeterCache(statsEntries, forwardMeterId.getValue(), new CommonFlowDescriptor(flow.getSrcSwitchId(), INGRESS, flow.getFlowId(), flow.getForwardPath().getCookie(), forwardMeterId));
assertMeterCache(statsEntries, forwardProtectedMeterId.getValue(), new CommonFlowDescriptor(flow.getSrcSwitchId(), INGRESS, flow.getFlowId(), flow.getProtectedForwardPath().getCookie(), forwardProtectedMeterId));
MeterStatsData statsOriginDst = getMeterStatsDataDstSwitch();
service.completeAndForwardMeterStats(statsOriginDst);
verify(carrier, atLeastOnce()).emitMeterStats(meterCacheCaptor.capture());
statsEntries = meterCacheCaptor.getValue().getStatsEntries();
assertDescriptionPopulation(statsEntries, statsOriginDst.getStats().size(), 2);
final MeterId reverseMeterId = flow.getReversePath().getMeterId();
assertMeterCache(statsEntries, reverseMeterId.getValue(), new CommonFlowDescriptor(flow.getDestSwitchId(), INGRESS, flow.getFlowId(), flow.getReversePath().getCookie(), reverseMeterId));
final MeterId reverseProtectedMeterId = flow.getProtectedReversePath().getMeterId();
assertMeterCache(statsEntries, reverseProtectedMeterId.getValue(), new CommonFlowDescriptor(flow.getDestSwitchId(), INGRESS, flow.getFlowId(), flow.getProtectedReversePath().getCookie(), reverseProtectedMeterId));
}
use of org.openkilda.wfm.topology.stats.model.CommonFlowDescriptor in project open-kilda by telstra.
the class KildaEntryCacheServiceTest method shouldHandleRemovingFlowFromCache.
@Test
public void shouldHandleRemovingFlowFromCache() {
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()));
RemoveFlowPathInfo pathInfo2 = new RemoveFlowPathInfo(flow.getFlowId(), flow.getYFlowId(), forwardPath.getCookie(), forwardPath.getMeterId(), FlowPathMapper.INSTANCE.mapToPathNodes(forwardPath));
service.removeCached(pathInfo2);
service.completeAndForwardFlowStats(statsOrigin);
verify(carrier, atLeastOnce()).emitFlowStats(cookieCacheCaptor.capture());
statsEntries = cookieCacheCaptor.getValue().getStatsEntries();
assertDescriptionPopulation(statsEntries, statsOrigin.getStats().size(), 0);
}
use of org.openkilda.wfm.topology.stats.model.CommonFlowDescriptor 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);
}
use of org.openkilda.wfm.topology.stats.model.CommonFlowDescriptor in project open-kilda by telstra.
the class KildaEntryCacheServiceTest method shouldRefreshCommonFlowsCookieCache.
@Test
public void shouldRefreshCommonFlowsCookieCache() {
Flow flow = buildFlow();
when(flowRepository.findAll()).thenReturn(Collections.singletonList(flow));
when(yFlowRepository.findAll()).thenReturn(Collections.emptyList());
service.refreshCache();
final FlowPath forwardPath = flow.getForwardPath();
FlowStatsData statsOriginSrc = getFlowStatsDataSrcSwitch();
service.completeAndForwardFlowStats(statsOriginSrc);
verify(carrier, atLeastOnce()).emitFlowStats(cookieCacheCaptor.capture());
List<FlowStatsAndDescriptor> statsEntries = cookieCacheCaptor.getValue().getStatsEntries();
assertDescriptionPopulation(statsEntries, statsOriginSrc.getStats().size(), 3);
assertCookieCache(statsEntries, forwardPath.getCookie(), new CommonFlowDescriptor(flow.getSrcSwitchId(), INGRESS, flow.getFlowId(), forwardPath.getCookie(), flow.getForwardPath().getMeterId()));
assertCookieCache(statsEntries, REVERSE_PATH_COOKIE, new CommonFlowDescriptor(flow.getSrcSwitchId(), EGRESS, flow.getFlowId(), REVERSE_PATH_COOKIE, null));
assertCookieCache(statsEntries, PROTECTED_REVERSE_PATH_COOKIE, new CommonFlowDescriptor(flow.getSrcSwitchId(), EGRESS, flow.getFlowId(), PROTECTED_REVERSE_PATH_COOKIE, null));
FlowStatsData statsOriginDst = getFlowStatsDataDstSwitch();
service.completeAndForwardFlowStats(statsOriginDst);
verify(carrier, atLeastOnce()).emitFlowStats(cookieCacheCaptor.capture());
statsEntries = cookieCacheCaptor.getValue().getStatsEntries();
assertDescriptionPopulation(statsEntries, statsOriginDst.getStats().size(), 3);
assertCookieCache(statsEntries, forwardPath.getCookie(), new CommonFlowDescriptor(flow.getDestSwitchId(), EGRESS, flow.getFlowId(), forwardPath.getCookie(), null));
assertCookieCache(statsEntries, REVERSE_PATH_COOKIE, new CommonFlowDescriptor(flow.getDestSwitchId(), INGRESS, flow.getFlowId(), REVERSE_PATH_COOKIE, flow.getReversePath().getMeterId()));
assertCookieCache(statsEntries, PROTECTED_FORWARD_PATH_COOKIE, new CommonFlowDescriptor(flow.getDestSwitchId(), EGRESS, flow.getFlowId(), PROTECTED_FORWARD_PATH_COOKIE, null));
FlowStatsData statsOriginTransit = getFlowStatsDataTransitSwitch();
service.completeAndForwardFlowStats(statsOriginTransit);
verify(carrier, atLeastOnce()).emitFlowStats(cookieCacheCaptor.capture());
statsEntries = cookieCacheCaptor.getValue().getStatsEntries();
assertDescriptionPopulation(statsEntries, statsOriginTransit.getStats().size(), 4);
assertCookieCache(statsEntries, forwardPath.getCookie(), new CommonFlowDescriptor(TRANSIT_SWITCH_ID, TRANSIT, flow.getFlowId(), forwardPath.getCookie(), null));
assertCookieCache(statsEntries, REVERSE_PATH_COOKIE, new CommonFlowDescriptor(TRANSIT_SWITCH_ID, TRANSIT, flow.getFlowId(), REVERSE_PATH_COOKIE, null));
assertCookieCache(statsEntries, PROTECTED_FORWARD_PATH_COOKIE, new CommonFlowDescriptor(TRANSIT_SWITCH_ID, TRANSIT, flow.getFlowId(), PROTECTED_FORWARD_PATH_COOKIE, null));
assertCookieCache(statsEntries, PROTECTED_REVERSE_PATH_COOKIE, new CommonFlowDescriptor(TRANSIT_SWITCH_ID, TRANSIT, flow.getFlowId(), PROTECTED_REVERSE_PATH_COOKIE, null));
// flow endpoint satellites
service.completeAndForwardFlowStats(new FlowStatsData(flow.getSrcSwitchId(), asList(new FlowStatsEntry(0, forwardPath.getCookie().toBuilder().type(CookieType.SERVER_42_FLOW_RTT_INGRESS).build().getValue(), 0, 0, 0, 0), new FlowStatsEntry(0, forwardPath.getCookie().toBuilder().mirror(true).build().getValue(), 0, 0, 0, 0), new FlowStatsEntry(0, forwardPath.getCookie().toBuilder().looped(true).build().getValue(), 0, 0, 0, 0))));
verify(carrier, atLeastOnce()).emitFlowStats(cookieCacheCaptor.capture());
statsEntries = cookieCacheCaptor.getValue().getStatsEntries();
assertDescriptionPopulation(statsEntries, 3, 3);
assertCookieCache(statsEntries, forwardPath.getCookie().toBuilder().type(CookieType.SERVER_42_FLOW_RTT_INGRESS).build(), new CommonFlowDescriptor(flow.getSrcSwitchId(), INGRESS, flow.getFlowId(), forwardPath.getCookie(), forwardPath.getMeterId()));
assertCookieCache(statsEntries, forwardPath.getCookie().toBuilder().mirror(true).build(), new CommonFlowDescriptor(flow.getSrcSwitchId(), INGRESS, flow.getFlowId(), forwardPath.getCookie(), forwardPath.getMeterId()));
assertCookieCache(statsEntries, forwardPath.getCookie().toBuilder().looped(true).build(), new CommonFlowDescriptor(flow.getSrcSwitchId(), INGRESS, flow.getFlowId(), forwardPath.getCookie(), forwardPath.getMeterId()));
}
use of org.openkilda.wfm.topology.stats.model.CommonFlowDescriptor 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