use of org.openkilda.persistence.repositories.YFlowRepository in project open-kilda by telstra.
the class AbstractYFlowTest method createYFlowViaTransit.
protected YFlow createYFlowViaTransit(String yFlowId) {
// Create sub-flows
Flow firstFlow = dummyFactory.makeMainAffinityFlow(firstSharedEndpoint, firstEndpoint, islSharedToTransit, islTransitToFirst);
Flow secondFlow = dummyFactory.makeFlow(secondSharedEndpoint, secondEndpoint, firstFlow.getAffinityGroupId(), islSharedToTransit, islTransitToSecond);
SwitchId yPoint = SWITCH_TRANSIT;
FlowMeter yPointMeter = dummyFactory.makeFlowMeter(yPoint, yFlowId, null);
FlowMeter sharedEndpointMeter = dummyFactory.makeFlowMeter(firstSharedEndpoint.getSwitchId(), yFlowId, null);
YFlow yFlow = YFlow.builder().yFlowId(yFlowId).sharedEndpoint(new SharedEndpoint(firstSharedEndpoint.getSwitchId(), firstSharedEndpoint.getPortNumber())).sharedEndpointMeterId(sharedEndpointMeter.getMeterId()).yPoint(yPoint).meterId(yPointMeter.getMeterId()).status(FlowStatus.UP).build();
yFlow.setSubFlows(Stream.of(firstFlow, secondFlow).map(flow -> YSubFlow.builder().sharedEndpointVlan(flow.getSrcVlan()).sharedEndpointInnerVlan(flow.getSrcInnerVlan()).endpointSwitchId(flow.getDestSwitchId()).endpointPort(flow.getDestPort()).endpointVlan(flow.getDestVlan()).endpointInnerVlan(flow.getDestInnerVlan()).flow(flow).yFlow(yFlow).build()).collect(Collectors.toSet()));
YFlowRepository yFlowRepository = persistenceManager.getRepositoryFactory().createYFlowRepository();
yFlowRepository.add(yFlow);
return yFlow;
}
use of org.openkilda.persistence.repositories.YFlowRepository in project open-kilda by telstra.
the class AbstractYFlowTest method createYFlowWithProtected.
protected YFlow createYFlowWithProtected(String yFlowId) {
dummyFactory.getFlowDefaults().setAllocateProtectedPath(true);
// Create sub-flows
Flow firstFlow = dummyFactory.makeMainAffinityFlowWithProtectedPath(firstSharedEndpoint, firstEndpoint, asList(islSharedToTransit, islTransitToFirst), asList(islSharedToAltTransit, islAltTransitToFirst));
Flow secondFlow = dummyFactory.makeFlowWithProtectedPath(secondSharedEndpoint, secondEndpoint, firstFlow.getAffinityGroupId(), asList(islSharedToTransit, islTransitToSecond), asList(islSharedToAltTransit, islAltTransitToSecond));
YFlow yFlow = YFlow.builder().yFlowId(yFlowId).sharedEndpoint(new SharedEndpoint(firstSharedEndpoint.getSwitchId(), firstSharedEndpoint.getPortNumber())).allocateProtectedPath(true).status(FlowStatus.UP).build();
yFlow.setSubFlows(Stream.of(firstFlow, secondFlow).map(flow -> YSubFlow.builder().sharedEndpointVlan(flow.getSrcVlan()).sharedEndpointInnerVlan(flow.getSrcInnerVlan()).endpointSwitchId(flow.getDestSwitchId()).endpointPort(flow.getDestPort()).endpointVlan(flow.getDestVlan()).endpointInnerVlan(flow.getDestInnerVlan()).flow(flow).yFlow(yFlow).build()).collect(Collectors.toSet()));
YFlowRepository yFlowRepository = persistenceManager.getRepositoryFactory().createYFlowRepository();
yFlowRepository.add(yFlow);
return yFlow;
}
use of org.openkilda.persistence.repositories.YFlowRepository in project open-kilda by telstra.
the class AbstractYFlowTest method verifyYFlowIsAbsent.
protected void verifyYFlowIsAbsent(String yFlowId) {
YFlowRepository repository = persistenceManager.getRepositoryFactory().createYFlowRepository();
assertFalse(repository.findById(yFlowId).isPresent());
}
use of org.openkilda.persistence.repositories.YFlowRepository in project open-kilda by telstra.
the class RerouteServiceTest method processManualRerouteRequestForYFlow.
@Test
public void processManualRerouteRequestForYFlow() {
RepositoryFactory repositoryFactory = mock(RepositoryFactory.class);
YFlowRepository yFlowRepository = mock(YFlowRepository.class);
when(repositoryFactory.createYFlowRepository()).thenReturn(yFlowRepository);
PersistenceManager persistenceManager = mock(PersistenceManager.class);
when(persistenceManager.getRepositoryFactory()).thenReturn(repositoryFactory);
when(persistenceManager.getTransactionManager()).thenReturn(transactionManager);
when(yFlowRepository.findById(YFLOW_ID)).thenReturn(Optional.of(regularYFlow));
RerouteService rerouteService = new RerouteService(persistenceManager);
YFlowRerouteRequest request = new YFlowRerouteRequest(regularYFlow.getYFlowId(), Collections.emptySet(), true, "reason", false);
rerouteService.processRerouteRequest(carrier, CORRELATION_ID, request);
FlowThrottlingData expected = FlowThrottlingData.builder().correlationId(CORRELATION_ID).priority(regularYFlow.getPriority()).timeCreate(regularYFlow.getTimeCreate()).affectedIsl(Collections.emptySet()).force(true).reason("reason").yFlow(true).build();
verify(carrier).emitManualRerouteCommand(eq(regularYFlow.getYFlowId()), eq(expected));
}
use of org.openkilda.persistence.repositories.YFlowRepository in project open-kilda by telstra.
the class YFlowCreateServiceTest method shouldFailOnErrorDuringDraftYFlowCreation.
@Test
public void shouldFailOnErrorDuringDraftYFlowCreation() throws RecoverableException, UnroutableFlowException, DuplicateKeyException {
// given
YFlowRequest request = buildYFlowRequest("test_failed_yflow", "test_flow_1", "test_flow_2").build();
YFlowRepository repository = setupYFlowRepositorySpy();
doThrow(new RuntimeException(injectedErrorMessage)).when(repository).add(ArgumentMatchers.argThat(argument -> argument.getYFlowId().equals(request.getYFlowId())));
preparePathComputation("test_flow_1", buildFirstSubFlowPathPair());
preparePathComputation("test_flow_2", buildSecondSubFlowPathPair());
prepareYPointComputation(SWITCH_SHARED, SWITCH_FIRST_EP, SWITCH_SECOND_EP, SWITCH_TRANSIT);
// when
processRequest(request);
// then
verifyNorthboundErrorResponse(yFlowCreateHubCarrier, ErrorType.INTERNAL_ERROR);
verifyNoSpeakerInteraction(yFlowCreateHubCarrier);
verifyYFlowIsAbsent(request.getYFlowId());
}
Aggregations