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());
}
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();
}
}
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());
}
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()));
}
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);
}
Aggregations