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