Search in sources :

Example 11 with TestNodeConfig

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

the class MicrometerMeterIntegrationTest method beforeAll.

@BeforeAll
static void beforeAll() {
    TestNodeConfig config = config().firstNodeWith(Services.KV).get();
    meterRegistry = new SimpleMeterRegistry();
    cluster = Cluster.connect(String.format("couchbase://%s:%d", config.hostname(), config.ports().get(Services.KV)), clusterOptions(config().adminUsername(), config().adminPassword()).environment(env -> env.meter(MicrometerMeter.wrap(meterRegistry))));
    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) SimpleMeterRegistry(io.micrometer.core.instrument.simple.SimpleMeterRegistry) BeforeAll(org.junit.jupiter.api.BeforeAll)

Example 12 with TestNodeConfig

use of com.couchbase.client.test.TestNodeConfig 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);
}
Also used : NoopRequest(com.couchbase.client.core.msg.kv.NoopRequest) NoopResponse(com.couchbase.client.core.msg.kv.NoopResponse) TestNodeConfig(com.couchbase.client.test.TestNodeConfig) CoreIntegrationTest(com.couchbase.client.core.util.CoreIntegrationTest) Test(org.junit.jupiter.api.Test)

Example 13 with TestNodeConfig

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

the class GlobalBucketRefresherIntegrationTest method loadGlobalConfig.

/**
 * Not related, but to test the refresh we first need to load the global config and prime the config provider.
 */
private void loadGlobalConfig(final ConfigurationProvider provider) {
    TestNodeConfig config = config().firstNodeWith(Services.KV).get();
    GlobalLoader loader = new GlobalLoader(core);
    ProposedGlobalConfigContext globalConfigContext = loader.load(new NodeIdentifier(config.hostname(), config.ports().get(Services.MANAGER)), config.ports().get(Services.KV)).block();
    provider.proposeGlobalConfig(globalConfigContext);
}
Also used : GlobalLoader(com.couchbase.client.core.config.loader.GlobalLoader) TestNodeConfig(com.couchbase.client.test.TestNodeConfig) ProposedGlobalConfigContext(com.couchbase.client.core.config.ProposedGlobalConfigContext) NodeIdentifier(com.couchbase.client.core.node.NodeIdentifier)

Example 14 with TestNodeConfig

use of com.couchbase.client.test.TestNodeConfig 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);
}
Also used : NoopRequest(com.couchbase.client.core.msg.kv.NoopRequest) NoopResponse(com.couchbase.client.core.msg.kv.NoopResponse) TestNodeConfig(com.couchbase.client.test.TestNodeConfig) CoreIntegrationTest(com.couchbase.client.core.util.CoreIntegrationTest) Test(org.junit.jupiter.api.Test)

Example 15 with TestNodeConfig

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

the class ManagerEndpointIntegrationTest method beforeEach.

@BeforeEach
void beforeEach() {
    TestNodeConfig node = config().nodes().get(0);
    env = CoreEnvironment.create();
    serviceContext = new ServiceContext(new CoreContext(null, 1, env, PasswordAuthenticator.create(config().adminUsername(), config().adminPassword())), node.hostname(), node.ports().get(Services.MANAGER), ServiceType.MANAGER, Optional.empty());
}
Also used : CoreContext(com.couchbase.client.core.CoreContext) ServiceContext(com.couchbase.client.core.service.ServiceContext) TestNodeConfig(com.couchbase.client.test.TestNodeConfig) BeforeEach(org.junit.jupiter.api.BeforeEach)

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