Search in sources :

Example 11 with ComponentConfigAdapter

use of org.onosproject.cfg.ComponentConfigAdapter in project onos by opennetworkinglab.

the class IntentCleanupTest method setUp.

@Before
public void setUp() {
    service = new MockIntentService();
    store = new SimpleIntentStore();
    cleanup = new IntentCleanup();
    super.setUp();
    cleanup.cfgService = new ComponentConfigAdapter();
    cleanup.service = service;
    cleanup.store = store;
    cleanup.period = 10;
    cleanup.retryThreshold = 3;
    cleanup.activate();
    assertTrue("store should be empty", Sets.newHashSet(cleanup.store.getIntents()).isEmpty());
}
Also used : ComponentConfigAdapter(org.onosproject.cfg.ComponentConfigAdapter) SimpleIntentStore(org.onosproject.store.trivial.SimpleIntentStore) Before(org.junit.Before)

Example 12 with ComponentConfigAdapter

use of org.onosproject.cfg.ComponentConfigAdapter in project onos by opennetworkinglab.

the class IntentManagerTest method testCorruptCleanup.

/**
 * Test failure to install an intent, then succeed on retry via IntentCleanup.
 */
@Test
public void testCorruptCleanup() {
    IntentCleanup cleanup = new IntentCleanup();
    cleanup.service = manager;
    cleanup.store = manager.store;
    cleanup.cfgService = new ComponentConfigAdapter();
    try {
        cleanup.activate();
        final TestIntentCompilerMultipleFlows errorCompiler = new TestIntentCompilerMultipleFlows();
        extensionService.registerCompiler(MockIntent.class, errorCompiler);
        List<Intent> intents;
        flowRuleService.setFuture(false);
        intents = Lists.newArrayList(service.getIntents());
        assertThat(intents, hasSize(0));
        final MockIntent intent1 = new MockIntent(MockIntent.nextId());
        listener.setLatch(1, Type.INSTALL_REQ);
        listener.setLatch(1, Type.CORRUPT);
        listener.setLatch(1, Type.INSTALLED);
        service.submit(intent1);
        listener.await(Type.INSTALL_REQ);
        listener.await(Type.CORRUPT);
        flowRuleService.setFuture(true);
        listener.await(Type.INSTALLED);
        assertThat(listener.getCounts(Type.CORRUPT), is(1));
        assertThat(listener.getCounts(Type.INSTALLED), is(1));
        assertEquals(INSTALLED, manager.getIntentState(intent1.key()));
        assertThat(flowRuleService.getFlowRuleCount(), is(5));
    } finally {
        cleanup.deactivate();
    }
}
Also used : ComponentConfigAdapter(org.onosproject.cfg.ComponentConfigAdapter) FlowRuleIntent(org.onosproject.net.intent.FlowRuleIntent) Intent(org.onosproject.net.intent.Intent) PathIntent(org.onosproject.net.intent.PathIntent) MockIntent(org.onosproject.net.intent.IntentTestsMocks.MockIntent) MockIntent(org.onosproject.net.intent.IntentTestsMocks.MockIntent) Test(org.junit.Test)

Example 13 with ComponentConfigAdapter

use of org.onosproject.cfg.ComponentConfigAdapter in project onos by opennetworkinglab.

the class OpenFlowDeviceProviderTest method startUp.

@Before
public void startUp() {
    provider.providerRegistry = registry;
    provider.controller = controller;
    provider.cfgService = new ComponentConfigAdapter();
    provider.driverService = new DriverServiceAdapter();
    provider.deviceService = new DeviceServiceAdapter();
    controller.switchMap.put(DPID1, SW1);
    provider.activate(null);
    assertNotNull("provider should be registered", registry.provider);
    assertNotNull("listener should be registered", controller.listener);
    assertEquals("devices not added", 1, registry.connected.size());
    assertEquals("ports not added", 2, registry.ports.get(DID1).size());
}
Also used : ComponentConfigAdapter(org.onosproject.cfg.ComponentConfigAdapter) DriverServiceAdapter(org.onosproject.net.driver.DriverServiceAdapter) DeviceServiceAdapter(org.onosproject.net.device.DeviceServiceAdapter) Before(org.junit.Before)

Example 14 with ComponentConfigAdapter

use of org.onosproject.cfg.ComponentConfigAdapter in project onos by opennetworkinglab.

the class MeterManagerTest method setup.

@Before
public void setup() {
    DeviceService deviceService = new TestDeviceService();
    DriverRegistryManager driverRegistry = new DriverRegistryManager();
    DriverManager driverService = new TestDriverManager(driverRegistry, deviceService, new NetworkConfigServiceAdapter());
    driverRegistry.addDriver(new DefaultDriver("foo", ImmutableList.of(), "", "", "", ImmutableMap.of(MeterProgrammable.class, TestMeterProgrammable.class, MeterQuery.class, TestMeterQuery.class), ImmutableMap.of()));
    meterStore = new DistributedMeterStore();
    TestUtils.setField(meterStore, "storageService", new TestStorageService());
    TestUtils.setField(meterStore, "driverService", driverService);
    KryoNamespace.Builder testKryoBuilder = TestUtils.getField(meterStore, "APP_KRYO_BUILDER");
    testKryoBuilder.register(TestApplicationId.class);
    Serializer testSerializer = Serializer.using(Lists.newArrayList(testKryoBuilder.build()));
    TestUtils.setField(meterStore, "serializer", testSerializer);
    meterStore.activate();
    manager = new MeterManager();
    TestUtils.setField(manager, "store", meterStore);
    injectEventDispatcher(manager, new TestEventDispatcher());
    manager.deviceService = deviceService;
    manager.mastershipService = new TestMastershipService();
    manager.cfgService = new ComponentConfigAdapter();
    manager.clusterService = new TestClusterService();
    registry = manager;
    manager.driverService = driverService;
    Dictionary<String, Object> cfgDict = new Hashtable<>();
    expect(componentContext.getProperties()).andReturn(cfgDict);
    replay(componentContext);
    manager.activate(componentContext);
    provider = new TestProvider(PID);
    providerService = registry.register(provider);
    assertTrue("provider should be registered", registry.getProviders().contains(provider.id()));
}
Also used : TestEventDispatcher(org.onosproject.common.event.impl.TestEventDispatcher) TestStorageService(org.onosproject.store.service.TestStorageService) Hashtable(java.util.Hashtable) DeviceService(org.onosproject.net.device.DeviceService) DistributedMeterStore(org.onosproject.store.meter.impl.DistributedMeterStore) ComponentConfigAdapter(org.onosproject.cfg.ComponentConfigAdapter) DefaultDriver(org.onosproject.net.driver.DefaultDriver) KryoNamespace(org.onlab.util.KryoNamespace) NetworkConfigServiceAdapter(org.onosproject.net.config.NetworkConfigServiceAdapter) DriverManager(org.onosproject.net.driver.impl.DriverManager) DriverRegistryManager(org.onosproject.net.driver.impl.DriverRegistryManager) Serializer(org.onosproject.store.service.Serializer) Before(org.junit.Before)

Example 15 with ComponentConfigAdapter

use of org.onosproject.cfg.ComponentConfigAdapter in project onos by opennetworkinglab.

the class LinkCollectionIntentCompilerTest method setUp.

@Before
public void setUp() {
    sut = new LinkCollectionIntentCompiler();
    coreService = createMock(CoreService.class);
    expect(coreService.registerApplication("org.onosproject.net.intent")).andReturn(appId);
    sut.coreService = coreService;
    domainService = createMock(DomainService.class);
    expect(domainService.getDomain(anyObject(DeviceId.class))).andReturn(LOCAL).anyTimes();
    sut.domainService = domainService;
    super.setUp();
    intent = LinkCollectionIntent.builder().appId(APP_ID).selector(selector).treatment(treatment).links(links).filteredIngressPoints(ImmutableSet.of(new FilteredConnectPoint(d1p1))).filteredEgressPoints(ImmutableSet.of(new FilteredConnectPoint(d3p1))).build();
    intentExtensionService = createMock(IntentExtensionService.class);
    intentExtensionService.registerCompiler(LinkCollectionIntent.class, sut);
    intentExtensionService.unregisterCompiler(LinkCollectionIntent.class);
    registrator = new IntentConfigurableRegistrator();
    registrator.extensionService = intentExtensionService;
    registrator.cfgService = new ComponentConfigAdapter();
    registrator.activate();
    sut.registrator = registrator;
    sut.resourceService = new MockResourceService();
    LinkCollectionCompiler.optimizeInstructions = false;
    LinkCollectionCompiler.copyTtl = false;
    replay(coreService, domainService, intentExtensionService);
}
Also used : ComponentConfigAdapter(org.onosproject.cfg.ComponentConfigAdapter) IntentExtensionService(org.onosproject.net.intent.IntentExtensionService) MockResourceService(org.onosproject.net.resource.MockResourceService) DomainService(org.onosproject.net.domain.DomainService) CoreService(org.onosproject.core.CoreService) FilteredConnectPoint(org.onosproject.net.FilteredConnectPoint) Before(org.junit.Before)

Aggregations

ComponentConfigAdapter (org.onosproject.cfg.ComponentConfigAdapter)30 Before (org.junit.Before)27 CoreService (org.onosproject.core.CoreService)12 IntentExtensionService (org.onosproject.net.intent.IntentExtensionService)7 MockResourceService (org.onosproject.net.resource.MockResourceService)7 TestEventDispatcher (org.onosproject.common.event.impl.TestEventDispatcher)6 DomainService (org.onosproject.net.domain.DomainService)6 ClusterService (org.onosproject.cluster.ClusterService)4 NodeId (org.onosproject.cluster.NodeId)4 DeviceServiceAdapter (org.onosproject.net.device.DeviceServiceAdapter)4 DriverServiceAdapter (org.onosproject.net.driver.DriverServiceAdapter)4 CoreServiceAdapter (org.onosproject.core.CoreServiceAdapter)3 DefaultDriver (org.onosproject.net.driver.DefaultDriver)3 DriverRegistryManager (org.onosproject.net.driver.impl.DriverRegistryManager)3 ClusterCommunicationServiceAdapter (org.onosproject.store.cluster.messaging.ClusterCommunicationServiceAdapter)3 TestStorageService (org.onosproject.store.service.TestStorageService)3 Test (org.junit.Test)2 ComponentContextAdapter (org.onlab.osgi.ComponentContextAdapter)2 FlowRuleIntent (org.onosproject.net.intent.FlowRuleIntent)2 Intent (org.onosproject.net.intent.Intent)2