use of com.couchbase.client.core.msg.kv.NoopRequest in project couchbase-jvm-clients by couchbase.
the class KeyValueServiceIntegrationTest method connectNoopAndDisconnect.
/**
* The most simplistic end-to-end test for a KV service.
*
* <p>This integration test connects to a node and then performs a NOOP and
* waits for a successful response.</p>
*
* @throws Exception if waiting on the response fails.
*/
@Test
void connectNoopAndDisconnect() throws Exception {
TestNodeConfig node = config().nodes().get(0);
KeyValueService service = new KeyValueService(KeyValueServiceConfig.builder().build(), core.context(), node.hostname(), node.ports().get(Services.KV), Optional.of(config().bucketname()), core.context().authenticator());
service.connect();
waitUntilCondition(() -> service.state() == ServiceState.CONNECTED);
NoopRequest request = new NoopRequest(kvTimeout, core.context(), null, CollectionIdentifier.fromDefault(config().bucketname()));
assertTrue(request.id() > 0);
service.send(request);
NoopResponse response = request.response().get(1, TimeUnit.SECONDS);
assertTrue(response.status().success());
assertTrue(request.context().dispatchLatency() > 0);
service.disconnect();
waitUntilCondition(() -> service.state() == ServiceState.DISCONNECTED);
}
use of com.couchbase.client.core.msg.kv.NoopRequest in project couchbase-jvm-clients by couchbase.
the class KeyValueEndpointIntegrationTest method connectNoopAndDisconnect.
/**
* The most simplistic end-to-end test for a KV endpoint.
*
* <p>This integration test connects to a node and then performs a NOOP and
* waits for a successful response.</p>
*
* @throws Exception if waiting on the response fails.
*/
@Test
void connectNoopAndDisconnect() throws Exception {
TestNodeConfig node = config().nodes().get(0);
KeyValueEndpoint endpoint = new KeyValueEndpoint(serviceContext, node.hostname(), node.ports().get(Services.KV), Optional.of(config().bucketname()), authenticator());
endpoint.connect();
waitUntilCondition(() -> endpoint.state() == EndpointState.CONNECTED);
NoopRequest request = new NoopRequest(kvTimeout, serviceContext, null, CollectionIdentifier.fromDefault(config().bucketname()));
assertTrue(request.id() > 0);
endpoint.send(request);
NoopResponse response = request.response().get(1, TimeUnit.SECONDS);
assertTrue(response.status().success());
assertTrue(request.context().dispatchLatency() > 0);
endpoint.disconnect();
waitUntilCondition(() -> endpoint.state() == EndpointState.DISCONNECTED);
}
use of com.couchbase.client.core.msg.kv.NoopRequest 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.core.msg.kv.NoopRequest in project couchbase-jvm-clients by couchbase.
the class ReactorTest method completesWithErrorBeforeSubscription.
@Test
void completesWithErrorBeforeSubscription() {
NoopRequest request = new NoopRequest(Duration.ZERO, mock(RequestContext.class), mock(RetryStrategy.class), mock(CollectionIdentifier.class));
RequestCanceledException exception = mock(RequestCanceledException.class);
request.fail(exception);
Mono<NoopResponse> mono = Reactor.wrap(request, request.response(), true);
StepVerifier verifier = StepVerifier.create(mono).expectError(RequestCanceledException.class);
verifier.verify();
}
use of com.couchbase.client.core.msg.kv.NoopRequest in project couchbase-jvm-clients by couchbase.
the class ReactorTest method noErrorDroppedWhenCancelledViaCompletionException.
@Test
void noErrorDroppedWhenCancelledViaCompletionException() {
AtomicInteger droppedErrors = new AtomicInteger(0);
Hooks.onErrorDropped(v -> {
droppedErrors.incrementAndGet();
});
NoopRequest request = new NoopRequest(Duration.ZERO, mock(RequestContext.class), mock(RetryStrategy.class), mock(CollectionIdentifier.class));
// Because this is a multi-step CompleteableFuture, the RequestCanceledException will be wrapped in a
// CompletionException in the internals. It will be unwrapped by the time it is raised to the app.
Mono<NoopResponse> mono = Reactor.wrap(request, request.response().thenApply(v -> v), true);
Disposable subscriber = mono.subscribe();
StepVerifier verifier = StepVerifier.create(mono).expectError(RequestCanceledException.class);
subscriber.dispose();
verifier.verify();
assertEquals(0, droppedErrors.get());
}
Aggregations