Search in sources :

Example 1 with CommonFlowDescriptor

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));
}
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) Flow(org.openkilda.model.Flow) YFlow(org.openkilda.model.YFlow) MeterId(org.openkilda.model.MeterId) Test(org.junit.Test)

Example 2 with CommonFlowDescriptor

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);
}
Also used : FlowStatsAndDescriptor(org.openkilda.wfm.topology.stats.model.FlowStatsAndDescriptor) CommonFlowDescriptor(org.openkilda.wfm.topology.stats.model.CommonFlowDescriptor) FlowStatsData(org.openkilda.messaging.info.stats.FlowStatsData) 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 3 with CommonFlowDescriptor

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);
}
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 4 with CommonFlowDescriptor

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()));
}
Also used : FlowStatsAndDescriptor(org.openkilda.wfm.topology.stats.model.FlowStatsAndDescriptor) CommonFlowDescriptor(org.openkilda.wfm.topology.stats.model.CommonFlowDescriptor) FlowStatsEntry(org.openkilda.messaging.info.stats.FlowStatsEntry) FlowStatsData(org.openkilda.messaging.info.stats.FlowStatsData) FlowPath(org.openkilda.model.FlowPath) Flow(org.openkilda.model.Flow) YFlow(org.openkilda.model.YFlow) Test(org.junit.Test)

Example 5 with CommonFlowDescriptor

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));
}
Also used : FlowStatsAndDescriptor(org.openkilda.wfm.topology.stats.model.FlowStatsAndDescriptor) CommonFlowDescriptor(org.openkilda.wfm.topology.stats.model.CommonFlowDescriptor) FlowStatsData(org.openkilda.messaging.info.stats.FlowStatsData) 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

Test (org.junit.Test)6 Flow (org.openkilda.model.Flow)6 YFlow (org.openkilda.model.YFlow)6 CommonFlowDescriptor (org.openkilda.wfm.topology.stats.model.CommonFlowDescriptor)6 FlowPath (org.openkilda.model.FlowPath)5 UpdateFlowPathInfo (org.openkilda.messaging.info.stats.UpdateFlowPathInfo)4 FlowStatsData (org.openkilda.messaging.info.stats.FlowStatsData)3 MeterStatsData (org.openkilda.messaging.info.stats.MeterStatsData)3 FlowStatsAndDescriptor (org.openkilda.wfm.topology.stats.model.FlowStatsAndDescriptor)3 MeterStatsAndDescriptor (org.openkilda.wfm.topology.stats.model.MeterStatsAndDescriptor)3 RemoveFlowPathInfo (org.openkilda.messaging.info.stats.RemoveFlowPathInfo)2 FlowStatsEntry (org.openkilda.messaging.info.stats.FlowStatsEntry)1 MeterId (org.openkilda.model.MeterId)1