Search in sources :

Example 66 with PathId

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

the class PersistenceDataAdapterTest method shouldProvideCorrectVlanEncapsulation.

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

Example 67 with PathId

use of org.openkilda.model.PathId 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 68 with PathId

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

the class PersistenceDataAdapterTest method shouldProvideCorrectFlows.

@Test
public void shouldProvideCorrectFlows() {
    PathId pathId = new PathId("path1");
    Set<PathId> pathIds = Sets.newHashSet(pathId);
    Flow flow = Flow.builder().flowId("flow").srcSwitch(buildSwitch(SWITCH_ID_1, Collections.emptySet())).destSwitch(buildSwitch(SWITCH_ID_2, Collections.emptySet())).build();
    flow.setForwardPathId(pathId);
    Map<PathId, Flow> flows = new HashMap<>();
    flows.put(pathId, flow);
    when(flowPathRepository.findFlowsByPathIds(pathIds)).thenReturn(flows);
    adapter = PersistenceDataAdapter.builder().pathIds(pathIds).persistenceManager(persistenceManager).build();
    Flow actual = adapter.getFlow(pathId);
    assertEquals(flow, actual);
    adapter.getFlow(new PathId("test"));
    verify(flowPathRepository).findFlowsByPathIds(pathIds);
    verifyNoMoreInteractions(flowPathRepository);
}
Also used : PathId(org.openkilda.model.PathId) HashMap(java.util.HashMap) Flow(org.openkilda.model.Flow) YFlow(org.openkilda.model.YFlow) Test(org.junit.Test)

Example 69 with PathId

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

the class VxlanPoolTest method vxlanPoolFullTest.

@Test(expected = ResourceNotAvailableException.class)
public void vxlanPoolFullTest() {
    transactionManager.doInTransaction(() -> {
        for (int i = MIN_VXLAN; i <= MAX_VXLAN + 1; i++) {
            Flow flow = Flow.builder().flowId(format("flow_%d", i)).srcSwitch(SWITCH_A).destSwitch(SWITCH_B).build();
            assertTrue(vxlanPool.allocate(flow, new PathId(format("path_%d", i)), new PathId(format("op_path_%d", i))).getVxlan().getVni() > 0);
        }
    });
}
Also used : PathId(org.openkilda.model.PathId) Flow(org.openkilda.model.Flow) InMemoryGraphBasedTest(org.openkilda.persistence.inmemory.InMemoryGraphBasedTest) Test(org.junit.Test)

Example 70 with PathId

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

the class SpeakerFlowSegmentRequestBuilderTest method buildFlowPath.

private FlowPath buildFlowPath(Flow flow, Switch srcSwitch, Switch dstSwitch, FlowSegmentCookie cookie) {
    PathId forwardPathId = new PathId(UUID.randomUUID().toString());
    TransitVlan forwardVlan = TransitVlan.builder().flowId(flow.getFlowId()).pathId(forwardPathId).vlan(vlanFactory.next()).build();
    vlanRepository.add(forwardVlan);
    return FlowPath.builder().bandwidth(flow.getBandwidth()).cookie(cookie).meterId(flow.getBandwidth() != 0 ? new MeterId(meterFactory.next()) : null).srcSwitch(srcSwitch).destSwitch(dstSwitch).pathId(forwardPathId).build();
}
Also used : PathId(org.openkilda.model.PathId) TransitVlan(org.openkilda.model.TransitVlan) MeterId(org.openkilda.model.MeterId)

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