use of org.openkilda.floodlight.model.FlowSegmentMetadata in project open-kilda by telstra.
the class TransitFlowSegmentInstallCommandTest method happyPathMultiTable.
@Test
public void happyPathMultiTable() throws Exception {
replayAll();
TransitFlowSegmentInstallCommand command = makeCommand(encapsulationVxLan, new FlowSegmentMetadata("transit-segment-install-multitable", new Cookie(5), true));
verifySuccessCompletion(command.execute(commandProcessor));
verifyWriteCount(1);
OFFlowAdd expected = of.buildFlowAdd().setTableId(TableId.of(SwitchManager.TRANSIT_TABLE_ID)).setPriority(TransitFlowSegmentInstallCommand.FLOW_PRIORITY).setCookie(U64.of(command.getCookie().getValue())).setMatch(OfAdapter.INSTANCE.matchVxLanVni(of, of.buildMatch(), command.getEncapsulation().getId()).setExact(MatchField.IN_PORT, OFPort.of(command.getIngressIslPort())).setExact(MatchField.ETH_TYPE, EthType.IPv4).setExact(MatchField.IP_PROTO, IpProtocol.UDP).setExact(MatchField.UDP_DST, TransportPort.of(4789)).build()).setInstructions(ImmutableList.of(of.instructions().applyActions(ImmutableList.of(of.actions().buildOutput().setPort(OFPort.of(command.getEgressIslPort())).build())))).build();
verifyOfMessageEquals(expected, getWriteRecord(0).getRequest());
}
use of org.openkilda.floodlight.model.FlowSegmentMetadata in project open-kilda by telstra.
the class TransitFlowSegmentRemoveCommandTest method makeCommand.
@Override
protected TransitFlowSegmentRemoveCommand makeCommand(FlowTransitEncapsulation encapsulation) {
MessageContext messageContext = new MessageContext();
UUID commandId = UUID.randomUUID();
FlowSegmentMetadata metadata = new FlowSegmentMetadata("transit-flow-segment-remove-flow-id", new Cookie(6), false);
int ingressIslPort = 3;
int egressIslPort = 5;
return new TransitFlowSegmentRemoveCommand(messageContext, mapSwitchId(dpIdNext), commandId, metadata, ingressIslPort, encapsulation, egressIslPort, null);
}
use of org.openkilda.floodlight.model.FlowSegmentMetadata in project open-kilda by telstra.
the class IngressServer42FlowInstallCommandTest method createCommand.
private IngressServer42FlowInstallCommand createCommand(int outerVlan, int innerVlan, FlowTransitEncapsulation encapsulation, boolean multiTable) throws Exception {
FlowSegmentMetadata metadata = new FlowSegmentMetadata(FLOW_ID, COOKIE, multiTable);
IngressServer42FlowInstallCommand command = new IngressServer42FlowInstallCommand(new MessageContext(), UUID.randomUUID(), metadata, INGRESS_SWITCH_ID, CUSTOMER_PORT, outerVlan, innerVlan, EGRESS_SWITCH_ID, ISL_PORT, encapsulation, SERVER_42_PORT, SERVER_42_MAC_ADDRESS);
FloodlightModuleContext context = new FloodlightModuleContext();
IOFSwitchService switchServiceMock = mock(IOFSwitchService.class);
expect(switchServiceMock.getActiveSwitch(anyObject())).andReturn(getOfSwitch()).anyTimes();
context.addService(IOFSwitchService.class, switchServiceMock);
FeatureDetectorService featureDetectorServiceMock = mock(FeatureDetectorService.class);
expect(featureDetectorServiceMock.detectSwitch(anyObject())).andReturn(FEATURES).anyTimes();
context.addService(FeatureDetectorService.class, featureDetectorServiceMock);
Properties properties = new Properties();
properties.setProperty(SERVER_42_UPD_PORT_OFFSET_PROPERTY, Integer.toString(SERVER_42_UPD_PORT_OFFSET));
PropertiesBasedConfigurationProvider provider = new PropertiesBasedConfigurationProvider(properties);
KildaCore kildaCoreMock = mock(KildaCore.class);
expect(kildaCoreMock.getConfig()).andReturn(provider.getConfiguration(KildaCoreConfig.class)).anyTimes();
context.addService(KildaCore.class, kildaCoreMock);
replay(switchServiceMock, featureDetectorServiceMock, kildaCoreMock);
command.setup(context);
return command;
}
use of org.openkilda.floodlight.model.FlowSegmentMetadata in project open-kilda by telstra.
the class EgressFlowSegmentCommandJsonTest method makeRequest.
@Override
protected EgressFlowSegmentRequest makeRequest() {
SwitchId swId = new SwitchId(1);
EgressFlowSegmentRequestFactory factory = new EgressFlowSegmentRequestFactory(new MessageContext(), new FlowSegmentMetadata("egress-flow-segment-install-request", new Cookie(2), false), new FlowEndpoint(swId, 3, 4), new FlowEndpoint(new SwitchId(swId.toLong() + 1), 6, 7), 9, new FlowTransitEncapsulation(10, FlowEncapsulationType.TRANSIT_VLAN), MirrorConfig.builder().build());
return makeRequest(factory);
}
use of org.openkilda.floodlight.model.FlowSegmentMetadata in project open-kilda by telstra.
the class IngressFlowLoopSegmentInstallCommandTest method createCommand.
private IngressFlowLoopSegmentInstallCommand createCommand(int outerVlan, int innerVlan, boolean multiTable) throws Exception {
FlowSegmentMetadata metadata = new FlowSegmentMetadata(FLOW_ID, COOKIE, multiTable);
FlowEndpoint endpoint = FlowEndpoint.builder().switchId(SWITCH_ID_1).portNumber(PORT_1).outerVlanId(outerVlan).innerVlanId(innerVlan).build();
IngressFlowLoopSegmentInstallCommand command = new IngressFlowLoopSegmentInstallCommand(new MessageContext(), UUID.randomUUID(), metadata, endpoint);
FloodlightModuleContext context = new FloodlightModuleContext();
IOFSwitchService switchServiceMock = mock(IOFSwitchService.class);
expect(switchServiceMock.getActiveSwitch(anyObject())).andReturn(getOfSwitch()).anyTimes();
context.addService(IOFSwitchService.class, switchServiceMock);
FeatureDetectorService featureDetectorServiceMock = mock(FeatureDetectorService.class);
expect(featureDetectorServiceMock.detectSwitch(anyObject())).andReturn(FEATURES).anyTimes();
context.addService(FeatureDetectorService.class, featureDetectorServiceMock);
PropertiesBasedConfigurationProvider provider = new PropertiesBasedConfigurationProvider(new Properties());
KildaCore kildaCoreMock = mock(KildaCore.class);
expect(kildaCoreMock.getConfig()).andReturn(provider.getConfiguration(KildaCoreConfig.class)).anyTimes();
context.addService(KildaCore.class, kildaCoreMock);
replay(switchServiceMock, featureDetectorServiceMock, kildaCoreMock);
command.setup(context);
return command;
}
Aggregations