Search in sources :

Example 71 with YFlow

use of org.openkilda.model.YFlow in project open-kilda by telstra.

the class YFlowUpdateServiceTest method shouldFailIfNoPathAvailableForFirstSubFlow.

@Test
public void shouldFailIfNoPathAvailableForFirstSubFlow() throws UnroutableFlowException, RecoverableException, DuplicateKeyException {
    // given
    YFlowRequest request = createYFlow();
    request.setMaximumBandwidth(2000L);
    request.getSubFlows().get(0).setEndpoint(newFirstEndpoint);
    request.getSubFlows().get(1).setEndpoint(newSecondEndpoint);
    when(pathComputer.getPath(buildFlowIdArgumentMatch("test_flow_1"), any())).thenThrow(new UnroutableFlowException(injectedErrorMessage));
    preparePathComputationForUpdate("test_flow_2", buildNewSecondSubFlowPathPair(), buildSecondSubFlowPathPair());
    prepareYPointComputation(SWITCH_SHARED, SWITCH_NEW_FIRST_EP, SWITCH_NEW_SECOND_EP, SWITCH_TRANSIT);
    // when
    processUpdateRequestAndSpeakerCommands(request);
    verifyNorthboundErrorResponse(yFlowUpdateHubCarrier, ErrorType.NOT_FOUND);
    verifyYFlowStatus(request.getYFlowId(), FlowStatus.UP);
    YFlow flow = getYFlow(request.getYFlowId());
    assertEquals(1000L, flow.getMaximumBandwidth());
    Set<SwitchId> expectedEndpointSwitchIds = Stream.of(SWITCH_FIRST_EP, SWITCH_SECOND_EP).collect(Collectors.toSet());
    Set<SwitchId> actualEndpointSwitchIds = flow.getSubFlows().stream().map(YSubFlow::getEndpointSwitchId).collect(Collectors.toSet());
    assertEquals(expectedEndpointSwitchIds, actualEndpointSwitchIds);
}
Also used : YFlow(org.openkilda.model.YFlow) UnroutableFlowException(org.openkilda.pce.exception.UnroutableFlowException) SwitchId(org.openkilda.model.SwitchId) YFlowRequest(org.openkilda.messaging.command.yflow.YFlowRequest) Test(org.junit.Test) AbstractYFlowTest(org.openkilda.wfm.topology.flowhs.service.AbstractYFlowTest)

Example 72 with YFlow

use of org.openkilda.model.YFlow in project open-kilda by telstra.

the class YFlowUpdateServiceTest method verifyYFlowStatus.

protected YFlow verifyYFlowStatus(String yFlowId, FlowStatus expectedStatus, FlowStatus expectedFirstSubFlowStatus, FlowStatus expectedSecondSubFlowStatus) {
    YFlow flow = getYFlow(yFlowId);
    assertEquals(expectedStatus, flow.getStatus());
    Set<FlowStatus> expectedSubFlowStatuses = Stream.of(expectedFirstSubFlowStatus, expectedSecondSubFlowStatus).collect(Collectors.toSet());
    Set<FlowStatus> actualSubFlowStatuses = flow.getSubFlows().stream().map(YSubFlow::getFlow).map(Flow::getStatus).collect(Collectors.toSet());
    assertEquals(expectedSubFlowStatuses, actualSubFlowStatuses);
    return flow;
}
Also used : YFlow(org.openkilda.model.YFlow) FlowStatus(org.openkilda.model.FlowStatus) YSubFlow(org.openkilda.model.YSubFlow)

Example 73 with YFlow

use of org.openkilda.model.YFlow in project open-kilda by telstra.

the class FermaYFlowRepositoryTest method createYFlow.

private YFlow createYFlow(String yFlowId, String flowId1, String flowId2) {
    YFlow yFlow = YFlow.builder().yFlowId(yFlowId).encapsulationType(FlowEncapsulationType.TRANSIT_VLAN).sharedEndpoint(new SharedEndpoint(SWITCH_ID_1, PORT_1)).build();
    Flow flow1 = createTestFlow(flowId1, switch1, PORT_1, VLAN_1, switch2, PORT_3, VLAN_3);
    Flow flow2 = createTestFlow(flowId2, switch1, PORT_1, VLAN_2, switch3, PORT_4, VLAN_3);
    YSubFlow subFlow1 = YSubFlow.builder().yFlow(yFlow).flow(flow1).endpointSwitchId(SWITCH_ID_2).endpointPort(PORT_3).endpointVlan(VLAN_3).sharedEndpointVlan(VLAN_1).build();
    YSubFlow subFlow2 = YSubFlow.builder().yFlow(yFlow).flow(flow2).endpointSwitchId(SWITCH_ID_3).endpointPort(PORT_4).endpointVlan(VLAN_3).sharedEndpointVlan(VLAN_2).build();
    yFlow.addSubFlow(subFlow1);
    yFlow.addSubFlow(subFlow2);
    yFlowRepository.add(yFlow);
    return yFlow;
}
Also used : YFlow(org.openkilda.model.YFlow) SharedEndpoint(org.openkilda.model.YFlow.SharedEndpoint) YSubFlow(org.openkilda.model.YSubFlow) Flow(org.openkilda.model.Flow) YFlow(org.openkilda.model.YFlow) YSubFlow(org.openkilda.model.YSubFlow)

Example 74 with YFlow

use of org.openkilda.model.YFlow 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

YFlow (org.openkilda.model.YFlow)74 Flow (org.openkilda.model.Flow)30 SwitchId (org.openkilda.model.SwitchId)29 YSubFlow (org.openkilda.model.YSubFlow)26 FlowProcessingException (org.openkilda.wfm.topology.flowhs.exception.FlowProcessingException)19 Test (org.junit.Test)12 YFlowRequest (org.openkilda.messaging.command.yflow.YFlowRequest)12 ArrayList (java.util.ArrayList)11 FlowStatus (org.openkilda.model.FlowStatus)10 CommandContext (org.openkilda.wfm.CommandContext)10 AbstractYFlowTest (org.openkilda.wfm.topology.flowhs.service.AbstractYFlowTest)10 FlowPath (org.openkilda.model.FlowPath)9 FlowEndpoint (org.openkilda.model.FlowEndpoint)8 InstallSpeakerCommandsRequest (org.openkilda.floodlight.api.request.rulemanager.InstallSpeakerCommandsRequest)6 Switch (org.openkilda.model.Switch)6 HashSet (java.util.HashSet)5 DeleteSpeakerCommandsRequest (org.openkilda.floodlight.api.request.rulemanager.DeleteSpeakerCommandsRequest)5 SharedEndpoint (org.openkilda.model.YFlow.SharedEndpoint)5 Collection (java.util.Collection)4 HashMap (java.util.HashMap)4