Search in sources :

Example 6 with FlowStatsAndDescriptor

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));
}
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

FlowStatsAndDescriptor (org.openkilda.wfm.topology.stats.model.FlowStatsAndDescriptor)6 Test (org.junit.Test)4 FlowStatsData (org.openkilda.messaging.info.stats.FlowStatsData)4 Flow (org.openkilda.model.Flow)4 YFlow (org.openkilda.model.YFlow)4 FlowPath (org.openkilda.model.FlowPath)3 CommonFlowDescriptor (org.openkilda.wfm.topology.stats.model.CommonFlowDescriptor)3 FlowStatsEntry (org.openkilda.messaging.info.stats.FlowStatsEntry)2 UpdateFlowPathInfo (org.openkilda.messaging.info.stats.UpdateFlowPathInfo)2 RemoveFlowPathInfo (org.openkilda.messaging.info.stats.RemoveFlowPathInfo)1 Switch (org.openkilda.model.Switch)1 SwitchId (org.openkilda.model.SwitchId)1 FlowSegmentCookie (org.openkilda.model.cookie.FlowSegmentCookie)1 TestFlowBuilder (org.openkilda.wfm.share.flow.TestFlowBuilder)1 KildaEntryDescriptor (org.openkilda.wfm.topology.stats.model.KildaEntryDescriptor)1 SwitchFlowStats (org.openkilda.wfm.topology.stats.model.SwitchFlowStats)1 YFlowSubDescriptor (org.openkilda.wfm.topology.stats.model.YFlowSubDescriptor)1