Search in sources :

Example 26 with Config

use of com.icodici.universa.node2.Config in project universa by UniversaBlockchain.

the class MainTest method testGetContractAPIforManyActive.

@Test
public void testGetContractAPIforManyActive() throws Exception {
    // init network in permanet mode
    List<Main> mm = new ArrayList<>();
    for (int i = 0; i < 4; i++) mm.add(createMain("node" + (i + 1), "_permanet", false));
    Main main = mm.get(0);
    main.config.setIsFreeRegistrationsAllowedFromYaml(true);
    main.config.getKeysWhiteList().add(TestKeys.publicKey(20));
    Client client = new Client(TestKeys.privateKey(20), main.myInfo, null);
    assertTrue(main.config.isPermanetMode());
    for (int i = 1; i < 4; i++) assertTrue(mm.get(i).config.isPermanetMode());
    // try cancel permanet mode
    main.config.setPermanetMode(false);
    assertTrue(main.config.isPermanetMode());
    Set<PrivateKey> issuerPrivateKeys = new HashSet<>(asList(TestKeys.privateKey(1)));
    Set<PublicKey> ownerPublicKeys = new HashSet<>(asList(TestKeys.publicKey(2)));
    Set<PrivateKey> issuerPrivateKeys2 = new HashSet<>(asList(TestKeys.privateKey(2)));
    List<Contract> splits = new ArrayList<>();
    Integer amountTokens = 1000;
    Contract tokenContract = ContractsService.createTokenContract(issuerPrivateKeys, ownerPublicKeys, new BigDecimal("1000"));
    tokenContract.check();
    tokenContract.traceErrors();
    HashId origin = tokenContract.getId();
    ItemResult itemResult = client.register(tokenContract.getPackedTransaction(), 5000);
    System.out.println("tokenContract : " + itemResult + " = " + amountTokens.toString());
    assertEquals(ItemState.APPROVED, itemResult.state);
    for (Integer i = 1; i < 41; i++) {
        Contract contractRemainder = ContractsService.createSplit(tokenContract, new BigDecimal(i), "amount", issuerPrivateKeys2, true);
        Contract contractSplit = contractRemainder.getNew().get(0);
        amountTokens -= i;
        splits.add(contractSplit);
        itemResult = client.register(contractRemainder.getPackedTransaction(), 5000);
        System.out.println("contractRemainder : " + itemResult + " = " + amountTokens.toString());
        assertEquals(ItemState.APPROVED, itemResult.state);
        assertEquals(amountTokens.toString(), contractRemainder.getStateData().get("amount").toString());
        assertEquals(i.toString(), contractSplit.getStateData().get("amount").toString());
        assertEquals(ItemState.REVOKED, main.node.waitItem(tokenContract.getId(), 5000).state);
        assertEquals(ItemState.APPROVED, main.node.waitItem(contractRemainder.getId(), 5000).state);
        assertEquals(ItemState.APPROVED, main.node.waitItem(contractSplit.getId(), 5000).state);
        tokenContract = contractRemainder;
    }
    // check getContract (default limit 100)
    Binder result = client.getContract(origin);
    List<byte[]> allKeepingIds = result.getListOrThrow("contractIds");
    assertFalse(result.containsKey("packedContract"));
    assertEquals(allKeepingIds.size(), splits.size() + 1);
    final HashId hash = tokenContract.getId();
    assertTrue(allKeepingIds.stream().anyMatch(id -> Arrays.equals(hash.getDigest(), id)));
    splits.forEach(s -> assertTrue(allKeepingIds.stream().anyMatch(id -> Arrays.equals(s.getId().getDigest(), id))));
    // check getContract with limit
    result = client.getContract(origin, 10);
    List<byte[]> keepingIds = result.getListOrThrow("contractIds");
    assertFalse(result.containsKey("packedContract"));
    assertEquals(keepingIds.size(), 10);
    assertTrue(keepingIds.stream().anyMatch(id -> Arrays.equals(hash.getDigest(), id)));
    for (int i = splits.size() - 1; i > splits.size() - 10; i--) {
        final HashId hashSplit = splits.get(i).getId();
        assertTrue(keepingIds.stream().anyMatch(id -> Arrays.equals(hashSplit.getDigest(), id)));
    }
    // set limit in node config
    mm.forEach(x -> x.config.setQueryContractsLimit(20));
    // check getContract (default limit 100)
    result = client.getContract(origin);
    keepingIds = result.getListOrThrow("contractIds");
    assertFalse(result.containsKey("packedContract"));
    assertEquals(keepingIds.size(), 20);
    assertTrue(keepingIds.stream().anyMatch(id -> Arrays.equals(hash.getDigest(), id)));
    for (int i = splits.size() - 1; i > splits.size() - 20; i--) {
        final HashId hashSplit = splits.get(i).getId();
        assertTrue(keepingIds.stream().anyMatch(id -> Arrays.equals(hashSplit.getDigest(), id)));
    }
    // check getContract with limit
    result = client.getContract(origin, 30);
    keepingIds = result.getListOrThrow("contractIds");
    assertFalse(result.containsKey("packedContract"));
    assertEquals(keepingIds.size(), 20);
    assertTrue(keepingIds.stream().anyMatch(id -> Arrays.equals(hash.getDigest(), id)));
    for (int i = splits.size() - 1; i > splits.size() - 20; i--) {
        final HashId hashSplit = splits.get(i).getId();
        assertTrue(keepingIds.stream().anyMatch(id -> Arrays.equals(hashSplit.getDigest(), id)));
    }
    mm.forEach(x -> x.shutdown());
}
Also used : ZonedDateTime(java.time.ZonedDateTime) SecureLoanHelper(com.icodici.universa.contract.helpers.SecureLoanHelper) TimeoutException(java.util.concurrent.TimeoutException) BigDecimal(java.math.BigDecimal) com.icodici.universa.contract.permissions(com.icodici.universa.contract.permissions) java.net(java.net) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) BossBiMapper(net.sergeych.biserializer.BossBiMapper) Arrays.asList(java.util.Arrays.asList) After(org.junit.After) Duration(java.time.Duration) Path(java.nio.file.Path) Role(com.icodici.universa.contract.roles.Role) LogPrinter(net.sergeych.utils.LogPrinter) ListRole(com.icodici.universa.contract.roles.ListRole) com.icodici.universa.contract.services(com.icodici.universa.contract.services) PreparedStatement(java.sql.PreparedStatement) Instant(java.time.Instant) Collectors(java.util.stream.Collectors) DbPool(com.icodici.db.DbPool) ZoneId(java.time.ZoneId) EncryptionError(com.icodici.crypto.EncryptionError) MatcherAssert(org.hamcrest.MatcherAssert) Crc32(com.icodici.crypto.digest.Crc32) PooledDb(com.icodici.db.PooledDb) Compound(com.icodici.universa.contract.helpers.Compound) EscrowHelper(com.icodici.universa.contract.helpers.EscrowHelper) Matchers.is(org.hamcrest.Matchers.is) DateTimeFormatterBuilder(java.time.format.DateTimeFormatterBuilder) ChronoField(java.time.temporal.ChronoField) NonNull(org.checkerframework.checker.nullness.qual.NonNull) java.util(java.util) com.icodici.universa.node(com.icodici.universa.node) net.sergeych.tools(net.sergeych.tools) SimpleRole(com.icodici.universa.contract.roles.SimpleRole) PublicKey(com.icodici.crypto.PublicKey) com.icodici.universa.contract(com.icodici.universa.contract) com.icodici.universa.node2.network(com.icodici.universa.node2.network) MatcherAssert.assertThat(org.hamcrest.MatcherAssert.assertThat) Before(org.junit.Before) PrivateKey(com.icodici.crypto.PrivateKey) Files(java.nio.file.Files) Semaphore(java.util.concurrent.Semaphore) KeyAddress(com.icodici.crypto.KeyAddress) Matchers(org.hamcrest.Matchers) FileOutputStream(java.io.FileOutputStream) Test(org.junit.Test) IOException(java.io.IOException) File(java.io.File) com.icodici.universa(com.icodici.universa) TimeUnit(java.util.concurrent.TimeUnit) Db(com.icodici.db.Db) ChronoUnit(java.time.temporal.ChronoUnit) Ignore(org.junit.Ignore) Paths(java.nio.file.Paths) RoleLink(com.icodici.universa.contract.roles.RoleLink) Assert(org.junit.Assert) Boss(net.sergeych.boss.Boss) PrivateKey(com.icodici.crypto.PrivateKey) PublicKey(com.icodici.crypto.PublicKey) BigDecimal(java.math.BigDecimal) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) Test(org.junit.Test)

Example 27 with Config

use of com.icodici.universa.node2.Config in project ongdb by graphfoundation.

the class BoltCausalClusteringIT method shouldPickANewServerToWriteToOnLeaderSwitch.

@Test
public void shouldPickANewServerToWriteToOnLeaderSwitch() throws Throwable {
    // given
    cluster = clusterRule.withNumberOfReadReplicas(0).startCluster();
    CoreClusterMember leader = cluster.awaitLeader();
    CountDownLatch leaderSwitchLatch = new CountDownLatch(1);
    LeaderSwitcher leaderSwitcher = new LeaderSwitcher(cluster, leaderSwitchLatch);
    Config config = Config.build().withLogging(new JULogging(Level.OFF)).toConfig();
    Set<String> seenAddresses = new HashSet<>();
    try (Driver driver = GraphDatabase.driver(leader.routingURI(), basicAuthToken, config)) {
        boolean success = false;
        long deadline = System.currentTimeMillis() + (30 * 1000);
        while (!success) {
            if (System.currentTimeMillis() > deadline) {
                fail("Failed to write to the new leader in time. Addresses seen: " + seenAddresses);
            }
            try (Session session = driver.session(AccessMode.WRITE)) {
                StatementResult result = session.run("CREATE (p:Person)");
                ServerInfo server = result.summary().server();
                seenAddresses.add(server.address());
                success = seenAddresses.size() >= 2;
            } catch (Exception e) {
                Thread.sleep(100);
            }
            /*
                 * Having the latch release here ensures that we've done at least one pass through the loop, which means
                 * we've completed a connection before the forced master switch.
                 */
            if (!seenAddresses.isEmpty() && !success) {
                leaderSwitcher.start();
                leaderSwitchLatch.await();
            }
        }
    } finally {
        leaderSwitcher.stop();
        assertTrue(leaderSwitcher.hadLeaderSwitch());
        assertThat(seenAddresses.size(), greaterThanOrEqualTo(2));
    }
    cluster.shutdown();
}
Also used : StatementResult(org.neo4j.driver.v1.StatementResult) CoreClusterMember(org.neo4j.causalclustering.discovery.CoreClusterMember) Config(org.neo4j.driver.v1.Config) ServerInfo(org.neo4j.driver.v1.summary.ServerInfo) Driver(org.neo4j.driver.v1.Driver) CountDownLatch(java.util.concurrent.CountDownLatch) TimeoutException(java.util.concurrent.TimeoutException) SessionExpiredException(org.neo4j.driver.v1.exceptions.SessionExpiredException) ServiceUnavailableException(org.neo4j.driver.v1.exceptions.ServiceUnavailableException) IOException(java.io.IOException) ClientException(org.neo4j.driver.v1.exceptions.ClientException) JULogging(org.neo4j.driver.internal.logging.JULogging) HashSet(java.util.HashSet) Session(org.neo4j.driver.v1.Session) Test(org.junit.Test)

Example 28 with Config

use of com.icodici.universa.node2.Config 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);
}
Also used : DeviceActionFactory(org.opendaylight.netconf.sal.connect.api.DeviceActionFactory) SchemaResourceManager(org.opendaylight.netconf.sal.connect.api.SchemaResourceManager) ThreadPool(org.opendaylight.controller.config.threadpool.ThreadPool) ServiceGroupIdentifier(org.opendaylight.mdsal.singleton.common.api.ServiceGroupIdentifier) ConfigBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.topology.singleton.config.rev170419.ConfigBuilder) GetTopOutputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.GetTopOutputBuilder) Mockito.doAnswer(org.mockito.Mockito.doAnswer) Map(java.util.Map) MapNode(org.opendaylight.yangtools.yang.data.api.schema.MapNode) DOMActionProviderService(org.opendaylight.mdsal.dom.api.DOMActionProviderService) PutTopInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.PutTopInputBuilder) YangInstanceIdentifier(org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier) Mockito.doReturn(org.mockito.Mockito.doReturn) ContainerNode(org.opendaylight.yangtools.yang.data.api.schema.ContainerNode) NodeBuilder(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.NodeBuilder) DOMActionService(org.opendaylight.mdsal.dom.api.DOMActionService) DOMDataTreeReadOperations(org.opendaylight.mdsal.dom.api.DOMDataTreeReadOperations) Awaitility.await(org.awaitility.Awaitility.await) Module(org.opendaylight.yangtools.yang.model.api.Module) ActorSystemProvider(org.opendaylight.controller.cluster.ActorSystemProvider) Set(java.util.Set) DOMRpcIdentifier(org.opendaylight.mdsal.dom.api.DOMRpcIdentifier) NetworkTopology(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NetworkTopology) FluentFutures(org.opendaylight.yangtools.util.concurrent.FluentFutures) NetconfNodeConnectionStatus(org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.NetconfNodeConnectionStatus) Top(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.Top) Assert.assertFalse(org.junit.Assert.assertFalse) PotentialSchemaSource(org.opendaylight.yangtools.yang.model.repo.spi.PotentialSchemaSource) NetconfSessionPreferences(org.opendaylight.netconf.sal.connect.netconf.listener.NetconfSessionPreferences) MapEntryNode(org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode) MockitoJUnitRunner(org.mockito.junit.MockitoJUnitRunner) Mockito.mock(org.mockito.Mockito.mock) EventExecutor(io.netty.util.concurrent.EventExecutor) YangTextSchemaSource(org.opendaylight.yangtools.yang.model.repo.api.YangTextSchemaSource) Mock(org.mockito.Mock) TransactionChainListener(org.opendaylight.mdsal.binding.api.TransactionChainListener) RpcDefinition(org.opendaylight.yangtools.yang.model.api.RpcDefinition) RunWith(org.junit.runner.RunWith) DOMMountPointService(org.opendaylight.mdsal.dom.api.DOMMountPointService) Mockito.spy(org.mockito.Mockito.spy) Timeout(akka.util.Timeout) ArrayList(java.util.ArrayList) ClusterSingletonServiceRegistration(org.opendaylight.mdsal.singleton.common.api.ClusterSingletonServiceRegistration) Mockito.timeout(org.mockito.Mockito.timeout) Lists(com.google.common.collect.Lists) DefaultDOMRpcResult(org.opendaylight.mdsal.dom.spi.DefaultDOMRpcResult) Host(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Host) DOMRpcResult(org.opendaylight.mdsal.dom.api.DOMRpcResult) GetTopInput(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.GetTopInput) Before(org.junit.Before) ReconnectFuture(org.opendaylight.netconf.nettyutil.ReconnectFuture) Node(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node) EmptyMountPointContext(org.opendaylight.yangtools.rfc8528.data.util.EmptyMountPointContext) WriteTransaction(org.opendaylight.mdsal.binding.api.WriteTransaction) Keystore(org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.keystore.rev171017.Keystore) Assert.assertTrue(org.junit.Assert.assertTrue) FileUtils(org.apache.commons.io.FileUtils) Test(org.junit.Test) TopLevelListKey(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.two.level.list.TopLevelListKey) DOMRpcRouter(org.opendaylight.mdsal.dom.broker.DOMRpcRouter) NetconfMessageTransformUtil(org.opendaylight.netconf.sal.connect.netconf.util.NetconfMessageTransformUtil) File(java.io.File) QName(org.opendaylight.yangtools.yang.common.QName) ExecutionException(java.util.concurrent.ExecutionException) Topology(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.Topology) Mockito.never(org.mockito.Mockito.never) Futures(com.google.common.util.concurrent.Futures) NetconfTopologyUtils(org.opendaylight.netconf.topology.singleton.impl.utils.NetconfTopologyUtils) Assert.assertNull(org.junit.Assert.assertNull) InstanceIdentifier(org.opendaylight.yangtools.yang.binding.InstanceIdentifier) RpcProviderService(org.opendaylight.mdsal.binding.api.RpcProviderService) RevisionSourceIdentifier(org.opendaylight.yangtools.yang.model.repo.api.RevisionSourceIdentifier) LogicalDatastoreType(org.opendaylight.mdsal.common.api.LogicalDatastoreType) IpAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress) KeyedInstanceIdentifier(org.opendaylight.yangtools.yang.binding.KeyedInstanceIdentifier) DOMRpcProviderService(org.opendaylight.mdsal.dom.api.DOMRpcProviderService) Assert.assertEquals(org.junit.Assert.assertEquals) RpcError(org.opendaylight.yangtools.yang.common.RpcError) DataBroker(org.opendaylight.mdsal.binding.api.DataBroker) DefaultSchemaResourceManager(org.opendaylight.netconf.sal.connect.impl.DefaultSchemaResourceManager) DOMDataTreeWriteTransaction(org.opendaylight.mdsal.dom.api.DOMDataTreeWriteTransaction) ClusteringRpcException(org.opendaylight.netconf.topology.singleton.impl.utils.ClusteringRpcException) TopologyNetconf(org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.network.topology.topology.topology.types.TopologyNetconf) Config(org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.topology.singleton.config.rev170419.Config) BindingReflections(org.opendaylight.mdsal.binding.spec.reflect.BindingReflections) LoggerFactory(org.slf4j.LoggerFactory) TimeoutException(java.util.concurrent.TimeoutException) SettableFuture(com.google.common.util.concurrent.SettableFuture) AbstractConcurrentDataBrokerTest(org.opendaylight.mdsal.binding.dom.adapter.test.AbstractConcurrentDataBrokerTest) GlobalEventExecutor(io.netty.util.concurrent.GlobalEventExecutor) NetconfNode(org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.NetconfNode) ReadTransaction(org.opendaylight.mdsal.binding.api.ReadTransaction) NetconfNodeBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.NetconfNodeBuilder) After(org.junit.After) Assert.fail(org.junit.Assert.fail) BindingNormalizedNodeSerializer(org.opendaylight.mdsal.binding.dom.codec.api.BindingNormalizedNodeSerializer) LoginPasswordUnencryptedBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.netconf.node.credentials.credentials.login.pw.unencrypted.LoginPasswordUnencryptedBuilder) DOMDataTreeReadWriteTransaction(org.opendaylight.mdsal.dom.api.DOMDataTreeReadWriteTransaction) Ipv4Address(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address) LoginPwUnencryptedBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.netconf.node.credentials.credentials.LoginPwUnencryptedBuilder) DefaultYangParserFactory(org.opendaylight.yangtools.yang.parser.impl.DefaultYangParserFactory) NetconfTopologySetup(org.opendaylight.netconf.topology.singleton.impl.utils.NetconfTopologySetup) ImmutableSet(com.google.common.collect.ImmutableSet) ImmutableMap(com.google.common.collect.ImmutableMap) Uint16(org.opendaylight.yangtools.yang.common.Uint16) NetconfClientDispatcher(org.opendaylight.netconf.client.NetconfClientDispatcher) TransactionChain(org.opendaylight.mdsal.binding.api.TransactionChain) DOMDataBroker(org.opendaylight.mdsal.dom.api.DOMDataBroker) PortNumber(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.PortNumber) ImmutableNodes(org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes) ActorSystem(akka.actor.ActorSystem) Entry(java.util.Map.Entry) Optional(java.util.Optional) TopLevelListBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.two.level.list.TopLevelListBuilder) DOMService(org.opendaylight.mdsal.dom.api.DOMService) ArgumentMatchers.any(org.mockito.ArgumentMatchers.any) MoreExecutors(com.google.common.util.concurrent.MoreExecutors) ListenableFuture(com.google.common.util.concurrent.ListenableFuture) DataTreeIdentifier(org.opendaylight.mdsal.binding.api.DataTreeIdentifier) DOMRpcImplementation(org.opendaylight.mdsal.dom.api.DOMRpcImplementation) TopLevelList(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.two.level.list.TopLevelList) ErrorType(org.opendaylight.yangtools.yang.common.ErrorType) NodeId(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId) ImmutableList(com.google.common.collect.ImmutableList) ScheduledThreadPool(org.opendaylight.controller.config.threadpool.ScheduledThreadPool) DOMMountPointListener(org.opendaylight.mdsal.dom.api.DOMMountPointListener) ConfigFactory(com.typesafe.config.ConfigFactory) DataTreeModification(org.opendaylight.mdsal.binding.api.DataTreeModification) SimpleEntry(java.util.AbstractMap.SimpleEntry) DataObjectModification(org.opendaylight.mdsal.binding.api.DataObjectModification) Builders(org.opendaylight.yangtools.yang.data.impl.schema.Builders) DOMClusterSingletonServiceProviderImpl(org.opendaylight.mdsal.singleton.dom.impl.DOMClusterSingletonServiceProviderImpl) BindingRuntimeHelpers(org.opendaylight.mdsal.binding.runtime.spi.BindingRuntimeHelpers) ClusterSingletonServiceProvider(org.opendaylight.mdsal.singleton.common.api.ClusterSingletonServiceProvider) Uint32(org.opendaylight.yangtools.yang.common.Uint32) Logger(org.slf4j.Logger) Iterator(java.util.Iterator) ErrorTag(org.opendaylight.yangtools.yang.common.ErrorTag) Assert.assertNotNull(org.junit.Assert.assertNotNull) DOMRpcService(org.opendaylight.mdsal.dom.api.DOMRpcService) TestKit(akka.testkit.javadsl.TestKit) EffectiveModelContext(org.opendaylight.yangtools.yang.model.api.EffectiveModelContext) Transaction(org.opendaylight.mdsal.binding.api.Transaction) Mockito.verify(org.mockito.Mockito.verify) TimeUnit(java.util.concurrent.TimeUnit) YangModuleInfo(org.opendaylight.yangtools.yang.binding.YangModuleInfo) AAAEncryptionService(org.opendaylight.aaa.encrypt.AAAEncryptionService) DOMMountPoint(org.opendaylight.mdsal.dom.api.DOMMountPoint) SchemaResourcesDTO(org.opendaylight.netconf.sal.connect.netconf.NetconfDevice.SchemaResourcesDTO) DOMMountPointServiceImpl(org.opendaylight.mdsal.dom.broker.DOMMountPointServiceImpl) RpcResultBuilder(org.opendaylight.yangtools.yang.common.RpcResultBuilder) NodeKey(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.NodeKey) NormalizedNode(org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode) FluentFuture(com.google.common.util.concurrent.FluentFuture) YangTextSchemaSource(org.opendaylight.yangtools.yang.model.repo.api.YangTextSchemaSource) NetconfNodeBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.NetconfNodeBuilder) Timeout(akka.util.Timeout) DeviceActionFactory(org.opendaylight.netconf.sal.connect.api.DeviceActionFactory) SchemaResourcesDTO(org.opendaylight.netconf.sal.connect.netconf.NetconfDevice.SchemaResourcesDTO) NetconfTopologySetup(org.opendaylight.netconf.topology.singleton.impl.utils.NetconfTopologySetup) DOMClusterSingletonServiceProviderImpl(org.opendaylight.mdsal.singleton.dom.impl.DOMClusterSingletonServiceProviderImpl) ServiceGroupIdentifier(org.opendaylight.mdsal.singleton.common.api.ServiceGroupIdentifier) AbstractConcurrentDataBrokerTest(org.opendaylight.mdsal.binding.dom.adapter.test.AbstractConcurrentDataBrokerTest)

Example 29 with Config

use of com.icodici.universa.node2.Config 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());
}
Also used : RpcProviderService(org.opendaylight.mdsal.binding.api.RpcProviderService) DOMRpcProviderService(org.opendaylight.mdsal.dom.api.DOMRpcProviderService) Config(org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.topology.singleton.config.rev170419.Config) ThreadPool(org.opendaylight.controller.config.threadpool.ThreadPool) ScheduledThreadPool(org.opendaylight.controller.config.threadpool.ScheduledThreadPool) DOMMountPointService(org.opendaylight.mdsal.dom.api.DOMMountPointService) DeviceActionFactory(org.opendaylight.netconf.sal.connect.api.DeviceActionFactory) DefaultYangParserFactory(org.opendaylight.yangtools.yang.parser.impl.DefaultYangParserFactory) ActorSystemProvider(org.opendaylight.controller.cluster.ActorSystemProvider) ScheduledThreadPool(org.opendaylight.controller.config.threadpool.ScheduledThreadPool) AAAEncryptionService(org.opendaylight.aaa.encrypt.AAAEncryptionService) ConfigBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.topology.singleton.config.rev170419.ConfigBuilder) ServiceGroupIdentifier(org.opendaylight.mdsal.singleton.common.api.ServiceGroupIdentifier) DefaultSchemaResourceManager(org.opendaylight.netconf.sal.connect.impl.DefaultSchemaResourceManager) AbstractDataBrokerTest(org.opendaylight.mdsal.binding.dom.adapter.test.AbstractDataBrokerTest) Timeout(akka.util.Timeout) NetworkTopology(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NetworkTopology) Topology(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.Topology) DOMRpcProviderService(org.opendaylight.mdsal.dom.api.DOMRpcProviderService) DOMActionProviderService(org.opendaylight.mdsal.dom.api.DOMActionProviderService) NetconfTopologySetup(org.opendaylight.netconf.topology.singleton.impl.utils.NetconfTopologySetup) YangModuleInfo(org.opendaylight.yangtools.yang.binding.YangModuleInfo) EventExecutor(io.netty.util.concurrent.EventExecutor) NetworkTopology(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NetworkTopology) ExecutorService(java.util.concurrent.ExecutorService) NetconfClientDispatcher(org.opendaylight.netconf.client.NetconfClientDispatcher) Before(org.junit.Before)

Example 30 with Config

use of com.icodici.universa.node2.Config in project kubernetes-client by fabric8io.

the class ImageRegistryOperatorConfigTest method get.

@Test
void get() throws ParseException {
    // Given
    server.expect().get().withPath("/apis/imageregistry.operator.openshift.io/v1/configs/test-get").andReturn(HttpURLConnection.HTTP_OK, createNewConfig("test-get")).once();
    // When
    Config Config = client.imageRegistryOperatorConfigs().withName("test-get").get();
    // Then
    assertThat(Config).isNotNull().hasFieldOrPropertyWithValue("metadata.name", "test-get");
}
Also used : Config(io.fabric8.openshift.api.model.miscellaneous.imageregistry.operator.v1.Config) Test(org.junit.jupiter.api.Test)

Aggregations

Config (sun.security.krb5.Config)8 Test (org.junit.Test)7 IOException (java.io.IOException)6 Config (simplelibrary.config2.Config)6 KeyAddress (com.icodici.crypto.KeyAddress)5 File (java.io.File)5 TimeoutException (java.util.concurrent.TimeoutException)4 Before (org.junit.Before)3 Timeout (akka.util.Timeout)2 PrivateKey (com.icodici.crypto.PrivateKey)2 com.icodici.universa.contract (com.icodici.universa.contract)2 QuorumVoteRole (com.icodici.universa.contract.roles.QuorumVoteRole)2 com.icodici.universa.contract.services (com.icodici.universa.contract.services)2 Config (com.icodici.universa.node2.Config)2 EventExecutor (io.netty.util.concurrent.EventExecutor)2 ByteArrayOutputStream (java.io.ByteArrayOutputStream)2 ZonedDateTime (java.time.ZonedDateTime)2 java.util (java.util)2 HashSet (java.util.HashSet)2 java.util.concurrent (java.util.concurrent)2