Search in sources :

Example 6 with AggregatedHttpRequest

use of com.linecorp.armeria.common.AggregatedHttpRequest in project zipkin by openzipkin.

the class ITElasticsearchAuth method healthcheck_usesAuthAndTls.

@Test
void healthcheck_usesAuthAndTls() {
    server.enqueue(VERSION_RESPONSE.toHttpResponse());
    server.enqueue(YELLOW_RESPONSE.toHttpResponse());
    assertThat(storage.check().ok()).isTrue();
    AggregatedHttpRequest next = server.takeRequest().request();
    // hard coded for sanity taken from https://en.wikipedia.org/wiki/Basic_access_authentication
    assertThat(next.headers().get("Authorization")).isEqualTo("Basic QWxhZGRpbjpPcGVuU2VzYW1l");
}
Also used : AggregatedHttpRequest(com.linecorp.armeria.common.AggregatedHttpRequest) Test(org.junit.jupiter.api.Test)

Example 7 with AggregatedHttpRequest

use of com.linecorp.armeria.common.AggregatedHttpRequest in project zipkin by openzipkin.

the class ITElasticsearchDynamicCredentials method healthcheck_usesDynamicCredentialsAndTls.

@Test
void healthcheck_usesDynamicCredentialsAndTls() {
    server.enqueue(VERSION_RESPONSE.toHttpResponse());
    server.enqueue(YELLOW_RESPONSE.toHttpResponse());
    assertThat(storage.check().ok()).isTrue();
    AggregatedHttpRequest next = server.takeRequest().request();
    assertThat(next.headers().get("Authorization")).isEqualTo("Basic Zm9vOmJhcg==");
}
Also used : AggregatedHttpRequest(com.linecorp.armeria.common.AggregatedHttpRequest) Test(org.junit.jupiter.api.Test)

Example 8 with AggregatedHttpRequest

use of com.linecorp.armeria.common.AggregatedHttpRequest 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);
    }
}
Also used : CheckResult(zipkin2.CheckResult) UncheckedIOException(java.io.UncheckedIOException) AggregatedHttpRequest(com.linecorp.armeria.common.AggregatedHttpRequest) RejectedExecutionException(java.util.concurrent.RejectedExecutionException)

Example 9 with AggregatedHttpRequest

use of com.linecorp.armeria.common.AggregatedHttpRequest in project zipkin by openzipkin.

the class ElasticsearchStorage method clear.

void clear(String index) throws IOException {
    String url = '/' + index;
    AggregatedHttpRequest delete = AggregatedHttpRequest.of(HttpMethod.DELETE, url);
    http().newCall(delete, BodyConverters.NULL, "delete-index").execute();
}
Also used : AggregatedHttpRequest(com.linecorp.armeria.common.AggregatedHttpRequest)

Example 10 with AggregatedHttpRequest

use of com.linecorp.armeria.common.AggregatedHttpRequest in project zipkin by openzipkin.

the class ITEnsureIndexTemplate method http.

void http(HttpMethod method, String path) throws IOException {
    AggregatedHttpRequest delete = AggregatedHttpRequest.of(method, path);
    Internal.instance.http(storage).newCall(delete, (parser, contentString) -> null, method + "-" + path).execute();
}
Also used : HttpData(com.linecorp.armeria.common.HttpData) TestObjects.spanBuilder(zipkin2.TestObjects.spanBuilder) AggregatedHttpRequest(com.linecorp.armeria.common.AggregatedHttpRequest) RequestHeaders(com.linecorp.armeria.common.RequestHeaders) Span(zipkin2.Span) IOException(java.io.IOException) PUT(com.linecorp.armeria.common.HttpMethod.PUT) HttpMethod(com.linecorp.armeria.common.HttpMethod) TestInfo(org.junit.jupiter.api.TestInfo) DELETE(com.linecorp.armeria.common.HttpMethod.DELETE) ElasticsearchStorage(zipkin2.elasticsearch.ElasticsearchStorage) Test(org.junit.jupiter.api.Test) Internal(zipkin2.elasticsearch.internal.Internal) GET(com.linecorp.armeria.common.HttpMethod.GET) TestInstance(org.junit.jupiter.api.TestInstance) Arrays.asList(java.util.Arrays.asList) JSON_UTF_8(com.linecorp.armeria.common.MediaType.JSON_UTF_8) CONTENT_TYPE(com.linecorp.armeria.common.HttpHeaderNames.CONTENT_TYPE) StorageComponent(zipkin2.storage.StorageComponent) ITStorage(zipkin2.storage.ITStorage) AggregatedHttpRequest(com.linecorp.armeria.common.AggregatedHttpRequest)

Aggregations

AggregatedHttpRequest (com.linecorp.armeria.common.AggregatedHttpRequest)11 Test (org.junit.jupiter.api.Test)8 HttpData (com.linecorp.armeria.common.HttpData)3 CONTENT_TYPE (com.linecorp.armeria.common.HttpHeaderNames.CONTENT_TYPE)2 HttpMethod (com.linecorp.armeria.common.HttpMethod)2 DELETE (com.linecorp.armeria.common.HttpMethod.DELETE)2 GET (com.linecorp.armeria.common.HttpMethod.GET)2 PUT (com.linecorp.armeria.common.HttpMethod.PUT)2 JSON_UTF_8 (com.linecorp.armeria.common.MediaType.JSON_UTF_8)2 RequestHeaders (com.linecorp.armeria.common.RequestHeaders)2 IOException (java.io.IOException)2 Arrays.asList (java.util.Arrays.asList)2 TestInfo (org.junit.jupiter.api.TestInfo)2 TestInstance (org.junit.jupiter.api.TestInstance)2 Span (zipkin2.Span)2 TestObjects.spanBuilder (zipkin2.TestObjects.spanBuilder)2 ElasticsearchStorage (zipkin2.elasticsearch.ElasticsearchStorage)2 Internal (zipkin2.elasticsearch.internal.Internal)2 ITStorage (zipkin2.storage.ITStorage)2 StorageComponent (zipkin2.storage.StorageComponent)2