Search in sources :

Example 1 with PathVerificationService

use of org.openkilda.floodlight.pathverification.PathVerificationService in project open-kilda by telstra.

the class SwitchManagerTest method setUp.

@Before
public void setUp() throws FloodlightModuleException {
    JdkProxyStaticConfigurationFactory factory = new JdkProxyStaticConfigurationFactory();
    config = factory.createConfiguration(SwitchManagerConfig.class, new MapConfigurationSource(emptyMap()));
    ofSwitchService = createMock(IOFSwitchService.class);
    restApiService = createMock(IRestApiService.class);
    featureDetectorService = createMock(FeatureDetectorService.class);
    switchFlowFactory = new SwitchFlowFactory();
    iofSwitch = createMock(IOFSwitch.class);
    switchDescription = createMock(SwitchDescription.class);
    dpid = DatapathId.of(SWITCH_ID.toLong());
    PathVerificationServiceConfig config = EasyMock.createMock(PathVerificationServiceConfig.class);
    expect(config.getVerificationBcastPacketDst()).andReturn("00:26:E1:FF:FF:FF").anyTimes();
    replay(config);
    PathVerificationService pathVerificationService = EasyMock.createMock(PathVerificationService.class);
    expect(pathVerificationService.getConfig()).andReturn(config).anyTimes();
    replay(pathVerificationService);
    KildaCore kildaCore = EasyMock.createMock(KildaCore.class);
    FloodlightModuleConfigurationProvider provider = FloodlightModuleConfigurationProvider.of(context, KildaCore.class);
    KildaCoreConfig coreConfig = provider.getConfiguration(KildaCoreConfig.class);
    expect(kildaCore.getConfig()).andStubReturn(coreConfig);
    EasyMock.replay(kildaCore);
    context.addService(KildaCore.class, kildaCore);
    SwitchTrackingService switchTracking = createMock(SwitchTrackingService.class);
    switchTracking.setup(context);
    replay(switchTracking);
    context.addService(SwitchTrackingService.class, switchTracking);
    IFloodlightProviderService floodlightProvider = createMock(IFloodlightProviderService.class);
    floodlightProvider.addOFMessageListener(EasyMock.eq(OFType.ERROR), EasyMock.anyObject(SwitchManager.class));
    replay(floodlightProvider);
    context.addService(IFloodlightProviderService.class, floodlightProvider);
    context.addService(IRestApiService.class, restApiService);
    context.addService(IOFSwitchService.class, ofSwitchService);
    context.addService(FeatureDetectorService.class, featureDetectorService);
    context.addService(SwitchFlowFactory.class, switchFlowFactory);
    context.addService(IPathVerificationService.class, pathVerificationService);
    switchManager = new SwitchManager();
    context.addService(ISwitchManager.class, switchManager);
    switchManager.init(context);
    switchManager.startUp(context);
}
Also used : IOFSwitch(net.floodlightcontroller.core.IOFSwitch) PathVerificationServiceConfig(org.openkilda.floodlight.pathverification.PathVerificationServiceConfig) IOFSwitchService(net.floodlightcontroller.core.internal.IOFSwitchService) FeatureDetectorService(org.openkilda.floodlight.service.FeatureDetectorService) IFloodlightProviderService(net.floodlightcontroller.core.IFloodlightProviderService) KildaCore(org.openkilda.floodlight.KildaCore) FloodlightModuleConfigurationProvider(org.openkilda.floodlight.config.provider.FloodlightModuleConfigurationProvider) IRestApiService(net.floodlightcontroller.restserver.IRestApiService) PathVerificationService(org.openkilda.floodlight.pathverification.PathVerificationService) IPathVerificationService(org.openkilda.floodlight.pathverification.IPathVerificationService) JdkProxyStaticConfigurationFactory(com.sabre.oss.conf4j.factory.jdkproxy.JdkProxyStaticConfigurationFactory) MapConfigurationSource(com.sabre.oss.conf4j.source.MapConfigurationSource) KildaCoreConfig(org.openkilda.floodlight.KildaCoreConfig) SwitchDescription(net.floodlightcontroller.core.SwitchDescription) SwitchFlowFactory(org.openkilda.floodlight.switchmanager.factory.SwitchFlowFactory) Before(org.junit.Before)

Example 2 with PathVerificationService

use of org.openkilda.floodlight.pathverification.PathVerificationService in project open-kilda by telstra.

the class PingRequestCommandWriteOkTest method switchIntoTestMode.

private void switchIntoTestMode() throws Exception {
    replayAll();
    moduleContext.addConfigParam(new PathVerificationService(), "hmac256-secret", "secret");
    realPingService.setup(moduleContext);
}
Also used : PathVerificationService(org.openkilda.floodlight.pathverification.PathVerificationService)

Example 3 with PathVerificationService

use of org.openkilda.floodlight.pathverification.PathVerificationService in project open-kilda by telstra.

the class ReplaceInstallFlowTest method setUp.

@Before
public void setUp() throws FloodlightModuleException {
    final SwitchManager switchManager = new SwitchManager();
    final PathVerificationService pathVerificationService = new PathVerificationService();
    ofSwitchService = createMock(IOFSwitchService.class);
    producer = createMock(KafkaMessageProducer.class);
    context.addService(IOFSwitchService.class, ofSwitchService);
    context.addService(IRestApiService.class, null);
    context.addService(SwitchEventCollector.class, null);
    context.addService(KafkaMessageProducer.class, producer);
    context.addService(IPathVerificationService.class, pathVerificationService);
    context.addService(ISwitchManager.class, switchManager);
    switchManager.init(context);
    collector = new KafkaMessageCollector();
    context.addConfigParam(collector, "topic", "");
    context.addConfigParam(collector, "bootstrap-servers", "");
    collector.init(context);
    initScheme();
}
Also used : IPathVerificationService(org.openkilda.floodlight.pathverification.IPathVerificationService) PathVerificationService(org.openkilda.floodlight.pathverification.PathVerificationService) IOFSwitchService(net.floodlightcontroller.core.internal.IOFSwitchService) SwitchManager(org.openkilda.floodlight.switchmanager.SwitchManager) ISwitchManager(org.openkilda.floodlight.switchmanager.ISwitchManager) Before(org.junit.Before)

Example 4 with PathVerificationService

use of org.openkilda.floodlight.pathverification.PathVerificationService in project open-kilda by telstra.

the class SwitchManagerOF12Test method setUp.

@Before
public void setUp() throws FloodlightModuleException {
    EasyMock.reset(switchService);
    PathVerificationServiceConfig config = EasyMock.createMock(PathVerificationServiceConfig.class);
    expect(config.getVerificationBcastPacketDst()).andReturn("00:26:E1:FF:FF:FF").anyTimes();
    replay(config);
    PathVerificationService pathVerificationService = EasyMock.createMock(PathVerificationService.class);
    expect(pathVerificationService.getConfig()).andReturn(config).anyTimes();
    SwitchFlowFactory switchFlowFactory = EasyMock.createMock(SwitchFlowFactory.class);
    expect(switchFlowFactory.getDropLoopFlowGenerator()).andReturn(DropLoopFlowGenerator.builder().build()).anyTimes();
    replay(pathVerificationService, switchFlowFactory);
    context.addService(IPathVerificationService.class, pathVerificationService);
    context.addService(SwitchFlowFactory.class, switchFlowFactory);
    switchManager = new SwitchManager();
    switchManager.init(context);
}
Also used : PathVerificationService(org.openkilda.floodlight.pathverification.PathVerificationService) IPathVerificationService(org.openkilda.floodlight.pathverification.IPathVerificationService) PathVerificationServiceConfig(org.openkilda.floodlight.pathverification.PathVerificationServiceConfig) SwitchFlowFactory(org.openkilda.floodlight.switchmanager.factory.SwitchFlowFactory) Before(org.junit.Before)

Example 5 with PathVerificationService

use of org.openkilda.floodlight.pathverification.PathVerificationService in project open-kilda by telstra.

the class PingResponseCommandTest method success.

@Test
public void success() throws Exception {
    final PingService realPingService = new PingService();
    moduleContext.addService(PingService.class, realPingService);
    final ISwitchManager realSwitchManager = new SwitchManager();
    moduleContext.addService(ISwitchManager.class, realSwitchManager);
    InputService inputService = createMock(InputService.class);
    moduleContext.addService(InputService.class, inputService);
    inputService.addTranslator(eq(OFType.PACKET_IN), anyObject());
    replayAll();
    final DatapathId dpIdBeta = DatapathId.of(0x0000fffe000002L);
    final Ping ping = new Ping(new NetworkEndpoint(new SwitchId(dpIdBeta.getLong()), 8), new NetworkEndpoint(new SwitchId(dpId.getLong()), 9), new FlowTransitEncapsulation(2, FlowEncapsulationType.TRANSIT_VLAN), 3);
    final PingData payload = PingData.of(ping);
    moduleContext.addConfigParam(new PathVerificationService(), "hmac256-secret", "secret");
    realPingService.setup(moduleContext);
    byte[] signedPayload = realPingService.getSignature().sign(payload);
    byte[] wireData = realPingService.wrapData(ping, signedPayload).serialize();
    OFFactory ofFactory = new OFFactoryVer13();
    OFPacketIn message = ofFactory.buildPacketIn().setReason(OFPacketInReason.ACTION).setXid(1L).setCookie(PingService.OF_CATCH_RULE_COOKIE).setData(wireData).build();
    FloodlightContext metadata = new FloodlightContext();
    IPacket decodedEthernet = new Ethernet().deserialize(wireData, 0, wireData.length);
    Assert.assertTrue(decodedEthernet instanceof Ethernet);
    IFloodlightProviderService.bcStore.put(metadata, IFloodlightProviderService.CONTEXT_PI_PAYLOAD, (Ethernet) decodedEthernet);
    OfInput input = new OfInput(iofSwitch, message, metadata);
    final PingResponseCommand command = makeCommand(input);
    command.call();
    final List<Message> replies = kafkaMessageCatcher.getValues();
    Assert.assertEquals(1, replies.size());
    InfoMessage response = (InfoMessage) replies.get(0);
    PingResponse pingResponse = (PingResponse) response.getData();
    Assert.assertNull(pingResponse.getError());
    Assert.assertNotNull(pingResponse.getMeters());
    Assert.assertEquals(payload.getPingId(), pingResponse.getPingId());
}
Also used : OfInput(org.openkilda.floodlight.model.OfInput) IPacket(net.floodlightcontroller.packet.IPacket) ISwitchManager(org.openkilda.floodlight.switchmanager.ISwitchManager) NetworkEndpoint(org.openkilda.messaging.model.NetworkEndpoint) InfoMessage(org.openkilda.messaging.info.InfoMessage) Message(org.openkilda.messaging.Message) OFMessage(org.projectfloodlight.openflow.protocol.OFMessage) OFFactoryVer13(org.projectfloodlight.openflow.protocol.ver13.OFFactoryVer13) OFFactory(org.projectfloodlight.openflow.protocol.OFFactory) FlowTransitEncapsulation(org.openkilda.model.FlowTransitEncapsulation) DatapathId(org.projectfloodlight.openflow.types.DatapathId) SwitchId(org.openkilda.model.SwitchId) PingResponse(org.openkilda.messaging.floodlight.response.PingResponse) SwitchManager(org.openkilda.floodlight.switchmanager.SwitchManager) ISwitchManager(org.openkilda.floodlight.switchmanager.ISwitchManager) PingData(org.openkilda.floodlight.model.PingData) InputService(org.openkilda.floodlight.service.of.InputService) PathVerificationService(org.openkilda.floodlight.pathverification.PathVerificationService) InfoMessage(org.openkilda.messaging.info.InfoMessage) PingService(org.openkilda.floodlight.service.ping.PingService) Ping(org.openkilda.messaging.model.Ping) Ethernet(net.floodlightcontroller.packet.Ethernet) OFPacketIn(org.projectfloodlight.openflow.protocol.OFPacketIn) FloodlightContext(net.floodlightcontroller.core.FloodlightContext) Test(org.junit.Test)

Aggregations

PathVerificationService (org.openkilda.floodlight.pathverification.PathVerificationService)5 Before (org.junit.Before)3 IPathVerificationService (org.openkilda.floodlight.pathverification.IPathVerificationService)3 IOFSwitchService (net.floodlightcontroller.core.internal.IOFSwitchService)2 PathVerificationServiceConfig (org.openkilda.floodlight.pathverification.PathVerificationServiceConfig)2 ISwitchManager (org.openkilda.floodlight.switchmanager.ISwitchManager)2 SwitchManager (org.openkilda.floodlight.switchmanager.SwitchManager)2 SwitchFlowFactory (org.openkilda.floodlight.switchmanager.factory.SwitchFlowFactory)2 JdkProxyStaticConfigurationFactory (com.sabre.oss.conf4j.factory.jdkproxy.JdkProxyStaticConfigurationFactory)1 MapConfigurationSource (com.sabre.oss.conf4j.source.MapConfigurationSource)1 FloodlightContext (net.floodlightcontroller.core.FloodlightContext)1 IFloodlightProviderService (net.floodlightcontroller.core.IFloodlightProviderService)1 IOFSwitch (net.floodlightcontroller.core.IOFSwitch)1 SwitchDescription (net.floodlightcontroller.core.SwitchDescription)1 Ethernet (net.floodlightcontroller.packet.Ethernet)1 IPacket (net.floodlightcontroller.packet.IPacket)1 IRestApiService (net.floodlightcontroller.restserver.IRestApiService)1 Test (org.junit.Test)1 KildaCore (org.openkilda.floodlight.KildaCore)1 KildaCoreConfig (org.openkilda.floodlight.KildaCoreConfig)1