use of org.openkilda.model.TransitVlan in project open-kilda by telstra.
the class PersistenceDummyEntityFactory method makeTransitVlan.
private TransitVlan makeTransitVlan(String flowId, PathId pathId) {
TransitVlan entity = TransitVlan.builder().flowId(flowId).pathId(pathId).vlan(idProvider.provideTransitVlanId()).build();
transitVlanRepository.add(entity);
return entity;
}
use of org.openkilda.model.TransitVlan 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.TransitVlan 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();
}
use of org.openkilda.model.TransitVlan in project open-kilda by telstra.
the class SpeakerFlowSegmentRequestBuilderTest method verifyVlanEncapsulation.
private void verifyVlanEncapsulation(Flow flow, FlowPath path, FlowTransitEncapsulation encapsulation) {
assertEquals(FlowEncapsulationType.TRANSIT_VLAN, encapsulation.getType());
TransitVlan transitVlan = vlanRepository.findByPathId(path.getPathId(), flow.getOppositePathId(path.getPathId()).orElse(null)).stream().findAny().orElseThrow(() -> new IllegalStateException("Vlan should be present"));
assertEquals(transitVlan.getVlan(), (int) encapsulation.getId());
}
use of org.openkilda.model.TransitVlan in project open-kilda by telstra.
the class PacketServiceTest method createFlow.
private void createFlow(String flowId, int srcVlan, int dstVlan, Integer transitVlan, boolean oneSwitchFlow, boolean onePort) {
if (transitVlan != null) {
transitVlanRepository.add(new TransitVlan(flowId, new PathId(PATH_ID), transitVlan));
}
Switch srcSwitch = switchRepository.findById(SWITCH_ID_1).get();
Switch dstSwitch = oneSwitchFlow ? srcSwitch : switchRepository.findById(SWITCH_ID_2).get();
Flow flow = Flow.builder().flowId(flowId).srcSwitch(srcSwitch).srcVlan(srcVlan).srcPort(PORT_NUMBER_1).destSwitch(dstSwitch).destVlan(dstVlan).destPort(onePort ? PORT_NUMBER_1 : PORT_NUMBER_2).build();
flowRepository.add(flow);
}
Aggregations