use of zipkin2.CheckResult.OK in project zipkin by openzipkin.
the class ITEnsureIndexTemplate method createZipkinIndexTemplate_getTraces_returnsSuccess.
@Test
void createZipkinIndexTemplate_getTraces_returnsSuccess(TestInfo testInfo) throws Exception {
String testSuffix = testSuffix(testInfo);
storage = newStorageBuilder(testInfo).templatePriority(10).build();
try {
// Delete all templates in order to create the "catch-all" index template, because
// ES does not allow multiple index templates of the same index_patterns and priority
http(DELETE, "/_template/*");
setUpCatchAllTemplate();
// Implicitly creates an index template
checkStorage();
// Get all templates. We don't assert on this at the moment. This is for logging on ES_DEBUG.
http(GET, "/_template");
// Now, add a span, which should be indexed differently than default.
Span span = spanBuilder(testSuffix).putTag("queryTest", "ok").build();
accept(asList(span));
// Assert that Zipkin's templates work and source is returned
assertGetTracesReturns(requestBuilder().parseAnnotationQuery("queryTest=" + span.tags().get("queryTest")).build(), asList(span));
} finally {
// Delete "catch-all" index template so it does not interfere with any other test
http(DELETE, catchAllIndexPath());
}
}
use of zipkin2.CheckResult.OK in project zipkin by openzipkin.
the class ITElasticsearchClientInitialization method doesntHangWhenAllDown.
/**
* blocking a little is ok, but blocking forever is not.
*/
@Test(timeout = 3000L)
public void doesntHangWhenAllDown() throws IOException {
TestPropertyValues.of("spring.config.name=zipkin-server", "zipkin.storage.type:elasticsearch", "zipkin.storage.elasticsearch.timeout:1000", "zipkin.storage.elasticsearch.hosts:127.0.0.1:1234,127.0.0.1:5678").applyTo(context);
Access.registerElasticsearch(context);
context.refresh();
try (ElasticsearchStorage storage = context.getBean(ElasticsearchStorage.class)) {
CheckResult result = storage.check();
assertThat(result.ok()).isFalse();
}
}
use of zipkin2.CheckResult.OK in project zipkin by openzipkin.
the class ITElasticsearchHealthCheck method notHealthyThenHealthyThenNotHealthy.
@Test
public void notHealthyThenHealthyThenNotHealthy() {
server1Health.setHealthy(false);
server2Health.setHealthy(false);
try (ElasticsearchStorage storage = context.getBean(ElasticsearchStorage.class)) {
CheckResult result = storage.check();
assertThat(result.ok()).isFalse();
server2Health.setHealthy(true);
awaitTimeout.untilAsserted(() -> assertThat(storage.check().ok()).isTrue());
server2Health.setHealthy(false);
awaitTimeout.untilAsserted(() -> assertThat(storage.check().ok()).isFalse());
}
}
use of zipkin2.CheckResult.OK in project spring-cloud-sleuth by spring-cloud.
the class FeignRetriesTests method testRetriedWhenRequestEventuallyIsSent.
@Test
public void testRetriedWhenRequestEventuallyIsSent() throws Exception {
String url = "http://localhost:" + server.getPort();
final AtomicInteger atomicInteger = new AtomicInteger();
// Client to simulate a retry scenario
final Client client = (request, options) -> {
// we simulate an exception only for the first request
if (atomicInteger.get() == 1) {
throw new IOException();
} else {
// with the second retry (first retry) we send back good result
return Response.builder().status(200).reason("OK").headers(new HashMap<>()).body("OK", Charset.defaultCharset()).build();
}
};
TestInterface api = Feign.builder().client(new TracingFeignClient(this.httpTracing, new Client() {
@Override
public Response execute(Request request, Request.Options options) throws IOException {
atomicInteger.incrementAndGet();
return client.execute(request, options);
}
})).target(TestInterface.class, url);
then(api.decodedPost()).isEqualTo("OK");
// request interception should take place only twice (1st request & 2nd retry)
then(atomicInteger.get()).isEqualTo(2);
then(this.reporter.getSpans().get(0).tags()).containsEntry("error", "IOException");
then(this.reporter.getSpans().get(1).kind().ordinal()).isEqualTo(Span.Kind.CLIENT.ordinal());
}
use of zipkin2.CheckResult.OK in project crnk-framework by crnk-project.
the class AbstractBraveModuleTest method testFindTargets.
@Test
public void testFindTargets() {
RelationshipRepository<Project, Serializable, Task, Serializable> relRepo = client.getRepositoryForType(Project.class, Task.class);
relRepo.findManyTargets(123L, "tasks", new QuerySpec(Task.class));
// check client call and link span
ArgumentCaptor<Span> clientSpanCaptor = ArgumentCaptor.forClass(Span.class);
Mockito.verify(clientReporter, Mockito.times(1)).report(clientSpanCaptor.capture());
List<Span> clientSpans = clientSpanCaptor.getAllValues();
Span callSpan = clientSpans.get(0);
Assert.assertEquals("get", callSpan.name());
Assert.assertEquals(Span.Kind.CLIENT, callSpan.kind());
// check server local span
ArgumentCaptor<Span> serverSpanCaptor = ArgumentCaptor.forClass(Span.class);
Mockito.verify(serverReporter, Mockito.times(2)).report(serverSpanCaptor.capture());
List<Span> serverSpans = serverSpanCaptor.getAllValues();
Span repositorySpan0 = serverSpans.get(0);
Assert.assertEquals("crnk:get:/tasks/", repositorySpan0.name());
Assert.assertTrue(repositorySpan0.toString().contains("\"lc\""));
assertTag(repositorySpan0, "lc", "crnk");
assertTag(repositorySpan0, "crnk.results", "0");
assertTag(repositorySpan0, "crnk.status", "OK");
Span repositorySpan1 = serverSpans.get(1);
Assert.assertEquals("crnk:get:/projects/123/tasks/", repositorySpan1.name());
Assert.assertTrue(repositorySpan1.toString().contains("\"lc\""));
assertTag(repositorySpan1, "lc", "crnk");
assertTag(repositorySpan1, "crnk.query", "?");
assertTag(repositorySpan1, "crnk.results", "0");
assertTag(repositorySpan1, "crnk.status", "OK");
}
Aggregations