Search in sources :

Example 6 with UpdateFlowPathInfo

use of org.openkilda.messaging.info.stats.UpdateFlowPathInfo 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)

Example 7 with UpdateFlowPathInfo

use of org.openkilda.messaging.info.stats.UpdateFlowPathInfo 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

UpdateFlowPathInfo (org.openkilda.messaging.info.stats.UpdateFlowPathInfo)7 Flow (org.openkilda.model.Flow)6 Test (org.junit.Test)4 FlowPath (org.openkilda.model.FlowPath)4 YFlow (org.openkilda.model.YFlow)4 CommonFlowDescriptor (org.openkilda.wfm.topology.stats.model.CommonFlowDescriptor)4 FlowStatsData (org.openkilda.messaging.info.stats.FlowStatsData)2 MeterStatsData (org.openkilda.messaging.info.stats.MeterStatsData)2 RemoveFlowPathInfo (org.openkilda.messaging.info.stats.RemoveFlowPathInfo)2 FlowStatsAndDescriptor (org.openkilda.wfm.topology.stats.model.FlowStatsAndDescriptor)2 MeterStatsAndDescriptor (org.openkilda.wfm.topology.stats.model.MeterStatsAndDescriptor)2 Optional (java.util.Optional)1 InfoMessage (org.openkilda.messaging.info.InfoMessage)1