use of org.openkilda.model.YFlow.SharedEndpoint 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.model.YFlow.SharedEndpoint 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.model.YFlow.SharedEndpoint in project open-kilda by telstra.
the class RerouteQueueServiceTest method shouldSendCorrectErrorMessageForManualRerouteRequestForPinnedYFlow.
@Test
public void shouldSendCorrectErrorMessageForManualRerouteRequestForPinnedYFlow() {
String flowId = "test flow";
when(yFlowRepository.findById(flowId)).thenReturn(Optional.of(YFlow.builder().yFlowId(flowId).sharedEndpoint(new SharedEndpoint(SWITCH_A.getSwitchId(), 10)).priority(2).pinned(true).build()));
FlowThrottlingData actual = getFlowThrottlingData(yFlow, CORRELATION_ID).build();
rerouteQueueService.processManualRequest(flowId, actual);
assertEquals(0, rerouteQueueService.getReroutes().size());
verify(carrier).emitFlowRerouteError(argThat(pinnedYFlowErrorData(flowId)));
}
use of org.openkilda.model.YFlow.SharedEndpoint in project open-kilda by telstra.
the class RerouteQueueServiceTest method setup.
@Before
public void setup() {
flow = Flow.builder().flowId(FLOW_ID).srcSwitch(SWITCH_A).destSwitch(SWITCH_B).priority(2).build();
when(flowRepository.findById(FLOW_ID)).thenReturn(Optional.of(flow));
yFlow = YFlow.builder().yFlowId(YFLOW_ID).sharedEndpoint(new SharedEndpoint(SWITCH_A.getSwitchId(), 10)).priority(2).build();
when(yFlowRepository.findById(YFLOW_ID)).thenReturn(Optional.of(yFlow));
RepositoryFactory repositoryFactory = mock(RepositoryFactory.class);
when(repositoryFactory.createFlowRepository()).thenReturn(flowRepository);
when(repositoryFactory.createYFlowRepository()).thenReturn(yFlowRepository);
PersistenceManager persistenceManager = mock(PersistenceManager.class);
when(persistenceManager.getRepositoryFactory()).thenReturn(repositoryFactory);
rerouteQueueService = new RerouteQueueService(carrier, persistenceManager, 0, 3);
}
use of org.openkilda.model.YFlow.SharedEndpoint in project open-kilda by telstra.
the class AbstractFlowTest method createTestYFlowForSubFlow.
protected void createTestYFlowForSubFlow(Flow subFlow) {
YFlow yFlow = YFlow.builder().yFlowId("test_y_flow").sharedEndpoint(new SharedEndpoint(subFlow.getSrcSwitchId(), subFlow.getSrcPort())).status(FlowStatus.UP).build();
yFlow.setSubFlows(singleton(YSubFlow.builder().sharedEndpointVlan(subFlow.getSrcVlan()).sharedEndpointInnerVlan(subFlow.getSrcInnerVlan()).endpointSwitchId(subFlow.getDestSwitchId()).endpointPort(subFlow.getDestPort()).endpointVlan(subFlow.getDestVlan()).endpointInnerVlan(subFlow.getDestInnerVlan()).flow(subFlow).yFlow(yFlow).build()));
YFlowRepository yFlowRepository = persistenceManager.getRepositoryFactory().createYFlowRepository();
yFlowRepository.add(yFlow);
}
Aggregations