use of com.couchbase.client.test.TestNodeConfig in project couchbase-jvm-clients by couchbase.
the class DefaultConfigurationProviderIntegrationTest method openBucketFromSecondValidSeed.
/**
* Bucket config should also be loaded when the first seed in the list is not available.
*/
@Test
void openBucketFromSecondValidSeed() {
TestNodeConfig cfg = config().firstNodeWith(Services.KV).get();
Set<SeedNode> seeds = new HashSet<>(Arrays.asList(SeedNode.create("1.2.3.4"), SeedNode.create(cfg.hostname(), Optional.of(cfg.ports().get(Services.KV)), Optional.of(cfg.ports().get(Services.MANAGER)))));
SimpleEventBus eventBus = new SimpleEventBus(true);
environment = CoreEnvironment.builder().eventBus(eventBus).build();
core = Core.create(environment, authenticator(), seeds);
String bucketName = config().bucketname();
ConfigurationProvider provider = new DefaultConfigurationProvider(core, seeds);
openAndClose(bucketName, provider);
provider.shutdown().block();
waitUntilCondition(() -> eventBus.publishedEvents().stream().anyMatch(e -> e instanceof EndpointConnectionFailedEvent));
}
use of com.couchbase.client.test.TestNodeConfig in project couchbase-jvm-clients by couchbase.
the class DefaultConfigurationProviderIntegrationTest method performShutdown.
/**
* Perform the shutdown and checks that afterwards the other ops don't work anymore.
*/
@Test
void performShutdown() throws Exception {
TestNodeConfig cfg = config().firstNodeWith(Services.KV).get();
Set<SeedNode> seeds = new HashSet<>(Collections.singletonList(SeedNode.create(cfg.hostname(), Optional.of(cfg.ports().get(Services.KV)), Optional.of(cfg.ports().get(Services.MANAGER)))));
environment = CoreEnvironment.builder().timeoutConfig(TimeoutConfig.kvTimeout(kvTimeout).managementTimeout(managementTimeout)).build();
core = Core.create(environment, authenticator(), seeds);
String bucketName = config().bucketname();
ConfigurationProvider provider = new DefaultConfigurationProvider(core, seeds);
AtomicInteger configEvents = new AtomicInteger(0);
CountDownLatch configsComplete = new CountDownLatch(1);
// ignore initial empty config
provider.configs().skip(1).subscribe((c) -> configEvents.incrementAndGet(), (e) -> {
}, configsComplete::countDown);
assertEquals(0, provider.config().bucketConfigs().size());
provider.openBucket(bucketName).timeout(DEFAULT_TIMEOUT).block();
assertEquals(1, provider.config().bucketConfigs().size());
provider.shutdown().timeout(DEFAULT_TIMEOUT).block();
assertEquals(0, provider.config().bucketConfigs().size());
assertThrows(AlreadyShutdownException.class, () -> provider.shutdown().block());
assertThrows(AlreadyShutdownException.class, () -> provider.openBucket("foo").block());
assertThrows(AlreadyShutdownException.class, () -> provider.closeBucket("foo").block());
assertTrue(configsComplete.await(1, TimeUnit.SECONDS));
assertEquals(3, configEvents.get());
}
use of com.couchbase.client.test.TestNodeConfig in project couchbase-jvm-clients by couchbase.
the class GlobalLoaderIntegrationTest method loadGlobalConfigViaCarrierPublication.
/**
* This is a very simplistic test that makes sure that we can "round trip" in the
* {@link GlobalLoader} by grabbing a JSON decodable config through the full stack.
*/
@Test
void loadGlobalConfigViaCarrierPublication() {
TestNodeConfig config = config().firstNodeWith(Services.KV).get();
Core core = Core.create(env, authenticator(), seedNodes());
GlobalLoader loader = new GlobalLoader(core);
ProposedGlobalConfigContext globalConfigContext = loader.load(new NodeIdentifier(config.hostname(), config.ports().get(Services.MANAGER)), config.ports().get(Services.KV)).block();
assertNotNull(globalConfigContext);
assertNotNull(globalConfigContext.config());
core.shutdown().block();
}
use of com.couchbase.client.test.TestNodeConfig in project couchbase-jvm-clients by couchbase.
the class KeyValueBucketLoaderIntegrationTest method loadConfigViaCarrierPublication.
/**
* This is a very simplistic test that makes sure that we can "round trip" in the
* {@link KeyValueBucketLoader} by grabbing a JSON decodable config through the full stack.
*/
@Test
void loadConfigViaCarrierPublication() {
TestNodeConfig config = config().firstNodeWith(Services.KV).get();
Core core = Core.create(env, authenticator(), seedNodes());
KeyValueBucketLoader loader = new KeyValueBucketLoader(core);
ProposedBucketConfigContext loaded = loader.load(new NodeIdentifier(config.hostname(), config.ports().get(Services.MANAGER)), config.ports().get(Services.KV), config().bucketname(), Optional.empty()).block();
assertNotNull(loaded);
assertEquals(config().bucketname(), loaded.bucketName());
core.shutdown().block();
}
use of com.couchbase.client.test.TestNodeConfig in project couchbase-jvm-clients by couchbase.
the class KeyValueEndpointIntegrationTest method beforeAll.
@BeforeAll
static void beforeAll() {
TestNodeConfig node = config().nodes().get(0);
env = environment().build();
core = Core.create(env, authenticator(), seedNodes());
serviceContext = new ServiceContext(new CoreContext(core, 1, env, authenticator()), node.hostname(), node.ports().get(Services.KV), ServiceType.KV, Optional.empty());
}
Aggregations