Search in sources :

Example 6 with TestNodeConfig

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

the class ViewEndpointIntegrationTest method dispatchGenericRequest.

/**
 * Makes sure that we can execute a generic view management request.
 *
 * <p>The mock does not support hitting the / path for views, so this test is ignored there.</p>
 */
@Test
@IgnoreWhen(clusterTypes = ClusterType.MOCKED)
void dispatchGenericRequest() throws Exception {
    TestNodeConfig node = config().nodes().get(0);
    ViewEndpoint endpoint = new ViewEndpoint(serviceContext, node.hostname(), node.ports().get(Services.VIEW));
    endpoint.connect();
    waitUntilCondition(() -> endpoint.state() == EndpointState.CONNECTED);
    CoreHttpRequest request = CoreHttpRequest.builder(CoreCommonOptions.of(Duration.ofSeconds(5), null, null), serviceContext, HttpMethod.GET, CoreHttpPath.path("/"), RequestTarget.views(config().bucketname())).build();
    endpoint.send(request);
    CoreHttpResponse response = request.response().get();
    assertEquals(ResponseStatus.SUCCESS, response.status());
    assertNotNull(response.content());
    assertTrue(response.content().length > 0);
    endpoint.disconnect();
    waitUntilCondition(() -> endpoint.state() == EndpointState.DISCONNECTED);
}
Also used : CoreHttpRequest(com.couchbase.client.core.endpoint.http.CoreHttpRequest) TestNodeConfig(com.couchbase.client.test.TestNodeConfig) CoreHttpResponse(com.couchbase.client.core.endpoint.http.CoreHttpResponse) IgnoreWhen(com.couchbase.client.test.IgnoreWhen) CoreIntegrationTest(com.couchbase.client.core.util.CoreIntegrationTest) Test(org.junit.jupiter.api.Test)

Example 7 with TestNodeConfig

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

the class ViewEndpointIntegrationTest method beforeAll.

@BeforeAll
static void beforeAll() {
    TestNodeConfig node = config().nodes().get(0);
    env = environment().ioConfig(IoConfig.captureTraffic(ServiceType.VIEWS)).build();
    serviceContext = new ServiceContext(new CoreContext(null, 1, env, authenticator()), node.hostname(), node.ports().get(Services.VIEW), ServiceType.VIEWS, Optional.empty());
}
Also used : CoreContext(com.couchbase.client.core.CoreContext) ServiceContext(com.couchbase.client.core.service.ServiceContext) TestNodeConfig(com.couchbase.client.test.TestNodeConfig) BeforeAll(org.junit.jupiter.api.BeforeAll)

Example 8 with TestNodeConfig

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

the class KeyValueChannelIntegrationTest method failWithInvalidPasswordCredential.

@Test
@IgnoreWhen(clusterTypes = ClusterType.MOCKED)
void failWithInvalidPasswordCredential() 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(config().adminUsername(), "djslkfsdfsoufhoshfoishgs")).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 9 with TestNodeConfig

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

the class OpenTelemetryIntegrationTest method beforeAll.

@BeforeAll
static void beforeAll() {
    TestNodeConfig config = config().firstNodeWith(Services.KV).get();
    cluster = Cluster.connect(String.format("couchbase://%s:%d", config.hostname(), config.ports().get(Services.KV)), clusterOptions(config().adminUsername(), config().adminPassword()).environment(env -> env.requestTracer(OpenTelemetryRequestTracer.wrap(otelTesting.getOpenTelemetry()))));
    Bucket bucket = cluster.bucket(config().bucketname());
    collection = bucket.defaultCollection();
    bucket.waitUntilReady(Duration.ofSeconds(30));
}
Also used : Bucket(com.couchbase.client.java.Bucket) TestNodeConfig(com.couchbase.client.test.TestNodeConfig) BeforeAll(org.junit.jupiter.api.BeforeAll)

Example 10 with TestNodeConfig

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

the class OpenTracingIntegrationTest method beforeAll.

@BeforeAll
static void beforeAll() {
    tracer = new MockTracer();
    TestNodeConfig config = config().firstNodeWith(Services.KV).get();
    cluster = Cluster.connect(String.format("couchbase://%s:%d", config.hostname(), config.ports().get(Services.KV)), clusterOptions(config().adminUsername(), config().adminPassword()).environment(env -> env.requestTracer(OpenTracingRequestTracer.wrap(tracer))));
    Bucket bucket = cluster.bucket(config().bucketname());
    collection = bucket.defaultCollection();
    bucket.waitUntilReady(Duration.ofSeconds(30));
}
Also used : Bucket(com.couchbase.client.java.Bucket) TestNodeConfig(com.couchbase.client.test.TestNodeConfig) MockTracer(io.opentracing.mock.MockTracer) BeforeAll(org.junit.jupiter.api.BeforeAll)

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