Search in sources :

Example 1 with YFlowSubDescriptor

use of org.openkilda.wfm.topology.stats.model.YFlowSubDescriptor in project open-kilda by telstra.

the class KildaEntryCacheServiceTest method shouldRefreshYFlowSubFlowCookieCache.

@Test
public void shouldRefreshYFlowSubFlowCookieCache() {
    Switch srcSwitch = Switch.builder().switchId(SRC_SWITCH_ID).build();
    Switch destSwitch = Switch.builder().switchId(DST_SWITCH_ID).build();
    Switch transitSwitch = Switch.builder().switchId(TRANSIT_SWITCH_ID).build();
    Flow flow = new TestFlowBuilder().yFlowId("dummy-y-flow-id").srcSwitch(srcSwitch).addTransitionEndpoint(srcSwitch, 2).addTransitionEndpoint(transitSwitch, 1).addTransitionEndpoint(transitSwitch, 2).addTransitionEndpoint(destSwitch, 1).unmaskedCookie(FLOW_UNMASKED_COOKIE).forwardMeterId(FORWARD_METER_ID).reverseMeterId(REVERSE_METER_ID).destSwitch(destSwitch).build();
    when(flowRepository.findAll()).thenReturn(Collections.singletonList(flow));
    when(yFlowRepository.findAll()).thenReturn(Collections.emptyList());
    service.refreshCache();
    final FlowSegmentCookie forwardPathCookie = flow.getForwardPath().getCookie();
    final FlowSegmentCookie reversePathCookie = flow.getReversePath().getCookie();
    // source switch
    service.completeAndForwardFlowStats(new FlowStatsData(flow.getSrcSwitchId(), asList(new FlowStatsEntry(0, forwardPathCookie.getValue(), 0, 0, 0, 0), new FlowStatsEntry(0, reversePathCookie.getValue(), 0, 0, 0, 0))));
    verify(carrier, atLeastOnce()).emitFlowStats(cookieCacheCaptor.capture());
    List<FlowStatsAndDescriptor> statsEntries = cookieCacheCaptor.getValue().getStatsEntries();
    assertDescriptionPopulation(statsEntries, 2, 2);
    assertCookieCache(statsEntries, forwardPathCookie, new YFlowSubDescriptor(flow.getSrcSwitchId(), INGRESS, flow.getYFlowId(), flow.getFlowId(), forwardPathCookie, flow.getForwardPath().getMeterId()));
    assertCookieCache(statsEntries, reversePathCookie, new YFlowSubDescriptor(flow.getSrcSwitchId(), EGRESS, flow.getYFlowId(), flow.getFlowId(), reversePathCookie, null));
    // transit
    service.completeAndForwardFlowStats(new FlowStatsData(transitSwitch.getSwitchId(), asList(new FlowStatsEntry(0, forwardPathCookie.getValue(), 0, 0, 0, 0), new FlowStatsEntry(0, reversePathCookie.getValue(), 0, 0, 0, 0))));
    verify(carrier, atLeastOnce()).emitFlowStats(cookieCacheCaptor.capture());
    statsEntries = cookieCacheCaptor.getValue().getStatsEntries();
    assertDescriptionPopulation(statsEntries, 2, 2);
    assertCookieCache(statsEntries, forwardPathCookie, new YFlowSubDescriptor(transitSwitch.getSwitchId(), TRANSIT, flow.getYFlowId(), flow.getFlowId(), forwardPathCookie, null));
    assertCookieCache(statsEntries, reversePathCookie, new YFlowSubDescriptor(transitSwitch.getSwitchId(), TRANSIT, flow.getYFlowId(), flow.getFlowId(), reversePathCookie, null));
    // egress
    service.completeAndForwardFlowStats(new FlowStatsData(flow.getDestSwitchId(), asList(new FlowStatsEntry(0, forwardPathCookie.getValue(), 0, 0, 0, 0), new FlowStatsEntry(0, reversePathCookie.getValue(), 0, 0, 0, 0))));
    verify(carrier, atLeastOnce()).emitFlowStats(cookieCacheCaptor.capture());
    statsEntries = cookieCacheCaptor.getValue().getStatsEntries();
    assertDescriptionPopulation(statsEntries, 2, 2);
    assertCookieCache(statsEntries, forwardPathCookie, new YFlowSubDescriptor(flow.getDestSwitchId(), EGRESS, flow.getYFlowId(), flow.getFlowId(), forwardPathCookie, null));
    assertCookieCache(statsEntries, reversePathCookie, new YFlowSubDescriptor(flow.getDestSwitchId(), INGRESS, flow.getYFlowId(), flow.getFlowId(), reversePathCookie, flow.getReversePath().getMeterId()));
}
Also used : FlowStatsAndDescriptor(org.openkilda.wfm.topology.stats.model.FlowStatsAndDescriptor) FlowSegmentCookie(org.openkilda.model.cookie.FlowSegmentCookie) Switch(org.openkilda.model.Switch) FlowStatsEntry(org.openkilda.messaging.info.stats.FlowStatsEntry) FlowStatsData(org.openkilda.messaging.info.stats.FlowStatsData) YFlowSubDescriptor(org.openkilda.wfm.topology.stats.model.YFlowSubDescriptor) TestFlowBuilder(org.openkilda.wfm.share.flow.TestFlowBuilder) Flow(org.openkilda.model.Flow) YFlow(org.openkilda.model.YFlow) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)1 FlowStatsData (org.openkilda.messaging.info.stats.FlowStatsData)1 FlowStatsEntry (org.openkilda.messaging.info.stats.FlowStatsEntry)1 Flow (org.openkilda.model.Flow)1 Switch (org.openkilda.model.Switch)1 YFlow (org.openkilda.model.YFlow)1 FlowSegmentCookie (org.openkilda.model.cookie.FlowSegmentCookie)1 TestFlowBuilder (org.openkilda.wfm.share.flow.TestFlowBuilder)1 FlowStatsAndDescriptor (org.openkilda.wfm.topology.stats.model.FlowStatsAndDescriptor)1 YFlowSubDescriptor (org.openkilda.wfm.topology.stats.model.YFlowSubDescriptor)1