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);
}
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);
}
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);
}
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);
}
});
}
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();
}
Aggregations