Search in sources :

Example 6 with TestFlowBuilder

use of org.openkilda.wfm.share.flow.TestFlowBuilder in project open-kilda by telstra.

the class FlowOperationsServiceTest method testStrictBandwidthAndIgnoreBandwidthFlowConflict.

@Test(expected = IllegalArgumentException.class)
public void testStrictBandwidthAndIgnoreBandwidthFlowConflict() throws FlowNotFoundException {
    String testFlowId = "flow_id";
    Flow flow = new TestFlowBuilder().flowId(testFlowId).srcSwitch(createSwitch(SWITCH_ID_1)).destSwitch(createSwitch(SWITCH_ID_2)).ignoreBandwidth(true).build();
    flowRepository.add(flow);
    FlowPatch receivedFlow = FlowPatch.builder().flowId(testFlowId).strictBandwidth(true).ignoreBandwidth(false).build();
    flowOperationsService.updateFlow(new FlowCarrierImpl(), receivedFlow);
}
Also used : FlowPatch(org.openkilda.messaging.model.FlowPatch) TestFlowBuilder(org.openkilda.wfm.share.flow.TestFlowBuilder) Flow(org.openkilda.model.Flow) InMemoryGraphBasedTest(org.openkilda.persistence.inmemory.InMemoryGraphBasedTest) Test(org.junit.Test)

Example 7 with TestFlowBuilder

use of org.openkilda.wfm.share.flow.TestFlowBuilder in project open-kilda by telstra.

the class StatsTopologyTest method createFlow.

private Flow createFlow() {
    Switch srcSw = Switch.builder().switchId(SWITCH_ID_1).build();
    switchRepository.add(srcSw);
    Switch dstSw = Switch.builder().switchId(SWITCH_ID_3).build();
    switchRepository.add(dstSw);
    Flow flow = new TestFlowBuilder(flowId).srcSwitch(srcSw).srcPort(PORT_1).srcVlan(5).addTransitionEndpoint(srcSw, PORT_2).addTransitionEndpoint(dstSw, PORT_1).unmaskedCookie(MAIN_COOKIE).forwardMeterId(456).forwardTransitEncapsulationId(ENCAPSULATION_ID).reverseMeterId(457).reverseTransitEncapsulationId(ENCAPSULATION_ID + 1).destSwitch(dstSw).destPort(PORT_3).destVlan(5).encapsulationType(FlowEncapsulationType.TRANSIT_VLAN).build();
    flowRepository.add(flow);
    return flow;
}
Also used : Switch(org.openkilda.model.Switch) TestFlowBuilder(org.openkilda.wfm.share.flow.TestFlowBuilder) Flow(org.openkilda.model.Flow)

Example 8 with TestFlowBuilder

use of org.openkilda.wfm.share.flow.TestFlowBuilder in project open-kilda by telstra.

the class KildaEntryCacheServiceTest method buildFlow.

private Flow buildFlow() {
    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();
    return new TestFlowBuilder().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).addProtectedTransitionEndpoint(srcSwitch, 3).addProtectedTransitionEndpoint(transitSwitch, 3).addProtectedTransitionEndpoint(transitSwitch, 4).addProtectedTransitionEndpoint(destSwitch, 3).protectedUnmaskedCookie(FLOW_PROTECTED_UNMASKED_COOKIE).protectedForwardMeterId(PROTECTED_FORWARD_METER_ID).protectedReverseMeterId(PROTECTED_REVERSE_METER_ID).destSwitch(destSwitch).build();
}
Also used : Switch(org.openkilda.model.Switch) TestFlowBuilder(org.openkilda.wfm.share.flow.TestFlowBuilder)

Example 9 with TestFlowBuilder

use of org.openkilda.wfm.share.flow.TestFlowBuilder 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)

Example 10 with TestFlowBuilder

use of org.openkilda.wfm.share.flow.TestFlowBuilder in project open-kilda by telstra.

the class KildaEntryCacheServiceTest method shouldRefreshYFlowMeterCache.

@Test
public void shouldRefreshYFlowMeterCache() {
    FlowEndpoint sharedEndpoint = new FlowEndpoint(SRC_SWITCH_ID, 1);
    FlowEndpoint splitEndEndpoint = new FlowEndpoint(DST_SWITCH_ID, 2);
    Switch sharedSwitch = Switch.builder().switchId(sharedEndpoint.getSwitchId()).build();
    Switch splitEndSwitch = Switch.builder().switchId(splitEndEndpoint.getSwitchId()).build();
    Switch yPointSwitch = Switch.builder().switchId(TRANSIT_SWITCH_ID).build();
    Flow subFlowAlpha = new TestFlowBuilder().srcSwitch(sharedSwitch).destSwitch(splitEndSwitch).addTransitionEndpoint(sharedSwitch, sharedEndpoint.getPortNumber()).addTransitionEndpoint(yPointSwitch, 1).addTransitionEndpoint(yPointSwitch, 2).addTransitionEndpoint(splitEndSwitch, sharedEndpoint.getPortNumber()).build();
    Flow subFlowBeta = new TestFlowBuilder().srcSwitch(sharedSwitch).destSwitch(splitEndSwitch).addTransitionEndpoint(sharedSwitch, sharedEndpoint.getPortNumber()).addTransitionEndpoint(yPointSwitch, 1).addTransitionEndpoint(yPointSwitch, 2).addTransitionEndpoint(splitEndSwitch, sharedEndpoint.getPortNumber()).build();
    YFlow yFlow = new TestYFlowBuilder().sharedEndpoint(new YFlow.SharedEndpoint(sharedEndpoint.getSwitchId(), sharedEndpoint.getPortNumber())).sharedEndpointMeterId(new MeterId(100)).yPoint(yPointSwitch.getSwitchId()).meterId(new MeterId(110)).subFlow(new TestYSubFlowBuilder().flow(subFlowAlpha).sharedEndpointVlan(10).endpoint(new FlowEndpoint(DST_SWITCH_ID, 2, 30))).subFlow(new TestYSubFlowBuilder().flow(subFlowBeta).sharedEndpointVlan(20).endpoint(new FlowEndpoint(DST_SWITCH_ID, 2, 40))).build();
    when(flowRepository.findAll()).thenReturn(Collections.emptyList());
    when(yFlowRepository.findAll()).thenReturn(Collections.singletonList(yFlow));
    service.refreshCache();
    // shared endpoint
    service.completeAndForwardMeterStats(new MeterStatsData(yFlow.getSharedEndpoint().getSwitchId(), Collections.singletonList(new MeterStatsEntry(yFlow.getSharedEndpointMeterId().getValue(), 0, 0))));
    verify(carrier, atLeastOnce()).emitMeterStats(meterCacheCaptor.capture());
    List<MeterStatsAndDescriptor> statsEntries = meterCacheCaptor.getValue().getStatsEntries();
    assertDescriptionPopulation(statsEntries, 1, 1);
    assertMeterCache(statsEntries, yFlow.getSharedEndpointMeterId().getValue(), new YFlowDescriptor(yFlow.getSharedEndpoint().getSwitchId(), Y_FLOW_SHARED, yFlow.getYFlowId(), yFlow.getSharedEndpointMeterId()));
    // y-point
    service.completeAndForwardMeterStats(new MeterStatsData(yFlow.getYPoint(), Collections.singletonList(new MeterStatsEntry(yFlow.getMeterId().getValue(), 0, 0))));
    verify(carrier, atLeastOnce()).emitMeterStats(meterCacheCaptor.capture());
    statsEntries = meterCacheCaptor.getValue().getStatsEntries();
    assertDescriptionPopulation(statsEntries, 1, 1);
    assertMeterCache(statsEntries, yFlow.getMeterId().getValue(), new YFlowDescriptor(yFlow.getYPoint(), Y_FLOW_Y_POINT, yFlow.getYFlowId(), yFlow.getMeterId()));
}
Also used : YFlow(org.openkilda.model.YFlow) MeterStatsAndDescriptor(org.openkilda.wfm.topology.stats.model.MeterStatsAndDescriptor) TestFlowBuilder(org.openkilda.wfm.share.flow.TestFlowBuilder) Flow(org.openkilda.model.Flow) YFlow(org.openkilda.model.YFlow) TestYFlowBuilder(org.openkilda.wfm.share.yflow.TestYFlowBuilder) MeterId(org.openkilda.model.MeterId) MeterStatsData(org.openkilda.messaging.info.stats.MeterStatsData) FlowEndpoint(org.openkilda.model.FlowEndpoint) Switch(org.openkilda.model.Switch) YFlowDescriptor(org.openkilda.wfm.topology.stats.model.YFlowDescriptor) MeterStatsEntry(org.openkilda.messaging.info.stats.MeterStatsEntry) TestYSubFlowBuilder(org.openkilda.wfm.share.yflow.TestYSubFlowBuilder) Test(org.junit.Test)

Aggregations

TestFlowBuilder (org.openkilda.wfm.share.flow.TestFlowBuilder)10 Flow (org.openkilda.model.Flow)9 Test (org.junit.Test)6 Switch (org.openkilda.model.Switch)6 FlowPatch (org.openkilda.messaging.model.FlowPatch)4 InMemoryGraphBasedTest (org.openkilda.persistence.inmemory.InMemoryGraphBasedTest)4 YFlow (org.openkilda.model.YFlow)2 FlowStatsData (org.openkilda.messaging.info.stats.FlowStatsData)1 FlowStatsEntry (org.openkilda.messaging.info.stats.FlowStatsEntry)1 MeterStatsData (org.openkilda.messaging.info.stats.MeterStatsData)1 MeterStatsEntry (org.openkilda.messaging.info.stats.MeterStatsEntry)1 FlowEndpoint (org.openkilda.model.FlowEndpoint)1 MeterId (org.openkilda.model.MeterId)1 PathComputationStrategy (org.openkilda.model.PathComputationStrategy)1 FlowSegmentCookie (org.openkilda.model.cookie.FlowSegmentCookie)1 TestYFlowBuilder (org.openkilda.wfm.share.yflow.TestYFlowBuilder)1 TestYSubFlowBuilder (org.openkilda.wfm.share.yflow.TestYSubFlowBuilder)1 FlowStatsAndDescriptor (org.openkilda.wfm.topology.stats.model.FlowStatsAndDescriptor)1 MeterStatsAndDescriptor (org.openkilda.wfm.topology.stats.model.MeterStatsAndDescriptor)1 YFlowDescriptor (org.openkilda.wfm.topology.stats.model.YFlowDescriptor)1