Search in sources :

Example 11 with DefaultDriver

use of org.onosproject.net.driver.DefaultDriver in project onos by opennetworkinglab.

the class CfmMepManagerTest method setup.

@Before
public void setup() throws CfmConfigException {
    mepManager = new CfmMepManager();
    mepStore = new DistributedMepStore();
    storageService = new MockStorageService();
    ma1 = DefaultMaintenanceAssociation.builder(MANAME1, MDNAME1.getNameLength()).build();
    ma2 = DefaultMaintenanceAssociation.builder(MANAME2, MDNAME2.getNameLength()).build();
    TestUtils.setField(mepStore, "storageService", storageService);
    ((DistributedMepStore) mepStore).activate();
    TestUtils.setField(mepManager, "coreService", new TestCoreService());
    TestUtils.setField(mepManager, "deviceService", deviceService);
    TestUtils.setField(mepManager, "cfmMdService", mdService);
    TestUtils.setField(mepManager, "mepStore", mepStore);
    injectEventDispatcher(mepManager, new TestEventDispatcher());
    mepService = mepManager;
    mepManager.activate();
    mep1 = DefaultMep.builder(MEPID1, DEVICE_ID1, PortNumber.P0, Mep.MepDirection.UP_MEP, MDNAME1, MANAME1).build();
    mepStore.createUpdateMep(new MepKeyId(MDNAME1, MANAME1, MEPID1), mep1);
    mep11 = DefaultMep.builder(MEPID11, DEVICE_ID1, PortNumber.P0, Mep.MepDirection.UP_MEP, MDNAME1, MANAME1).build();
    mepStore.createUpdateMep(new MepKeyId(MDNAME1, MANAME1, MEPID11), mep11);
    mep12 = DefaultMep.builder(MEPID12, DEVICE_ID1, PortNumber.P0, Mep.MepDirection.UP_MEP, MDNAME2, MANAME2).build();
    mepStore.createUpdateMep(new MepKeyId(MDNAME2, MANAME2, MEPID12), mep12);
    mep2 = DefaultMep.builder(MEPID2, DEVICE_ID2, PortNumber.portNumber(2), Mep.MepDirection.UP_MEP, MDNAME1, MANAME1).build();
    mepStore.createUpdateMep(new MepKeyId(MDNAME1, MANAME1, MEPID2), mep2);
    mep21 = DefaultMep.builder(MEPID21, DEVICE_ID2, PortNumber.portNumber(2), Mep.MepDirection.UP_MEP, MDNAME1, MANAME1).build();
    mepStore.createUpdateMep(new MepKeyId(MDNAME1, MANAME1, MEPID21), mep21);
    mep22 = DefaultMep.builder(MEPID22, DEVICE_ID2, PortNumber.portNumber(2), Mep.MepDirection.UP_MEP, MDNAME2, MANAME2).build();
    mepStore.createUpdateMep(new MepKeyId(MDNAME2, MANAME2, MEPID22), mep22);
    device1 = new DefaultDevice(ProviderId.NONE, DEVICE_ID1, Device.Type.SWITCH, TEST_MFR, TEST_HW_VERSION, TEST_SW_VERSION, TEST_SN, new ChassisId(1), DefaultAnnotations.builder().set(AnnotationKeys.DRIVER, TEST_DRIVER).build());
    device2 = new DefaultDevice(ProviderId.NONE, DEVICE_ID2, Device.Type.SWITCH, TEST_MFR, TEST_HW_VERSION, TEST_SW_VERSION, TEST_SN, new ChassisId(2), DefaultAnnotations.builder().set(AnnotationKeys.DRIVER, TEST_DRIVER).build());
    AbstractProjectableModel.setDriverService(null, driverService);
    Map<Class<? extends Behaviour>, Class<? extends Behaviour>> behaviours = new HashMap<>();
    behaviours.put(DeviceDescriptionDiscovery.class, TestDeviceDiscoveryBehavior.class);
    behaviours.put(CfmMepProgrammable.class, TestCfmMepProgrammable.class);
    behaviours.put(SoamDmProgrammable.class, TestSoamDmProgrammable.class);
    testDriver = new DefaultDriver(TEST_DRIVER, new ArrayList<Driver>(), TEST_MFR, TEST_HW_VERSION, TEST_SW_VERSION, behaviours, new HashMap<>());
}
Also used : TestEventDispatcher(org.onosproject.common.event.impl.TestEventDispatcher) ChassisId(org.onlab.packet.ChassisId) Behaviour(org.onosproject.net.driver.Behaviour) HashMap(java.util.HashMap) DefaultDevice(org.onosproject.net.DefaultDevice) ArrayList(java.util.ArrayList) DefaultDriver(org.onosproject.net.driver.DefaultDriver) MepKeyId(org.onosproject.incubator.net.l2monitoring.cfm.identifier.MepKeyId) Before(org.junit.Before)

Example 12 with DefaultDriver

use of org.onosproject.net.driver.DefaultDriver in project onos by opennetworkinglab.

the class DriverRegistryManagerTest method basicEvents.

@Test
public void basicEvents() {
    mgr.addListener(testListener);
    DefaultDriverProvider mockProvider = new DefaultDriverProvider();
    DefaultDriver driver = new DefaultDriver("foo", Lists.newArrayList(), MFR, HW, SW, ImmutableMap.of(TestBehaviour.class, TestBehaviourImpl.class), ImmutableMap.of("foo", "bar"));
    mockProvider.addDriver(driver);
    mgr.registerProvider(mockProvider);
    assertEquals("wrong driver event type", DRIVER_ENHANCED, testListener.event.type());
    assertSame("wrong driver event subject", driver, testListener.event.subject());
    mgr.unregisterProvider(mockProvider);
    assertEquals("wrong driver event type", DRIVER_REDUCED, testListener.event.type());
    assertSame("wrong driver event subject", driver, testListener.event.subject());
    mgr.removeListener(testListener);
}
Also used : TestBehaviourImpl(org.onosproject.net.driver.TestBehaviourImpl) DefaultDriver(org.onosproject.net.driver.DefaultDriver) TestBehaviour(org.onosproject.net.driver.TestBehaviour) DefaultDriverProvider(org.onosproject.net.driver.DefaultDriverProvider) Test(org.junit.Test) DefaultDriverTest(org.onosproject.net.driver.DefaultDriverTest)

Example 13 with DefaultDriver

use of org.onosproject.net.driver.DefaultDriver in project onos by opennetworkinglab.

the class DriverRegistryManagerTest method managerStart.

@Test
public void managerStart() {
    DefaultDriverProvider mockProvider = new DefaultDriverProvider();
    DefaultDriver driver = new DefaultDriver("default", Lists.newArrayList(), MFR, HW, SW, ImmutableMap.of(TestBehaviour.class, TestBehaviourImpl.class), ImmutableMap.of("foo", "bar"));
    mockProvider.addDriver(driver);
    mgr.registerProvider(mockProvider);
    assertTrue("should be activated", componentService.activated);
    mgr.unregisterProvider(mockProvider);
    assertFalse("should not be dactivated", componentService.activated);
}
Also used : TestBehaviourImpl(org.onosproject.net.driver.TestBehaviourImpl) DefaultDriver(org.onosproject.net.driver.DefaultDriver) TestBehaviour(org.onosproject.net.driver.TestBehaviour) DefaultDriverProvider(org.onosproject.net.driver.DefaultDriverProvider) Test(org.junit.Test) DefaultDriverTest(org.onosproject.net.driver.DefaultDriverTest)

Example 14 with DefaultDriver

use of org.onosproject.net.driver.DefaultDriver in project onos by opennetworkinglab.

the class FlowRuleManagerTest method setUp.

@Before
public void setUp() {
    mgr = new FlowRuleManager();
    mgr.store = new SimpleFlowRuleStore();
    injectEventDispatcher(mgr, new TestEventDispatcher());
    mgr.deviceService = new TestDeviceService();
    mgr.mastershipService = new TestMastershipService();
    mgr.coreService = new TestCoreService();
    mgr.operationsService = MoreExecutors.newDirectExecutorService();
    mgr.deviceInstallers = MoreExecutors.newDirectExecutorService();
    mgr.cfgService = new ComponentConfigAdapter();
    ClusterService mockClusterService = createMock(ClusterService.class);
    NodeId nodeId = new NodeId(NODE_ID);
    MockControllerNode mockControllerNode = new MockControllerNode(nodeId);
    expect(mockClusterService.getLocalNode()).andReturn(mockControllerNode).anyTimes();
    replay(mockClusterService);
    mgr.clusterService = mockClusterService;
    service = mgr;
    registry = mgr;
    DriverRegistryManager driverRegistry = new DriverRegistryManager();
    driverService = new TestDriverManager(driverRegistry);
    driverRegistry.addDriver(new DefaultDriver("foo", ImmutableList.of(), "", "", "", ImmutableMap.of(FlowRuleProgrammable.class, TestFlowRuleProgrammable.class), ImmutableMap.of()));
    mgr.activate(null);
    mgr.addListener(listener);
    provider = new TestProvider(PID);
    providerService = this.registry.register(provider);
    appId = new TestApplicationId(0, "FlowRuleManagerTest");
    assertTrue("provider should be registered", this.registry.getProviders().contains(provider.id()));
}
Also used : TestEventDispatcher(org.onosproject.common.event.impl.TestEventDispatcher) ComponentConfigAdapter(org.onosproject.cfg.ComponentConfigAdapter) ClusterService(org.onosproject.cluster.ClusterService) SimpleFlowRuleStore(org.onosproject.store.trivial.SimpleFlowRuleStore) NodeId(org.onosproject.cluster.NodeId) DefaultDriver(org.onosproject.net.driver.DefaultDriver) DriverRegistryManager(org.onosproject.net.driver.impl.DriverRegistryManager) Before(org.junit.Before)

Example 15 with DefaultDriver

use of org.onosproject.net.driver.DefaultDriver 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)

Aggregations

DefaultDriver (org.onosproject.net.driver.DefaultDriver)16 Before (org.junit.Before)7 HashMap (java.util.HashMap)6 Test (org.junit.Test)6 TestEventDispatcher (org.onosproject.common.event.impl.TestEventDispatcher)6 Behaviour (org.onosproject.net.driver.Behaviour)6 Driver (org.onosproject.net.driver.Driver)5 ChassisId (org.onlab.packet.ChassisId)4 DefaultDevice (org.onosproject.net.DefaultDevice)4 TestBehaviour (org.onosproject.net.driver.TestBehaviour)4 DriverRegistryManager (org.onosproject.net.driver.impl.DriverRegistryManager)4 ArrayList (java.util.ArrayList)3 ComponentConfigAdapter (org.onosproject.cfg.ComponentConfigAdapter)3 DeviceId (org.onosproject.net.DeviceId)3 DefaultDriverData (org.onosproject.net.driver.DefaultDriverData)3 DefaultDriverProvider (org.onosproject.net.driver.DefaultDriverProvider)3 DefaultDriverTest (org.onosproject.net.driver.DefaultDriverTest)3 TestBehaviourImpl (org.onosproject.net.driver.TestBehaviourImpl)3 MepId (org.onosproject.incubator.net.l2monitoring.cfm.identifier.MepId)2 CfmConfigException (org.onosproject.incubator.net.l2monitoring.cfm.service.CfmConfigException)2