Search in sources :

Example 1 with PropertiesBasedConfigurationProvider

use of org.openkilda.config.provider.PropertiesBasedConfigurationProvider 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;
}
Also used : IOFSwitchService(net.floodlightcontroller.core.internal.IOFSwitchService) FloodlightModuleContext(net.floodlightcontroller.core.module.FloodlightModuleContext) PropertiesBasedConfigurationProvider(org.openkilda.config.provider.PropertiesBasedConfigurationProvider) MessageContext(org.openkilda.messaging.MessageContext) FeatureDetectorService(org.openkilda.floodlight.service.FeatureDetectorService) Properties(java.util.Properties) FlowSegmentMetadata(org.openkilda.floodlight.model.FlowSegmentMetadata) KildaCore(org.openkilda.floodlight.KildaCore)

Example 2 with PropertiesBasedConfigurationProvider

use of org.openkilda.config.provider.PropertiesBasedConfigurationProvider 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;
}
Also used : FlowEndpoint(org.openkilda.model.FlowEndpoint) IOFSwitchService(net.floodlightcontroller.core.internal.IOFSwitchService) FloodlightModuleContext(net.floodlightcontroller.core.module.FloodlightModuleContext) PropertiesBasedConfigurationProvider(org.openkilda.config.provider.PropertiesBasedConfigurationProvider) MessageContext(org.openkilda.messaging.MessageContext) FeatureDetectorService(org.openkilda.floodlight.service.FeatureDetectorService) Properties(java.util.Properties) FlowSegmentMetadata(org.openkilda.floodlight.model.FlowSegmentMetadata) KildaCore(org.openkilda.floodlight.KildaCore)

Example 3 with PropertiesBasedConfigurationProvider

use of org.openkilda.config.provider.PropertiesBasedConfigurationProvider in project open-kilda by telstra.

the class InMemoryPathComputerBaseTest method setUpOnce.

@BeforeClass
public static void setUpOnce() {
    switchRepository = repositoryFactory.createSwitchRepository();
    switchPropertiesRepository = repositoryFactory.createSwitchPropertiesRepository();
    islRepository = repositoryFactory.createIslRepository();
    flowRepository = repositoryFactory.createFlowRepository();
    flowPathRepository = repositoryFactory.createFlowPathRepository();
    config = new PropertiesBasedConfigurationProvider().getConfiguration(PathComputerConfig.class);
    availableNetworkFactory = new AvailableNetworkFactory(config, repositoryFactory);
    pathComputerFactory = new PathComputerFactory(config, availableNetworkFactory);
}
Also used : PathComputerConfig(org.openkilda.pce.PathComputerConfig) AvailableNetworkFactory(org.openkilda.pce.AvailableNetworkFactory) PathComputerFactory(org.openkilda.pce.PathComputerFactory) PropertiesBasedConfigurationProvider(org.openkilda.config.provider.PropertiesBasedConfigurationProvider) BeforeClass(org.junit.BeforeClass)

Example 4 with PropertiesBasedConfigurationProvider

use of org.openkilda.config.provider.PropertiesBasedConfigurationProvider in project open-kilda by telstra.

the class CommandBuilderImplTest method setUpOnce.

@BeforeClass
public static void setUpOnce() {
    Properties configProps = new Properties();
    configProps.setProperty("flow.meter-id.max", "40");
    configProps.setProperty("flow.vlan.max", "50");
    PropertiesBasedConfigurationProvider configurationProvider = new PropertiesBasedConfigurationProvider(configProps);
    FlowResourcesConfig flowResourcesConfig = configurationProvider.getConfiguration(FlowResourcesConfig.class);
    commandBuilder = new CommandBuilderImpl(persistenceManager().build(), flowResourcesConfig);
}
Also used : FlowResourcesConfig(org.openkilda.wfm.share.flow.resources.FlowResourcesConfig) PropertiesBasedConfigurationProvider(org.openkilda.config.provider.PropertiesBasedConfigurationProvider) SwitchProperties(org.openkilda.model.SwitchProperties) Properties(java.util.Properties) BeforeClass(org.junit.BeforeClass)

Example 5 with PropertiesBasedConfigurationProvider

use of org.openkilda.config.provider.PropertiesBasedConfigurationProvider in project open-kilda by telstra.

the class SwitchSyncServiceImplTest method setUp.

@Before
public void setUp() {
    RepositoryFactory repositoryFactory = Mockito.mock(RepositoryFactory.class);
    FlowRepository flowRepository = Mockito.mock(FlowRepository.class);
    FlowPathRepository flowPathRepository = Mockito.mock(FlowPathRepository.class);
    TransitVlanRepository transitVlanRepository = Mockito.mock(TransitVlanRepository.class);
    when(repositoryFactory.createFlowPathRepository()).thenReturn(flowPathRepository);
    when(repositoryFactory.createFlowRepository()).thenReturn(flowRepository);
    when(repositoryFactory.createTransitVlanRepository()).thenReturn(transitVlanRepository);
    when(persistenceManager.getRepositoryFactory()).thenReturn(repositoryFactory);
    Properties configProps = new Properties();
    configProps.setProperty("flow.meter-id.max", "40");
    configProps.setProperty("flow.vlan.max", "50");
    PropertiesBasedConfigurationProvider configurationProvider = new PropertiesBasedConfigurationProvider(configProps);
    FlowResourcesConfig flowResourcesConfig = configurationProvider.getConfiguration(FlowResourcesConfig.class);
    service = new SwitchSyncServiceImpl(carrier, persistenceManager, flowResourcesConfig);
    service.commandBuilder = commandBuilder;
    request = SwitchValidateRequest.builder().switchId(SWITCH_ID).performSync(true).build();
    flowEntry = new FlowEntry(new FlowSegmentCookie(FlowPathDirection.FORWARD, 7).getValue(), 0, 0, 0, 0, "", 0, 0, 0, 0, null, null, null);
    InstallIngressFlow installingRule = new InstallIngressFlow(UUID.randomUUID(), FLOW_ID, flowEntry.getCookie(), SWITCH_ID, 1, 2, 50, 0, 60, FlowEncapsulationType.TRANSIT_VLAN, OutputVlanType.POP, 10L, 100L, EGRESS_SWITCH_ID, false, false, false, null);
    when(commandBuilder.buildCommandsToSyncMissingRules(eq(SWITCH_ID), any())).thenReturn(singletonList(installingRule));
    missingRules = singletonList(flowEntry.getCookie());
    excessRules = emptyList();
    misconfiguredRules = emptyList();
    excessMeters = emptyList();
}
Also used : InstallIngressFlow(org.openkilda.messaging.command.flow.InstallIngressFlow) FlowRepository(org.openkilda.persistence.repositories.FlowRepository) FlowPathRepository(org.openkilda.persistence.repositories.FlowPathRepository) FlowResourcesConfig(org.openkilda.wfm.share.flow.resources.FlowResourcesConfig) FlowSegmentCookie(org.openkilda.model.cookie.FlowSegmentCookie) TransitVlanRepository(org.openkilda.persistence.repositories.TransitVlanRepository) PropertiesBasedConfigurationProvider(org.openkilda.config.provider.PropertiesBasedConfigurationProvider) RepositoryFactory(org.openkilda.persistence.repositories.RepositoryFactory) Properties(java.util.Properties) FlowEntry(org.openkilda.messaging.info.rule.FlowEntry) Before(org.junit.Before)

Aggregations

PropertiesBasedConfigurationProvider (org.openkilda.config.provider.PropertiesBasedConfigurationProvider)11 Properties (java.util.Properties)9 BeforeClass (org.junit.BeforeClass)4 Before (org.junit.Before)3 IOFSwitchService (net.floodlightcontroller.core.internal.IOFSwitchService)2 FloodlightModuleContext (net.floodlightcontroller.core.module.FloodlightModuleContext)2 KildaCore (org.openkilda.floodlight.KildaCore)2 FlowSegmentMetadata (org.openkilda.floodlight.model.FlowSegmentMetadata)2 FeatureDetectorService (org.openkilda.floodlight.service.FeatureDetectorService)2 MessageContext (org.openkilda.messaging.MessageContext)2 PathComputerConfig (org.openkilda.pce.PathComputerConfig)2 RepositoryFactory (org.openkilda.persistence.repositories.RepositoryFactory)2 FlowResourcesConfig (org.openkilda.wfm.share.flow.resources.FlowResourcesConfig)2 KildaCoreConfig (org.openkilda.floodlight.KildaCoreConfig)1 InstallIngressFlow (org.openkilda.messaging.command.flow.InstallIngressFlow)1 FlowEntry (org.openkilda.messaging.info.rule.FlowEntry)1 FlowEndpoint (org.openkilda.model.FlowEndpoint)1 SwitchProperties (org.openkilda.model.SwitchProperties)1 FlowSegmentCookie (org.openkilda.model.cookie.FlowSegmentCookie)1 AvailableNetworkFactory (org.openkilda.pce.AvailableNetworkFactory)1