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