Search in sources :

Example 16 with TestNodeConfig

use of com.couchbase.client.test.TestNodeConfig in project couchbase-jvm-clients by couchbase.

the class ManagerEndpointIntegrationTest method fetchTerseConfig.

/**
 * This integration test attempts to load a "terse" bucket config from the cluster manager.
 *
 * <p>Note that the actual response is not checked here, since this handles at the higher levels. We just make sure
 * that the config returned is not empty.</p>
 */
@Test
void fetchTerseConfig() throws Exception {
    TestNodeConfig node = config().nodes().get(0);
    ManagerEndpoint endpoint = new ManagerEndpoint(serviceContext, node.hostname(), node.ports().get(Services.MANAGER));
    endpoint.connect();
    waitUntilCondition(() -> endpoint.state() == EndpointState.CONNECTED);
    BucketConfigRequest request = new BucketConfigRequest(Duration.ofSeconds(1), serviceContext, null, config().bucketname(), serviceContext.authenticator(), null);
    assertTrue(request.id() > 0);
    endpoint.send(request);
    BucketConfigResponse response = request.response().get(1, TimeUnit.SECONDS);
    assertTrue(response.status().success());
    assertTrue(response.config().length > 0);
    endpoint.disconnect();
    waitUntilCondition(() -> endpoint.state() == EndpointState.DISCONNECTED);
}
Also used : TestNodeConfig(com.couchbase.client.test.TestNodeConfig) BucketConfigResponse(com.couchbase.client.core.msg.manager.BucketConfigResponse) BucketConfigRequest(com.couchbase.client.core.msg.manager.BucketConfigRequest) ClusterAwareIntegrationTest(com.couchbase.client.test.ClusterAwareIntegrationTest) Test(org.junit.jupiter.api.Test)

Example 17 with TestNodeConfig

use of com.couchbase.client.test.TestNodeConfig in project couchbase-jvm-clients by couchbase.

the class KeyValueChannelIntegrationTest method failWithInvalidUsernameCredential.

@Test
@IgnoreWhen(clusterTypes = ClusterType.MOCKED)
void failWithInvalidUsernameCredential() throws Exception {
    TestNodeConfig node = config().nodes().get(0);
    Bootstrap bootstrap = new Bootstrap().remoteAddress(node.hostname(), node.ports().get(Services.KV)).group(eventLoopGroup).channel(NioSocketChannel.class).handler(new ChannelInitializer<SocketChannel>() {

        @Override
        protected void initChannel(SocketChannel ch) {
            new KeyValueEndpoint.KeyValuePipelineInitializer(endpointContext, Optional.of(config().bucketname()), PasswordAuthenticator.create("vfwmf42343rew", config().adminPassword())).init(null, ch.pipeline());
        }
    });
    assertAuthenticationFailure(bootstrap, "Authentication Failure");
}
Also used : NioSocketChannel(com.couchbase.client.core.deps.io.netty.channel.socket.nio.NioSocketChannel) SocketChannel(com.couchbase.client.core.deps.io.netty.channel.socket.SocketChannel) NioSocketChannel(com.couchbase.client.core.deps.io.netty.channel.socket.nio.NioSocketChannel) TestNodeConfig(com.couchbase.client.test.TestNodeConfig) Bootstrap(com.couchbase.client.core.deps.io.netty.bootstrap.Bootstrap) IgnoreWhen(com.couchbase.client.test.IgnoreWhen) CoreIntegrationTest(com.couchbase.client.core.util.CoreIntegrationTest) Test(org.junit.jupiter.api.Test)

Example 18 with TestNodeConfig

use of com.couchbase.client.test.TestNodeConfig in project couchbase-jvm-clients by couchbase.

the class KeyValueChannelIntegrationTest method beforeAll.

@BeforeAll
static void beforeAll() {
    TestNodeConfig node = config().nodes().get(0);
    env = environment().eventBus(eventBus).build();
    Core core = Core.create(env, authenticator(), seedNodes());
    endpointContext = new EndpointContext(core.context(), new HostAndPort(node.hostname(), node.ports().get(Services.KV)), null, ServiceType.KV, Optional.empty(), Optional.of(config().bucketname()), Optional.empty());
    eventLoopGroup = new NioEventLoopGroup(1);
}
Also used : HostAndPort(com.couchbase.client.core.util.HostAndPort) EndpointContext(com.couchbase.client.core.endpoint.EndpointContext) TestNodeConfig(com.couchbase.client.test.TestNodeConfig) NioEventLoopGroup(com.couchbase.client.core.deps.io.netty.channel.nio.NioEventLoopGroup) Core(com.couchbase.client.core.Core) BeforeAll(org.junit.jupiter.api.BeforeAll)

Example 19 with TestNodeConfig

use of com.couchbase.client.test.TestNodeConfig in project couchbase-jvm-clients by couchbase.

the class KeyValueChannelIntegrationTest method connectNoopAndDisconnect.

/**
 * This is the most simple kv test case one can do in a full-stack manner.
 *
 * <p>It connects to a kv socket, including all auth and bucket selection. It then
 * checks that the channel is opened properly and performs a NOOP and checks for a
 * successful result. Then it shuts everything down.</p>
 *
 * @throws Exception if waiting on the response fails.
 */
@Test
void connectNoopAndDisconnect() throws Exception {
    TestNodeConfig node = config().nodes().get(0);
    Bootstrap bootstrap = new Bootstrap().remoteAddress(node.hostname(), node.ports().get(Services.KV)).group(eventLoopGroup).channel(NioSocketChannel.class).handler(new ChannelInitializer<SocketChannel>() {

        @Override
        protected void initChannel(SocketChannel ch) {
            new KeyValueEndpoint.KeyValuePipelineInitializer(endpointContext, Optional.of(config().bucketname()), endpointContext.authenticator()).init(null, ch.pipeline());
        }
    });
    Channel channel = bootstrap.connect().awaitUninterruptibly().channel();
    assertTrue(channel.isActive());
    assertTrue(channel.isOpen());
    NoopRequest request = new NoopRequest(Duration.ZERO, endpointContext, null, CollectionIdentifier.fromDefault(config().bucketname()));
    channel.writeAndFlush(request);
    NoopResponse response = request.response().get(1, TimeUnit.SECONDS);
    assertTrue(response.status().success());
    channel.close().awaitUninterruptibly();
}
Also used : NioSocketChannel(com.couchbase.client.core.deps.io.netty.channel.socket.nio.NioSocketChannel) NoopRequest(com.couchbase.client.core.msg.kv.NoopRequest) NoopResponse(com.couchbase.client.core.msg.kv.NoopResponse) SocketChannel(com.couchbase.client.core.deps.io.netty.channel.socket.SocketChannel) NioSocketChannel(com.couchbase.client.core.deps.io.netty.channel.socket.nio.NioSocketChannel) TestNodeConfig(com.couchbase.client.test.TestNodeConfig) SocketChannel(com.couchbase.client.core.deps.io.netty.channel.socket.SocketChannel) Channel(com.couchbase.client.core.deps.io.netty.channel.Channel) NioSocketChannel(com.couchbase.client.core.deps.io.netty.channel.socket.nio.NioSocketChannel) Bootstrap(com.couchbase.client.core.deps.io.netty.bootstrap.Bootstrap) CoreIntegrationTest(com.couchbase.client.core.util.CoreIntegrationTest) Test(org.junit.jupiter.api.Test)

Example 20 with TestNodeConfig

use of com.couchbase.client.test.TestNodeConfig in project couchbase-jvm-clients by couchbase.

the class KeyValueChannelIntegrationTest method failWithInvalidBucketCredential.

@Test
void failWithInvalidBucketCredential() throws Exception {
    String bucketName = "42eredwefrfe";
    TestNodeConfig node = config().nodes().get(0);
    Bootstrap bootstrap = new Bootstrap().remoteAddress(node.hostname(), node.ports().get(Services.KV)).group(eventLoopGroup).channel(NioSocketChannel.class).handler(new ChannelInitializer<SocketChannel>() {

        @Override
        protected void initChannel(SocketChannel ch) {
            new KeyValueEndpoint.KeyValuePipelineInitializer(endpointContext, Optional.of(bucketName), endpointContext.authenticator()).init(null, ch.pipeline());
        }
    });
    assertAuthenticationFailure(bootstrap, "Either the bucket with name \"" + bucketName + "\" is not present " + "or the user does not have the right privileges to access it");
}
Also used : NioSocketChannel(com.couchbase.client.core.deps.io.netty.channel.socket.nio.NioSocketChannel) SocketChannel(com.couchbase.client.core.deps.io.netty.channel.socket.SocketChannel) NioSocketChannel(com.couchbase.client.core.deps.io.netty.channel.socket.nio.NioSocketChannel) TestNodeConfig(com.couchbase.client.test.TestNodeConfig) Bootstrap(com.couchbase.client.core.deps.io.netty.bootstrap.Bootstrap) CoreIntegrationTest(com.couchbase.client.core.util.CoreIntegrationTest) Test(org.junit.jupiter.api.Test)

Aggregations

TestNodeConfig (com.couchbase.client.test.TestNodeConfig)25 Test (org.junit.jupiter.api.Test)16 CoreIntegrationTest (com.couchbase.client.core.util.CoreIntegrationTest)15 Core (com.couchbase.client.core.Core)7 IgnoreWhen (com.couchbase.client.test.IgnoreWhen)6 SeedNode (com.couchbase.client.core.env.SeedNode)5 HashSet (java.util.HashSet)5 BeforeAll (org.junit.jupiter.api.BeforeAll)5 Bootstrap (com.couchbase.client.core.deps.io.netty.bootstrap.Bootstrap)4 SocketChannel (com.couchbase.client.core.deps.io.netty.channel.socket.SocketChannel)4 NioSocketChannel (com.couchbase.client.core.deps.io.netty.channel.socket.nio.NioSocketChannel)4 NodeIdentifier (com.couchbase.client.core.node.NodeIdentifier)4 CountDownLatch (java.util.concurrent.CountDownLatch)4 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)4 CoreContext (com.couchbase.client.core.CoreContext)3 Event (com.couchbase.client.core.cnc.Event)3 SimpleEventBus (com.couchbase.client.core.cnc.SimpleEventBus)3 BucketOpenRetriedEvent (com.couchbase.client.core.cnc.events.config.BucketOpenRetriedEvent)3 EndpointConnectionFailedEvent (com.couchbase.client.core.cnc.events.endpoint.EndpointConnectionFailedEvent)3 CoreEnvironment (com.couchbase.client.core.env.CoreEnvironment)3