Search in sources :

Example 71 with CoreService

use of org.onosproject.core.CoreService in project fabric-tna by stratum.

the class FabricUpfProgrammableTest method setUp.

@Before
public void setUp() throws Exception {
    FabricCapabilities capabilities = createMock(FabricCapabilities.class);
    expect(capabilities.supportUpf()).andReturn(true).anyTimes();
    replay(capabilities);
    // Services mock
    packetService = new MockPacketService();
    CoreService coreService = createMock(CoreService.class);
    NetworkConfigService netcfgService = createMock(NetworkConfigService.class);
    DeviceService deviceService = createMock(DeviceService.class);
    SlicingService slicingService = createMock(SlicingService.class);
    expect(slicingService.getSlices()).andReturn(Set.of(SliceId.of(SLICE_MOBILE))).anyTimes();
    expect(slicingService.getTrafficClasses(SliceId.of(SLICE_MOBILE))).andReturn(Set.of(TrafficClass.ELASTIC)).anyTimes();
    PiTranslationService piTranslationService = createMock(PiTranslationService.class);
    expect(coreService.getAppId(anyString())).andReturn(APP_ID).anyTimes();
    expect(netcfgService.getConfig(TestUpfConstants.DEVICE_ID, BasicDeviceConfig.class)).andReturn(TestUpfUtils.getBasicConfig(TestUpfConstants.DEVICE_ID, "/basic.json")).anyTimes();
    replay(coreService, netcfgService, slicingService);
    // Mock driverData to get the right device ID
    DriverData driverData = createMock(DriverData.class);
    expect(driverData.deviceId()).andReturn(TestUpfConstants.DEVICE_ID).anyTimes();
    replay(driverData);
    // Mock DriverHandler to get all the required mocked services
    DriverHandler driverHandler = createMock(DriverHandler.class);
    expect(driverHandler.get(FlowRuleService.class)).andReturn(new MockFlowRuleService()).anyTimes();
    expect(driverHandler.get(MeterService.class)).andReturn(new MockMeterService()).anyTimes();
    expect(driverHandler.get(SlicingService.class)).andReturn(slicingService).anyTimes();
    expect(driverHandler.get(PacketService.class)).andReturn(packetService).anyTimes();
    expect(driverHandler.get(NetworkConfigService.class)).andReturn(netcfgService).anyTimes();
    expect(driverHandler.get(CoreService.class)).andReturn(coreService).anyTimes();
    expect(driverHandler.get(DeviceService.class)).andReturn(deviceService).anyTimes();
    expect(driverHandler.get(PiTranslationService.class)).andReturn(piTranslationService).anyTimes();
    expect(driverHandler.get(PiPipeconfService.class)).andReturn(new MockPiPipeconfService(TABLE_MODELS, COUNTER_MODELS, METER_MODELS, TNA)).anyTimes();
    expect(driverHandler.get(P4RuntimeController.class)).andReturn(mockP4RtController).anyTimes();
    expect(driverHandler.data()).andReturn(driverData).anyTimes();
    replay(driverHandler);
    upfProgrammable = new FabricUpfProgrammable();
    TestUtils.setField(upfProgrammable, "handler", driverHandler);
    TestUtils.setField(upfProgrammable, "data", driverData);
    ConcurrentMap<DeviceId, URI> channelUris = TestUtils.getField(upfProgrammable, "CHANNEL_URIS");
    channelUris.put(TestUpfConstants.DEVICE_ID, new URI("grpc://localhost:1234?device_id=1"));
}
Also used : DriverData(org.onosproject.net.driver.DriverData) PacketService(org.onosproject.net.packet.PacketService) NetworkConfigService(org.onosproject.net.config.NetworkConfigService) DeviceId(org.onosproject.net.DeviceId) DeviceService(org.onosproject.net.device.DeviceService) CoreService(org.onosproject.core.CoreService) PiPipeconfService(org.onosproject.net.pi.service.PiPipeconfService) FabricCapabilities(org.stratumproject.fabric.tna.behaviour.FabricCapabilities) URI(java.net.URI) BasicDeviceConfig(org.onosproject.net.config.basics.BasicDeviceConfig) P4RuntimeController(org.onosproject.p4runtime.api.P4RuntimeController) DriverHandler(org.onosproject.net.driver.DriverHandler) PiTranslationService(org.onosproject.net.pi.service.PiTranslationService) FlowRuleService(org.onosproject.net.flow.FlowRuleService) MeterService(org.onosproject.net.meter.MeterService) SlicingService(org.stratumproject.fabric.tna.slicing.api.SlicingService) Before(org.junit.Before)

Aggregations

CoreService (org.onosproject.core.CoreService)71 Before (org.junit.Before)31 ApplicationId (org.onosproject.core.ApplicationId)30 FlowRuleService (org.onosproject.net.flow.FlowRuleService)14 JsonNode (com.fasterxml.jackson.databind.JsonNode)12 ComponentConfigAdapter (org.onosproject.cfg.ComponentConfigAdapter)12 NetworkConfigService (org.onosproject.net.config.NetworkConfigService)12 TrafficSelector (org.onosproject.net.flow.TrafficSelector)11 TrafficTreatment (org.onosproject.net.flow.TrafficTreatment)11 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)10 DeviceId (org.onosproject.net.DeviceId)10 IntentExtensionService (org.onosproject.net.intent.IntentExtensionService)10 TestServiceDirectory (org.onlab.osgi.TestServiceDirectory)9 MockResourceService (org.onosproject.net.resource.MockResourceService)9 TestEventDispatcher (org.onosproject.common.event.impl.TestEventDispatcher)8 DistributedVirtualNetworkStore (org.onosproject.incubator.net.virtual.store.impl.DistributedVirtualNetworkStore)8 DeviceService (org.onosproject.net.device.DeviceService)8 TestStorageService (org.onosproject.store.service.TestStorageService)8 ArrayList (java.util.ArrayList)7 DomainService (org.onosproject.net.domain.DomainService)6