Search in sources :

Example 6 with TransitVlan

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;
}
Also used : TransitVlan(org.openkilda.model.TransitVlan)

Example 7 with TransitVlan

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);
}
Also used : PathId(org.openkilda.model.PathId) TransitVlan(org.openkilda.model.TransitVlan) FlowTransitEncapsulation(org.openkilda.model.FlowTransitEncapsulation) Test(org.junit.Test)

Example 8 with TransitVlan

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();
}
Also used : PathId(org.openkilda.model.PathId) TransitVlan(org.openkilda.model.TransitVlan) MeterId(org.openkilda.model.MeterId)

Example 9 with TransitVlan

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());
}
Also used : TransitVlan(org.openkilda.model.TransitVlan)

Example 10 with TransitVlan

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);
}
Also used : PathId(org.openkilda.model.PathId) Switch(org.openkilda.model.Switch) TransitVlan(org.openkilda.model.TransitVlan) Flow(org.openkilda.model.Flow)

Aggregations

TransitVlan (org.openkilda.model.TransitVlan)15 Test (org.junit.Test)7 PathId (org.openkilda.model.PathId)6 InMemoryGraphBasedTest (org.openkilda.persistence.inmemory.InMemoryGraphBasedTest)5 Flow (org.openkilda.model.Flow)3 FlowTransitEncapsulation (org.openkilda.model.FlowTransitEncapsulation)1 MeterId (org.openkilda.model.MeterId)1 Switch (org.openkilda.model.Switch)1