Search in sources :

Example 1 with QueryRequest

use of zipkin.storage.QueryRequest in project zipkin by openzipkin.

the class ZipkinDispatcherTest method toQueryRequest.

@Test
public void toQueryRequest() {
    HttpUrl url = baseUrl.newBuilder().addQueryParameter("serviceName", "zipkin-server").addQueryParameter("spanName", "get").addQueryParameter("limit", "1000").build();
    QueryRequest request = ZipkinDispatcher.toQueryRequest(url);
    assertThat(request.serviceName).isEqualTo("zipkin-server");
    assertThat(request.spanName).isEqualTo("get");
    assertThat(request.limit).isEqualTo(1000);
}
Also used : QueryRequest(zipkin.storage.QueryRequest) HttpUrl(okhttp3.HttpUrl) Test(org.junit.Test)

Example 2 with QueryRequest

use of zipkin.storage.QueryRequest in project zipkin by openzipkin.

the class ZipkinDispatcherTest method toQueryRequest_parseAnnotations.

@Test
public void toQueryRequest_parseAnnotations() {
    HttpUrl url = baseUrl.newBuilder().addQueryParameter("serviceName", "zipkin-server").addQueryParameter("annotationQuery", "error and finagle.timeout").build();
    QueryRequest request = ZipkinDispatcher.toQueryRequest(url);
    assertThat(request.annotations).containsExactly(Constants.ERROR, "finagle.timeout");
}
Also used : QueryRequest(zipkin.storage.QueryRequest) HttpUrl(okhttp3.HttpUrl) Test(org.junit.Test)

Example 3 with QueryRequest

use of zipkin.storage.QueryRequest in project zipkin by openzipkin.

the class CassandraSpanStoreTest method searchingByAnnotationShouldFilterBeforeLimiting.

@Test
public void searchingByAnnotationShouldFilterBeforeLimiting() {
    long now = System.currentTimeMillis();
    int queryLimit = 2;
    Endpoint endpoint = TestObjects.LOTS_OF_SPANS[0].annotations.get(0).endpoint;
    BinaryAnnotation ba = BinaryAnnotation.create("host.name", "host1", endpoint);
    int nbTraceFetched = queryLimit * storage.indexFetchMultiplier;
    IntStream.range(0, nbTraceFetched).forEach(i -> accept(TestObjects.LOTS_OF_SPANS[i++].toBuilder().timestamp(now - (i * 1000)).build()));
    // Add two traces with the binary annotation we're looking for
    IntStream.range(nbTraceFetched, nbTraceFetched + 2).forEach(i -> accept(TestObjects.LOTS_OF_SPANS[i++].toBuilder().timestamp(now - (i * 1000)).addBinaryAnnotation(ba).build()));
    QueryRequest queryRequest = QueryRequest.builder().addBinaryAnnotation(ba.key, new String(ba.value, Util.UTF_8)).serviceName(endpoint.serviceName).limit(queryLimit).build();
    assertThat(store().getTraces(queryRequest)).hasSize(queryLimit);
}
Also used : BinaryAnnotation(zipkin.BinaryAnnotation) Endpoint(zipkin.Endpoint) QueryRequest(zipkin.storage.QueryRequest) Endpoint(zipkin.Endpoint) Test(org.junit.Test) SpanStoreTest(zipkin.storage.SpanStoreTest)

Example 4 with QueryRequest

use of zipkin.storage.QueryRequest in project zipkin by openzipkin.

the class InternalGuavaSpanStoreAdapterTest method getTraces_exception.

@Test
public void getTraces_exception() throws Exception {
    QueryRequest request = QueryRequest.builder().build();
    doAnswer(answer(c -> c.onError(new IllegalStateException("failed")))).when(asyncSpanStore).getTraces(eq(request), any(Callback.class));
    thrown.expect(ExecutionException.class);
    thrown.expectCause(isA(IllegalStateException.class));
    spanStore.getTraces(request).get();
}
Also used : TRACE(zipkin.TestObjects.TRACE) Mock(org.mockito.Mock) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) Test(org.junit.Test) LINKS(zipkin.TestObjects.LINKS) AsyncSpanStore(zipkin.storage.AsyncSpanStore) ExecutionException(java.util.concurrent.ExecutionException) Consumer(java.util.function.Consumer) Matchers.any(org.mockito.Matchers.any) Answer(org.mockito.stubbing.Answer) Is.isA(org.hamcrest.core.Is.isA) Rule(org.junit.Rule) Arrays.asList(java.util.Arrays.asList) Matchers.eq(org.mockito.Matchers.eq) Mockito.doAnswer(org.mockito.Mockito.doAnswer) QueryRequest(zipkin.storage.QueryRequest) MockitoJUnit(org.mockito.junit.MockitoJUnit) MockitoRule(org.mockito.junit.MockitoRule) ExpectedException(org.junit.rules.ExpectedException) Callback(zipkin.storage.Callback) Before(org.junit.Before) Callback(zipkin.storage.Callback) QueryRequest(zipkin.storage.QueryRequest) Test(org.junit.Test)

Example 5 with QueryRequest

use of zipkin.storage.QueryRequest in project zipkin by openzipkin.

the class InternalGuavaSpanStoreAdapterTest method getTraces_success.

@Test
public void getTraces_success() throws Exception {
    QueryRequest request = QueryRequest.builder().build();
    doAnswer(answer(c -> c.onSuccess(asList(TRACE)))).when(asyncSpanStore).getTraces(eq(request), any(Callback.class));
    assertThat(spanStore.getTraces(request).get()).containsExactly(TRACE);
}
Also used : TRACE(zipkin.TestObjects.TRACE) Mock(org.mockito.Mock) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) Test(org.junit.Test) LINKS(zipkin.TestObjects.LINKS) AsyncSpanStore(zipkin.storage.AsyncSpanStore) ExecutionException(java.util.concurrent.ExecutionException) Consumer(java.util.function.Consumer) Matchers.any(org.mockito.Matchers.any) Answer(org.mockito.stubbing.Answer) Is.isA(org.hamcrest.core.Is.isA) Rule(org.junit.Rule) Arrays.asList(java.util.Arrays.asList) Matchers.eq(org.mockito.Matchers.eq) Mockito.doAnswer(org.mockito.Mockito.doAnswer) QueryRequest(zipkin.storage.QueryRequest) MockitoJUnit(org.mockito.junit.MockitoJUnit) MockitoRule(org.mockito.junit.MockitoRule) ExpectedException(org.junit.rules.ExpectedException) Callback(zipkin.storage.Callback) Before(org.junit.Before) Callback(zipkin.storage.Callback) QueryRequest(zipkin.storage.QueryRequest) Test(org.junit.Test)

Aggregations

QueryRequest (zipkin.storage.QueryRequest)10 Test (org.junit.Test)8 HttpUrl (okhttp3.HttpUrl)6 Callback (zipkin.storage.Callback)3 Arrays.asList (java.util.Arrays.asList)2 ExecutionException (java.util.concurrent.ExecutionException)2 Consumer (java.util.function.Consumer)2 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)2 Is.isA (org.hamcrest.core.Is.isA)2 Before (org.junit.Before)2 Rule (org.junit.Rule)2 ExpectedException (org.junit.rules.ExpectedException)2 Matchers.any (org.mockito.Matchers.any)2 Matchers.eq (org.mockito.Matchers.eq)2 Mock (org.mockito.Mock)2 Mockito.doAnswer (org.mockito.Mockito.doAnswer)2 MockitoJUnit (org.mockito.junit.MockitoJUnit)2 MockitoRule (org.mockito.junit.MockitoRule)2 Answer (org.mockito.stubbing.Answer)2 BinaryAnnotation (zipkin.BinaryAnnotation)2