Search in sources :

Example 6 with IOFSwitch

use of net.floodlightcontroller.core.IOFSwitch in project open-kilda by telstra.

the class ReplaceInstallFlowTest method prepareMocks.

/**
 * Prepares test mocks for run.
 *
 * @param flowAddCapture  Capture for FlowAdd command
 * @param meterAddCapture Capture for MeterMod<Add> command
 */
private void prepareMocks(Capture<OFFlowAdd> flowAddCapture, Capture<OFMeterMod> meterAddCapture, boolean needCheckReverseFlow, boolean needCheckReverseMeter) {
    IOFSwitch iofSwitch = createMock(IOFSwitch.class);
    expect(ofSwitchService.getSwitch(anyObject(DatapathId.class))).andStubReturn(iofSwitch);
    expect(iofSwitch.getOFFactory()).andStubReturn(ofFactory);
    expect(iofSwitch.getSwitchDescription()).andStubReturn(switchDescription);
    if (meterAddCapture != null) {
        expect(iofSwitch.write(capture(meterAddCapture))).andReturn(true);
        if (flowAddCapture != null) {
            expect(iofSwitch.write(capture(flowAddCapture))).andReturn(true);
        }
        if (needCheckReverseMeter) {
            expect(iofSwitch.write(capture(meterAddCapture))).andReturn(true);
        }
        if (needCheckReverseFlow) {
            expect(iofSwitch.write(capture(flowAddCapture))).andReturn(true);
        }
    } else if (flowAddCapture != null) {
        expect(iofSwitch.write(capture(flowAddCapture))).andReturn(true).times(needCheckReverseFlow ? 2 : 1);
    }
    replay(ofSwitchService);
    replay(iofSwitch);
}
Also used : IOFSwitch(net.floodlightcontroller.core.IOFSwitch) DatapathId(org.projectfloodlight.openflow.types.DatapathId)

Example 7 with IOFSwitch

use of net.floodlightcontroller.core.IOFSwitch in project open-kilda by telstra.

the class PathVerificationPacketSignTest method setUp.

@Before
public void setUp() throws Exception {
    super.setUp();
    OFPacketOut packetOut = pvs.generateVerificationPacket(sw1, OFPort.of(1));
    ofPacketIn = EasyMock.createMock(OFPacketIn.class);
    context = new FloodlightContext();
    expect(ofPacketIn.getType()).andReturn(OFType.PACKET_IN).anyTimes();
    expect(ofPacketIn.getXid()).andReturn(0L).anyTimes();
    expect(ofPacketIn.getVersion()).andReturn(packetOut.getVersion()).anyTimes();
    Match match = EasyMock.createMock(Match.class);
    expect(match.get(MatchField.IN_PORT)).andReturn(OFPort.of(1)).anyTimes();
    replay(match);
    expect(ofPacketIn.getMatch()).andReturn(match).anyTimes();
    replay(ofPacketIn);
    IPacket expected = new Ethernet().deserialize(packetOut.getData(), 0, packetOut.getData().length);
    context.getStorage().put(IFloodlightProviderService.CONTEXT_PI_PAYLOAD, expected);
    HashMap<DatapathId, IOFSwitch> switches = new HashMap<>();
    switches.put(sw1.getId(), sw1);
    switches.put(sw2.getId(), sw2);
    mockSwitchManager.setSwitches(switches);
    reset(producer);
    pvs.setKafkaProducer(producer);
}
Also used : IPacket(net.floodlightcontroller.packet.IPacket) IOFSwitch(net.floodlightcontroller.core.IOFSwitch) HashMap(java.util.HashMap) Ethernet(net.floodlightcontroller.packet.Ethernet) OFPacketIn(org.projectfloodlight.openflow.protocol.OFPacketIn) DatapathId(org.projectfloodlight.openflow.types.DatapathId) OFPacketOut(org.projectfloodlight.openflow.protocol.OFPacketOut) FloodlightContext(net.floodlightcontroller.core.FloodlightContext) Match(org.projectfloodlight.openflow.protocol.match.Match) Before(org.junit.Before)

Example 8 with IOFSwitch

use of net.floodlightcontroller.core.IOFSwitch in project open-kilda by telstra.

the class FloodlightTestCase method buildMockIOFSwitch.

public IOFSwitch buildMockIOFSwitch(Long id, OFPortDesc portDesc, OFFactory factory, OFDescStatsReply swDesc, InetSocketAddress inetAddr) {
    IOFSwitch sw = EasyMock.createMock(IOFSwitch.class);
    expect(sw.getId()).andReturn(DatapathId.of(id)).anyTimes();
    expect(sw.getPort(OFPort.of(1))).andReturn(portDesc).anyTimes();
    expect(sw.getOFFactory()).andReturn(factory).anyTimes();
    expect(sw.getBuffers()).andReturn(swFeatures.getNBuffers()).anyTimes();
    expect(sw.hasAttribute(IOFSwitch.PROP_SUPPORTS_OFPP_TABLE)).andReturn(true).anyTimes();
    expect(sw.getSwitchDescription()).andReturn(new SwitchDescription(swDesc)).anyTimes();
    expect(sw.isActive()).andReturn(true).anyTimes();
    expect(sw.getLatency()).andReturn(U64.of(10L)).anyTimes();
    expect(sw.getInetAddress()).andReturn(inetAddr).anyTimes();
    return sw;
}
Also used : IOFSwitch(net.floodlightcontroller.core.IOFSwitch) SwitchDescription(net.floodlightcontroller.core.SwitchDescription)

Aggregations

IOFSwitch (net.floodlightcontroller.core.IOFSwitch)8 DatapathId (org.projectfloodlight.openflow.types.DatapathId)4 InfoMessage (org.openkilda.messaging.info.InfoMessage)3 JWTVerificationException (com.auth0.jwt.exceptions.JWTVerificationException)2 JsonProcessingException (com.fasterxml.jackson.core.JsonProcessingException)2 UnsupportedEncodingException (java.io.UnsupportedEncodingException)2 FloodlightModuleException (net.floodlightcontroller.core.module.FloodlightModuleException)2 Ethernet (net.floodlightcontroller.packet.Ethernet)2 CommandMessage (org.openkilda.messaging.command.CommandMessage)2 NetworkCommandData (org.openkilda.messaging.command.discovery.NetworkCommandData)2 SwitchInfoData (org.openkilda.messaging.info.event.SwitchInfoData)2 OFPacketOut (org.projectfloodlight.openflow.protocol.OFPacketOut)2 DecodedJWT (com.auth0.jwt.interfaces.DecodedJWT)1 ByteBuffer (java.nio.ByteBuffer)1 java.util (java.util)1 Arrays.asList (java.util.Arrays.asList)1 HashMap (java.util.HashMap)1 Collectors (java.util.stream.Collectors)1 FloodlightContext (net.floodlightcontroller.core.FloodlightContext)1 SwitchDescription (net.floodlightcontroller.core.SwitchDescription)1