use of org.opendaylight.netconf.topology.singleton.impl.utils.NetconfTopologySetup in project netconf by opendaylight.
the class NetconfNodeActorTest method setup.
@Before
public void setup() {
remoteDeviceId = new RemoteDeviceId("netconf-topology", new InetSocketAddress(InetAddresses.forString("127.0.0.1"), 9999));
masterSchemaRepository.registerSchemaSourceListener(TextToIRTransformer.create(masterSchemaRepository, masterSchemaRepository));
doReturn(masterSchemaRepository).when(schemaResourceDTO).getSchemaRepository();
doReturn(mockRegistry).when(schemaResourceDTO).getSchemaRegistry();
final NetconfTopologySetup setup = NetconfTopologySetupBuilder.create().setActorSystem(system).setIdleTimeout(Duration.apply(1, TimeUnit.SECONDS)).setSchemaResourceDTO(schemaResourceDTO).setBaseSchemas(BASE_SCHEMAS).build();
final Props props = NetconfNodeActor.props(setup, remoteDeviceId, TIMEOUT, mockMountPointService);
masterRef = TestActorRef.create(system, props, "master_messages");
resetMountPointMocks();
doReturn(mockMountPointBuilder).when(mockMountPointService).createMountPoint(any());
doReturn(mockSchemaSourceReg1).when(mockRegistry).registerSchemaSource(any(), withSourceId(SOURCE_IDENTIFIER1));
doReturn(mockSchemaSourceReg2).when(mockRegistry).registerSchemaSource(any(), withSourceId(SOURCE_IDENTIFIER2));
doReturn(mockSchemaContextFactory).when(mockSchemaRepository).createEffectiveModelContextFactory();
}
use of org.opendaylight.netconf.topology.singleton.impl.utils.NetconfTopologySetup in project netconf by opendaylight.
the class NetconfNodeManagerTest method setup.
@Before
public void setup() {
final Timeout responseTimeout = Timeout.apply(1, TimeUnit.SECONDS);
slaveSystem = ActorSystem.create(ACTOR_SYSTEM_NAME, ConfigFactory.load().getConfig("Slave"));
masterSystem = ActorSystem.create(ACTOR_SYSTEM_NAME, ConfigFactory.load().getConfig("Master"));
masterAddress = Cluster.get(masterSystem).selfAddress().toString();
SharedSchemaRepository masterSchemaRepository = new SharedSchemaRepository("master");
masterSchemaRepository.registerSchemaSourceListener(TextToIRTransformer.create(masterSchemaRepository, masterSchemaRepository));
String yangTemplate = "module ID {" + " namespace \"ID\";" + " prefix ID;" + "}";
SOURCE_IDENTIFIERS.stream().map(sourceId -> masterSchemaRepository.registerSchemaSource(id -> Futures.immediateFuture(YangTextSchemaSource.delegateForByteSource(id, ByteSource.wrap(yangTemplate.replaceAll("ID", id.getName()).getBytes(UTF_8)))), PotentialSchemaSource.create(sourceId, YangTextSchemaSource.class, 1))).collect(Collectors.toList());
NetconfTopologySetup masterSetup = new NetconfTopologySetup.NetconfTopologySetupBuilder().setActorSystem(masterSystem).setDataBroker(mockDataBroker).setSchemaResourceDTO(new NetconfDevice.SchemaResourcesDTO(masterSchemaRepository, masterSchemaRepository, mockSchemaContextFactory, mockSchemasResolver)).setBaseSchemas(BASE_SCHEMAS).build();
testMasterActorRef = TestActorRef.create(masterSystem, Props.create(TestMasterActor.class, masterSetup, DEVICE_ID, responseTimeout, mockMountPointService).withDispatcher(Dispatchers.DefaultDispatcherId()), NetconfTopologyUtils.createMasterActorName(DEVICE_ID.getName(), masterAddress));
SharedSchemaRepository slaveSchemaRepository = new SharedSchemaRepository("slave");
slaveSchemaRepository.registerSchemaSourceListener(TextToIRTransformer.create(slaveSchemaRepository, slaveSchemaRepository));
NetconfTopologySetup slaveSetup = new NetconfTopologySetup.NetconfTopologySetupBuilder().setActorSystem(slaveSystem).setDataBroker(mockDataBroker).setSchemaResourceDTO(new NetconfDevice.SchemaResourcesDTO(slaveSchemaRepository, slaveSchemaRepository, mockSchemaContextFactory, mockSchemasResolver)).setBaseSchemas(BASE_SCHEMAS).build();
netconfNodeManager = new NetconfNodeManager(slaveSetup, DEVICE_ID, responseTimeout, mockMountPointService);
setupMountPointMocks();
}
use of org.opendaylight.netconf.topology.singleton.impl.utils.NetconfTopologySetup in project netconf by opendaylight.
the class NetconfTopologyManagerTest method setUp.
@Before
public void setUp() throws Exception {
AbstractDataBrokerTest dataBrokerTest = new AbstractDataBrokerTest() {
@Override
protected Set<YangModuleInfo> getModuleInfos() throws Exception {
return ImmutableSet.of(BindingReflections.getModuleInfo(NetworkTopology.class), BindingReflections.getModuleInfo(Topology.class));
}
};
dataBrokerTest.setup();
dataBroker = spy(dataBrokerTest.getDataBroker());
final DOMRpcProviderService rpcProviderRegistry = mock(DOMRpcProviderService.class);
final ScheduledThreadPool keepaliveExecutor = mock(ScheduledThreadPool.class);
final DOMActionProviderService actionProviderRegistry = mock(DOMActionProviderService.class);
final ThreadPool processingThreadPool = mock(ThreadPool.class);
final ExecutorService processingService = mock(ExecutorService.class);
doReturn(processingService).when(processingThreadPool).getExecutor();
final ActorSystemProvider actorSystemProvider = mock(ActorSystemProvider.class);
final EventExecutor eventExecutor = mock(EventExecutor.class);
final NetconfClientDispatcher clientDispatcher = mock(NetconfClientDispatcher.class);
final DOMMountPointService mountPointService = mock(DOMMountPointService.class);
final AAAEncryptionService encryptionService = mock(AAAEncryptionService.class);
final DeviceActionFactory deviceActionFactory = mock(DeviceActionFactory.class);
final RpcProviderService rpcProviderService = mock(RpcProviderService.class);
final Config config = new ConfigBuilder().setWriteTransactionIdleTimeout(Uint16.ZERO).build();
netconfTopologyManager = new NetconfTopologyManager(BASE_SCHEMAS, dataBroker, rpcProviderRegistry, actionProviderRegistry, clusterSingletonServiceProvider, keepaliveExecutor, processingThreadPool, actorSystemProvider, eventExecutor, clientDispatcher, TOPOLOGY_ID, config, mountPointService, encryptionService, rpcProviderService, deviceActionFactory, new DefaultSchemaResourceManager(new DefaultYangParserFactory())) {
@Override
protected NetconfTopologyContext newNetconfTopologyContext(final NetconfTopologySetup setup, final ServiceGroupIdentifier serviceGroupIdent, final Timeout actorResponseWaitTime, final DeviceActionFactory deviceActionFactory) {
assertEquals(ACTOR_RESPONSE_WAIT_TIME.toJava(), actorResponseWaitTime.duration().toSeconds());
return Objects.requireNonNull(mockContextMap.get(setup.getInstanceIdentifier()), "No mock context for " + setup.getInstanceIdentifier()).apply(setup);
}
};
doNothing().when(mockListenerReg).close();
doReturn(mockListenerReg).when(dataBroker).registerDataTreeChangeListener(any(), any());
}
use of org.opendaylight.netconf.topology.singleton.impl.utils.NetconfTopologySetup in project netconf by opendaylight.
the class MountPointEndToEndTest method setupMaster.
private void setupMaster() throws Exception {
AbstractConcurrentDataBrokerTest dataBrokerTest = newDataBrokerTest();
masterDataBroker = dataBrokerTest.getDataBroker();
deviceDOMDataBroker = dataBrokerTest.getDomBroker();
bindingToNormalized = dataBrokerTest.getDataBrokerTestCustomizer().getAdapterContext().currentSerializer();
masterSystem = ActorSystem.create(ACTOR_SYSTEM_NAME, ConfigFactory.load().getConfig("Master"));
masterClusterSingletonServiceProvider = new DOMClusterSingletonServiceProviderImpl();
masterClusterSingletonServiceProvider.initializeProvider();
doReturn(masterSystem).when(mockMasterActorSystemProvider).getActorSystem();
doReturn(MoreExecutors.newDirectExecutorService()).when(mockThreadPool).getExecutor();
final SchemaResourcesDTO resources = resourceManager.getSchemaResources(new NetconfNodeBuilder().setSchemaCacheDirectory(TEST_DEFAULT_SUBDIR).build(), "test");
resources.getSchemaRegistry().registerSchemaSource(id -> Futures.immediateFuture(YangTextSchemaSource.delegateForByteSource(id, topModuleInfo.getYangTextByteSource())), PotentialSchemaSource.create(RevisionSourceIdentifier.create(TOP_MODULE_NAME, topModuleInfo.getName().getRevision()), YangTextSchemaSource.class, 1));
masterNetconfTopologyManager = new NetconfTopologyManager(BASE_SCHEMAS, masterDataBroker, mockRpcProviderRegistry, mockActionProviderRegistry, masterClusterSingletonServiceProvider, mockKeepaliveExecutor, mockThreadPool, mockMasterActorSystemProvider, eventExecutor, mockClientDispatcher, TOPOLOGY_ID, config, masterMountPointService, mockEncryptionService, mockRpcProviderService, deviceActionFactory, resourceManager) {
@Override
protected NetconfTopologyContext newNetconfTopologyContext(final NetconfTopologySetup setup, final ServiceGroupIdentifier serviceGroupIdent, final Timeout actorResponseWaitTime, final DeviceActionFactory deviceActionFact) {
NetconfTopologyContext context = super.newNetconfTopologyContext(setup, serviceGroupIdent, actorResponseWaitTime, deviceActionFact);
NetconfTopologyContext spiedContext = spy(context);
doAnswer(invocation -> {
final MasterSalFacade spiedFacade = (MasterSalFacade) spy(invocation.callRealMethod());
doReturn(deviceDOMDataBroker).when(spiedFacade).newDeviceDataBroker();
masterSalFacadeFuture.set(spiedFacade);
return spiedFacade;
}).when(spiedContext).newMasterSalFacade();
return spiedContext;
}
};
masterNetconfTopologyManager.init();
verifyTopologyNodesCreated(masterDataBroker);
}
Aggregations