Search in sources :

Example 6 with SharedEndpoint

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

the class PersistenceDataAdapterTest method shouldProvideCorrectYFlows.

@Test
public void shouldProvideCorrectYFlows() {
    PathId pathId = new PathId("path1");
    Set<PathId> pathIds = Sets.newHashSet(pathId);
    YFlow yFlow = YFlow.builder().yFlowId("flow").sharedEndpoint(new SharedEndpoint(SWITCH_ID_1, 1)).build();
    Map<PathId, YFlow> yFlows = new HashMap<>();
    yFlows.put(pathId, yFlow);
    when(flowPathRepository.findYFlowsByPathIds(pathIds)).thenReturn(yFlows);
    adapter = PersistenceDataAdapter.builder().pathIds(pathIds).persistenceManager(persistenceManager).build();
    YFlow actual = adapter.getYFlow(pathId);
    assertEquals(yFlow, actual);
    adapter.getYFlow(new PathId("test"));
    verify(flowPathRepository).findYFlowsByPathIds(pathIds);
    verifyNoMoreInteractions(flowPathRepository);
}
Also used : PathId(org.openkilda.model.PathId) YFlow(org.openkilda.model.YFlow) HashMap(java.util.HashMap) SharedEndpoint(org.openkilda.model.YFlow.SharedEndpoint) Test(org.junit.Test)

Example 7 with SharedEndpoint

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

the class RerouteServiceTest method setup.

@Before
public void setup() throws Throwable {
    doAnswer(invocation -> {
        TransactionCallbackWithoutResult<?> arg = invocation.getArgument(0);
        arg.doInTransaction();
        return null;
    }).when(transactionManager).doInTransaction(Mockito.<TransactionCallbackWithoutResult<?>>any());
    doAnswer(invocation -> {
        TransactionCallback<?, ?> arg = invocation.getArgument(0);
        return arg.doInTransaction();
    }).when(transactionManager).doInTransaction(Mockito.<TransactionCallback<?, ?>>any());
    pinnedFlow = Flow.builder().flowId(FLOW_ID).srcSwitch(SWITCH_A).destSwitch(SWITCH_C).pinned(true).build();
    FlowPath pinnedFlowForwardPath = FlowPath.builder().pathId(new PathId("1")).srcSwitch(SWITCH_A).destSwitch(SWITCH_C).cookie(new FlowSegmentCookie(FlowPathDirection.FORWARD, 1)).build();
    List<PathSegment> pinnedFlowForwardSegments = new ArrayList<>();
    pinnedFlowForwardSegments.add(PathSegment.builder().pathId(pinnedFlowForwardPath.getPathId()).srcSwitch(SWITCH_A).srcPort(1).destSwitch(SWITCH_B).destPort(1).build());
    pinnedFlowForwardSegments.add(PathSegment.builder().pathId(pinnedFlowForwardPath.getPathId()).srcSwitch(SWITCH_B).srcPort(2).destSwitch(SWITCH_C).destPort(1).build());
    pinnedFlowForwardPath.setSegments(pinnedFlowForwardSegments);
    FlowPath pinnedFlowReversePath = FlowPath.builder().pathId(new PathId("2")).srcSwitch(SWITCH_C).destSwitch(SWITCH_A).cookie(new FlowSegmentCookie(FlowPathDirection.REVERSE, 2)).build();
    List<PathSegment> pinnedFlowReverseSegments = new ArrayList<>();
    pinnedFlowReverseSegments.add(PathSegment.builder().pathId(pinnedFlowReversePath.getPathId()).srcSwitch(SWITCH_C).srcPort(1).destSwitch(SWITCH_B).destPort(2).build());
    pinnedFlowReverseSegments.add(PathSegment.builder().pathId(pinnedFlowReversePath.getPathId()).srcSwitch(SWITCH_B).srcPort(1).destSwitch(SWITCH_A).destPort(1).build());
    pinnedFlowReversePath.setSegments(pinnedFlowReverseSegments);
    pinnedFlow.setForwardPath(pinnedFlowForwardPath);
    pinnedFlow.setReversePath(pinnedFlowReversePath);
    regularFlow = Flow.builder().flowId(FLOW_ID).srcSwitch(SWITCH_A).destSwitch(SWITCH_C).pinned(false).priority(2).build();
    FlowPath regularFlowForwardPath = FlowPath.builder().pathId(new PathId("3")).srcSwitch(SWITCH_A).destSwitch(SWITCH_C).cookie(new FlowSegmentCookie(FlowPathDirection.FORWARD, 3)).status(FlowPathStatus.ACTIVE).build();
    List<PathSegment> unpinnedFlowForwardSegments = new ArrayList<>();
    unpinnedFlowForwardSegments.add(PathSegment.builder().pathId(regularFlowForwardPath.getPathId()).srcSwitch(SWITCH_A).srcPort(1).destSwitch(SWITCH_B).destPort(1).build());
    unpinnedFlowForwardSegments.add(PathSegment.builder().pathId(regularFlowForwardPath.getPathId()).srcSwitch(SWITCH_B).srcPort(2).destSwitch(SWITCH_C).destPort(1).build());
    regularFlowForwardPath.setSegments(unpinnedFlowForwardSegments);
    FlowPath regularFlowReversePath = FlowPath.builder().pathId(new PathId("4")).srcSwitch(SWITCH_C).destSwitch(SWITCH_A).cookie(new FlowSegmentCookie(FlowPathDirection.REVERSE, 3)).status(FlowPathStatus.ACTIVE).build();
    List<PathSegment> unpinnedFlowReverseSegments = new ArrayList<>();
    unpinnedFlowReverseSegments.add(PathSegment.builder().pathId(regularFlowReversePath.getPathId()).srcSwitch(SWITCH_C).srcPort(1).destSwitch(SWITCH_B).destPort(2).build());
    unpinnedFlowReverseSegments.add(PathSegment.builder().pathId(regularFlowReversePath.getPathId()).srcSwitch(SWITCH_B).srcPort(1).destSwitch(SWITCH_A).destPort(1).build());
    regularFlowReversePath.setSegments(unpinnedFlowReverseSegments);
    regularFlow.setForwardPath(regularFlowForwardPath);
    regularFlow.setReversePath(regularFlowReversePath);
    oneSwitchFlow = Flow.builder().flowId(FLOW_ID).srcSwitch(SWITCH_A).destSwitch(SWITCH_A).build();
    FlowPath oneSwitchFlowForwardPath = FlowPath.builder().pathId(new PathId("5")).srcSwitch(SWITCH_A).destSwitch(SWITCH_A).cookie(new FlowSegmentCookie(FlowPathDirection.FORWARD, 4)).status(FlowPathStatus.ACTIVE).build();
    FlowPath oneSwitchFlowReversePath = FlowPath.builder().pathId(new PathId("6")).srcSwitch(SWITCH_A).destSwitch(SWITCH_A).cookie(new FlowSegmentCookie(FlowPathDirection.REVERSE, 4)).status(FlowPathStatus.ACTIVE).build();
    oneSwitchFlow.setForwardPath(oneSwitchFlowForwardPath);
    oneSwitchFlow.setReversePath(oneSwitchFlowReversePath);
    regularYFlow = YFlow.builder().yFlowId(YFLOW_ID).priority(2).sharedEndpoint(new SharedEndpoint(SWITCH_A.getSwitchId(), 10)).build();
    FlowPath regularYFlowForwardPath = FlowPath.builder().pathId(new PathId("3")).srcSwitch(SWITCH_A).destSwitch(SWITCH_C).cookie(new FlowSegmentCookie(FlowPathDirection.FORWARD, 3)).status(FlowPathStatus.ACTIVE).build();
    regularYFlowForwardPath.setSegments(unpinnedFlowForwardSegments);
    FlowPath regularYFlowReversePath = FlowPath.builder().pathId(new PathId("4")).srcSwitch(SWITCH_C).destSwitch(SWITCH_A).cookie(new FlowSegmentCookie(FlowPathDirection.REVERSE, 3)).status(FlowPathStatus.ACTIVE).build();
    regularYFlowReversePath.setSegments(unpinnedFlowReverseSegments);
    subFlow = Flow.builder().flowId(SUB_YFLOW_ID).srcSwitch(SWITCH_A).destSwitch(SWITCH_C).pinned(false).priority(2).yFlowId(YFLOW_ID).yFlow(regularYFlow).build();
    subFlow.setForwardPath(regularYFlowForwardPath);
    subFlow.setReversePath(regularYFlowReversePath);
    Set<YSubFlow> subFlows = Collections.singleton(YSubFlow.builder().yFlow(regularYFlow).flow(subFlow).build());
    regularYFlow.setSubFlows(subFlows);
}
Also used : PathId(org.openkilda.model.PathId) FlowSegmentCookie(org.openkilda.model.cookie.FlowSegmentCookie) ArrayList(java.util.ArrayList) SharedEndpoint(org.openkilda.model.YFlow.SharedEndpoint) PathSegment(org.openkilda.model.PathSegment) FlowPath(org.openkilda.model.FlowPath) YSubFlow(org.openkilda.model.YSubFlow) Before(org.junit.Before)

Example 8 with SharedEndpoint

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

Aggregations

SharedEndpoint (org.openkilda.model.YFlow.SharedEndpoint)8 YFlow (org.openkilda.model.YFlow)5 YSubFlow (org.openkilda.model.YSubFlow)4 Flow (org.openkilda.model.Flow)3 YFlowRepository (org.openkilda.persistence.repositories.YFlowRepository)3 Before (org.junit.Before)2 Test (org.junit.Test)2 PathId (org.openkilda.model.PathId)2 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 FlowMeter (org.openkilda.model.FlowMeter)1 FlowPath (org.openkilda.model.FlowPath)1 PathSegment (org.openkilda.model.PathSegment)1 SwitchId (org.openkilda.model.SwitchId)1 FlowSegmentCookie (org.openkilda.model.cookie.FlowSegmentCookie)1 PersistenceManager (org.openkilda.persistence.PersistenceManager)1 RepositoryFactory (org.openkilda.persistence.repositories.RepositoryFactory)1 FlowThrottlingData (org.openkilda.wfm.topology.reroute.model.FlowThrottlingData)1