Search in sources :

Example 46 with PathId

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

the class PersistenceDataAdapterTest method shouldProvideCorrectVxlanEncapsulation.

@Test
public void shouldProvideCorrectVxlanEncapsulation() {
    PathId pathId = new PathId("path1");
    Set<PathId> pathIds = Sets.newHashSet(pathId);
    Vxlan vxlan = Vxlan.builder().flowId("flowId").pathId(pathId).vni(8).build();
    when(vxlanRepository.findByPathId(pathId, null)).thenReturn(Collections.singletonList(vxlan));
    adapter = PersistenceDataAdapter.builder().pathIds(pathIds).persistenceManager(persistenceManager).build();
    FlowTransitEncapsulation actual = adapter.getTransitEncapsulation(pathId, null);
    assertEquals(FlowEncapsulationType.VXLAN, actual.getType());
    assertEquals(vxlan.getVni(), actual.getId().intValue());
    adapter.getTransitEncapsulation(pathId, null);
    verify(transitVlanRepository).findByPathId(pathId, null);
    verify(vxlanRepository).findByPathId(pathId, null);
    verifyNoMoreInteractions(transitVlanRepository);
    verifyNoMoreInteractions(vxlanRepository);
}
Also used : PathId(org.openkilda.model.PathId) Vxlan(org.openkilda.model.Vxlan) FlowTransitEncapsulation(org.openkilda.model.FlowTransitEncapsulation) Test(org.junit.Test)

Example 47 with PathId

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

the class VxlanPoolTest method vxlanIdPool.

@Test
public void vxlanIdPool() {
    transactionManager.doInTransaction(() -> {
        Set<Integer> vxlans = new HashSet<>();
        for (int i = MIN_VXLAN; i <= MAX_VXLAN; i++) {
            Flow flow = Flow.builder().flowId(format("flow_%d", i)).srcSwitch(SWITCH_A).destSwitch(SWITCH_B).build();
            vxlans.add(vxlanPool.allocate(flow, new PathId(format("path_%d", i)), new PathId(format("opposite_dummy_%d", i))).getVxlan().getVni());
        }
        assertEquals(MAX_VXLAN - MIN_VXLAN + 1, vxlans.size());
        vxlans.forEach(vni -> assertTrue(vni >= MIN_VXLAN && vni <= MAX_VXLAN));
    });
}
Also used : PathId(org.openkilda.model.PathId) HashSet(java.util.HashSet) Flow(org.openkilda.model.Flow) InMemoryGraphBasedTest(org.openkilda.persistence.inmemory.InMemoryGraphBasedTest) Test(org.junit.Test)

Example 48 with PathId

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

the class FlowMapperTest method buildFlow.

private Flow buildFlow() {
    Flow flow = Flow.builder().flowId("test_flow").srcSwitch(Switch.builder().switchId(SRC_SWITCH_ID).build()).destSwitch(Switch.builder().switchId(DST_SWITCH_ID).build()).allocateProtectedPath(true).build();
    FlowPath forwardFlowPath = FlowPath.builder().pathId(new PathId("forward_flow_path")).srcSwitch(Switch.builder().switchId(SRC_SWITCH_ID).build()).destSwitch(Switch.builder().switchId(DST_SWITCH_ID).build()).cookie(new FlowSegmentCookie(FlowPathDirection.FORWARD, 1)).status(FlowPathStatus.ACTIVE).build();
    flow.setForwardPath(forwardFlowPath);
    FlowPath reverseFlowPath = FlowPath.builder().pathId(new PathId("reverse_flow_path")).srcSwitch(Switch.builder().switchId(DST_SWITCH_ID).build()).destSwitch(Switch.builder().switchId(SRC_SWITCH_ID).build()).cookie(new FlowSegmentCookie(FlowPathDirection.REVERSE, 1)).status(FlowPathStatus.ACTIVE).build();
    flow.setReversePath(reverseFlowPath);
    FlowPath forwardProtectedFlowPath = FlowPath.builder().pathId(new PathId("forward_protected_flow_path")).srcSwitch(Switch.builder().switchId(SRC_SWITCH_ID).build()).destSwitch(Switch.builder().switchId(DST_SWITCH_ID).build()).cookie(new FlowSegmentCookie(FlowPathDirection.FORWARD, 2)).status(FlowPathStatus.INACTIVE).build();
    flow.setProtectedForwardPath(forwardProtectedFlowPath);
    FlowPath reverseProtectedFlowPath = FlowPath.builder().pathId(new PathId("reverse_protected_flow_path")).srcSwitch(Switch.builder().switchId(DST_SWITCH_ID).build()).destSwitch(Switch.builder().switchId(SRC_SWITCH_ID).build()).cookie(new FlowSegmentCookie(FlowPathDirection.REVERSE, 2)).status(FlowPathStatus.INACTIVE).build();
    flow.setProtectedReversePath(reverseProtectedFlowPath);
    return flow;
}
Also used : PathId(org.openkilda.model.PathId) FlowSegmentCookie(org.openkilda.model.cookie.FlowSegmentCookie) FlowPath(org.openkilda.model.FlowPath) Flow(org.openkilda.model.Flow)

Example 49 with PathId

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

the class TestFlowBuilder method buildFlowPath.

private FlowPath buildFlowPath(Flow flow, Switch srcSwitch, Switch destSwitch, List<Endpoint> transitEndpoints, FlowSegmentCookie cookie, MeterId meterId) {
    PathId pathId = new PathId(UUID.randomUUID().toString());
    List<PathSegment> pathSegments = new ArrayList<>();
    if (!srcSwitch.getSwitchId().equals(destSwitch.getSwitchId())) {
        for (int i = 0; i < transitEndpoints.size() - 1; i += 2) {
            Endpoint first = transitEndpoints.get(i);
            Endpoint second = transitEndpoints.get(i + 1);
            pathSegments.add(PathSegment.builder().pathId(pathId).srcSwitch(first.sw).srcPort(first.port).destSwitch(second.sw).destPort(second.port).bandwidth(flow.getBandwidth()).ignoreBandwidth(flow.isIgnoreBandwidth()).build());
        }
    }
    return FlowPath.builder().pathId(pathId).srcSwitch(srcSwitch).destSwitch(destSwitch).cookie(cookie).meterId(meterId).bandwidth(flow.getBandwidth()).ignoreBandwidth(flow.isIgnoreBandwidth()).segments(pathSegments).build();
}
Also used : PathId(org.openkilda.model.PathId) ArrayList(java.util.ArrayList) PathSegment(org.openkilda.model.PathSegment)

Example 50 with PathId

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

the class TransitVlanPoolTest method vlanPoolFullTest.

@Test(expected = ResourceNotAvailableException.class)
public void vlanPoolFullTest() {
    transactionManager.doInTransaction(() -> {
        for (int i = MIN_TRANSIT_VLAN; i <= MAX_TRANSIT_VLAN + 1; i++) {
            Flow flow = Flow.builder().flowId(format("flow_%d", i)).srcSwitch(SWITCH_A).destSwitch(SWITCH_B).build();
            assertTrue(transitVlanPool.allocate(flow, new PathId(format("path_%d", i)), new PathId(format("opposite_dummy_%d", i))).getTransitVlan().getVlan() > 0);
        }
    });
}
Also used : PathId(org.openkilda.model.PathId) Flow(org.openkilda.model.Flow) InMemoryGraphBasedTest(org.openkilda.persistence.inmemory.InMemoryGraphBasedTest) Test(org.junit.Test)

Aggregations

PathId (org.openkilda.model.PathId)124 Flow (org.openkilda.model.Flow)65 FlowPath (org.openkilda.model.FlowPath)65 Test (org.junit.Test)44 Switch (org.openkilda.model.Switch)29 SwitchId (org.openkilda.model.SwitchId)28 FlowSegmentCookie (org.openkilda.model.cookie.FlowSegmentCookie)27 PathSegment (org.openkilda.model.PathSegment)26 InMemoryGraphBasedTest (org.openkilda.persistence.inmemory.InMemoryGraphBasedTest)21 MeterId (org.openkilda.model.MeterId)19 ArrayList (java.util.ArrayList)18 List (java.util.List)13 Slf4j (lombok.extern.slf4j.Slf4j)11 GetPathsResult (org.openkilda.pce.GetPathsResult)11 FlowMirrorPoints (org.openkilda.model.FlowMirrorPoints)10 Path (org.openkilda.pce.Path)10 Collection (java.util.Collection)9 RecoverableException (org.openkilda.pce.exception.RecoverableException)9 String.format (java.lang.String.format)8 HashMap (java.util.HashMap)8