use of com.datastax.oss.driver.api.core.InvalidKeyspaceException in project java-driver by datastax.
the class ChannelPoolInitTest method should_indicate_when_keyspace_failed_on_all_channels.
@Test
public void should_indicate_when_keyspace_failed_on_all_channels() {
when(defaultProfile.getInt(DefaultDriverOption.CONNECTION_POOL_LOCAL_SIZE)).thenReturn(3);
MockChannelFactoryHelper factoryHelper = MockChannelFactoryHelper.builder(channelFactory).failure(node, new InvalidKeyspaceException("invalid keyspace")).failure(node, new InvalidKeyspaceException("invalid keyspace")).failure(node, new InvalidKeyspaceException("invalid keyspace")).build();
CompletionStage<ChannelPool> poolFuture = ChannelPool.init(node, null, NodeDistance.LOCAL, context, "test");
factoryHelper.waitForCalls(node, 3);
assertThatStage(poolFuture).isSuccess(pool -> {
assertThat(pool.isInvalidKeyspace()).isTrue();
verify(nodeMetricUpdater, VERIFY_TIMEOUT.times(3)).incrementCounter(DefaultNodeMetric.CONNECTION_INIT_ERRORS, null);
});
}
use of com.datastax.oss.driver.api.core.InvalidKeyspaceException in project java-driver by datastax.
the class SessionLeakIT method should_never_warn_when_session_init_fails.
@Test
public void should_never_warn_when_session_init_fails() {
SIMULACRON_RULE.cluster().prime(PrimeDsl.when("USE \"non_existent_keyspace\"").then(PrimeDsl.invalid("irrelevant")));
int threshold = 4;
// Set the config option explicitly, in case it gets overridden in the test application.conf:
DriverConfigLoader configLoader = DriverConfigLoader.programmaticBuilder().withInt(DefaultDriverOption.SESSION_LEAK_THRESHOLD, threshold).build();
// Go over the threshold, no warnings expected
for (int i = 0; i < threshold + 1; i++) {
try (Session session = SessionUtils.newSession(SIMULACRON_RULE, CqlIdentifier.fromCql("non_existent_keyspace"), configLoader)) {
fail("Session %s should have failed to initialize", session.getName());
} catch (InvalidKeyspaceException e) {
assertThat(e.getMessage()).isEqualTo("Invalid keyspace non_existent_keyspace");
}
}
verify(appender, never()).doAppend(any());
}
Aggregations