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