use of com.sequenceiq.cloudbreak.core.flow2.CheckResult in project zipkin by openzipkin.
the class CassandraStorageTest method check_failsInsteadOfThrowing.
@Test
public void check_failsInsteadOfThrowing() {
CheckResult result = CassandraStorage.newBuilder().contactPoints("1.1.1.1").build().check();
assertThat(result.ok()).isFalse();
assertThat(result.error()).isInstanceOf(AllNodesFailedException.class);
}
use of com.sequenceiq.cloudbreak.core.flow2.CheckResult in project zipkin by openzipkin.
the class ElasticsearchStorage method ensureIndexTemplatesAndClusterReady.
/**
* This allows the health check to display problems, such as access, installing the index
* template. It also helps reduce traffic sent to nodes still initializing (when guarded on the
* check result). Finally, this reads the cluster health of the index as it can go down after the
* one-time initialization passes.
*/
CheckResult ensureIndexTemplatesAndClusterReady(String index) {
try {
// ensure the version is available (even if we already cached it)
version();
// called only once, so we have to double-check health
ensureIndexTemplates();
AggregatedHttpRequest request = AggregatedHttpRequest.of(GET, "/_cluster/health/" + index);
CheckResult result = http().newCall(request, READ_STATUS, "get-cluster-health").execute();
if (result == null)
throw new IllegalArgumentException("No content reading cluster health");
return result;
} catch (Throwable e) {
Call.propagateIfFatal(e);
// Unwrap any IOException from the first call to ensureIndexTemplates()
if (e instanceof RejectedExecutionException || e instanceof UncheckedIOException) {
e = e.getCause();
}
return CheckResult.failed(e);
}
}
use of com.sequenceiq.cloudbreak.core.flow2.CheckResult in project zipkin by openzipkin.
the class MySQLStorageTest method check_failsInsteadOfThrowing.
@Test
public void check_failsInsteadOfThrowing() throws SQLException {
DataSource dataSource = mock(DataSource.class);
when(dataSource.getConnection()).thenThrow(new SQLException("foo"));
CheckResult result = storage(dataSource).check();
assertThat(result.ok()).isFalse();
assertThat(result.error()).isInstanceOf(SQLException.class);
}
use of com.sequenceiq.cloudbreak.core.flow2.CheckResult in project zipkin by openzipkin.
the class ElasticsearchStorageTest method check_unauthorized.
// TODO: when Armeria's mock server supports it, add a test for IOException
@Test
void check_unauthorized() {
server.enqueue(RESPONSE_UNAUTHORIZED);
CheckResult result = storage.check();
assertThat(result.ok()).isFalse();
assertThat(result.error().getMessage()).isEqualTo("User: anonymous is not authorized to perform: es:ESHttpGet");
}
use of com.sequenceiq.cloudbreak.core.flow2.CheckResult in project zipkin by openzipkin.
the class ElasticsearchStorageTest method check_fail_onNoContent.
// makes sure we don't NPE
@Test
void check_fail_onNoContent() {
// assume index templates called before
storage.ensuredTemplates = true;
// empty instead of success response
server.enqueue(SUCCESS_RESPONSE);
CheckResult result = storage.check();
assertThat(result.ok()).isFalse();
assertThat(result.error().getMessage()).isEqualTo("No content reading Elasticsearch version");
}
Aggregations