Merge branch 'master' into 2.0.x

This commit is contained in:
Marcin Grzejszczak
2017-06-27 15:39:27 +02:00
22 changed files with 133 additions and 128 deletions

View File

@@ -206,9 +206,9 @@
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.jayway.awaitility</groupId>
<groupId>org.awaitility</groupId>
<artifactId>awaitility</artifactId>
<version>1.7.0</version>
<version>3.0.0</version>
<scope>test</scope>
</dependency>
<dependency>

View File

@@ -131,7 +131,7 @@
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.jayway.awaitility</groupId>
<groupId>org.awaitility</groupId>
<artifactId>awaitility</artifactId>
<scope>test</scope>
</dependency>

View File

@@ -52,7 +52,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;
import com.jayway.awaitility.Awaitility;
import org.awaitility.Awaitility;
/**
* @author Marcin Grzejszczak
@@ -88,7 +88,7 @@ public class Issue410Tests {
"http://localhost:" + port() + "/without_pool", String.class);
then(response).isEqualTo(span.traceIdString());
Awaitility.await().until(() -> {
Awaitility.await().untilAsserted(() -> {
then(this.asyncTask.getSpan().get()).isNotNull();
then(this.asyncTask.getSpan().get().getTraceId())
.isEqualTo(span.getTraceId());
@@ -108,7 +108,7 @@ public class Issue410Tests {
"http://localhost:" + port() + "/with_pool", String.class);
then(response).isEqualTo(span.traceIdString());
Awaitility.await().until(() -> {
Awaitility.await().untilAsserted(() -> {
then(this.asyncTask.getSpan().get()).isNotNull();
then(this.asyncTask.getSpan().get().getTraceId())
.isEqualTo(span.getTraceId());
@@ -131,7 +131,7 @@ public class Issue410Tests {
"http://localhost:" + port() + "/completable", String.class);
then(response).isEqualTo(span.traceIdString());
Awaitility.await().until(() -> {
Awaitility.await().untilAsserted(() -> {
then(this.asyncTask.getSpan().get()).isNotNull();
then(this.asyncTask.getSpan().get().getTraceId())
.isEqualTo(span.getTraceId());
@@ -154,7 +154,7 @@ public class Issue410Tests {
"http://localhost:" + port() + "/taskScheduler", String.class);
then(response).isEqualTo(span.traceIdString());
Awaitility.await().until(() -> {
Awaitility.await().untilAsserted(() -> {
then(this.asyncTask.getSpan().get()).isNotNull();
then(this.asyncTask.getSpan().get().getTraceId())
.isEqualTo(span.getTraceId());

View File

@@ -40,7 +40,7 @@ import org.springframework.context.annotation.Configuration;
import org.springframework.test.annotation.DirtiesContext;
import org.springframework.test.context.junit4.SpringRunner;
import com.jayway.awaitility.Awaitility;
import org.awaitility.Awaitility;
import com.netflix.hystrix.contrib.javanica.annotation.HystrixCommand;
import com.netflix.hystrix.strategy.HystrixPlugins;
@@ -91,26 +91,20 @@ public class HystrixAnnotationsIntegrationTests {
private void thenSpanInHystrixThreadIsContinued(final Span span) {
then(span).isNotNull();
Awaitility.await().atMost(5, SECONDS).until(new Runnable() {
@Override
public void run() {
Awaitility.await().atMost(5, SECONDS).untilAsserted(() -> {
then(HystrixAnnotationsIntegrationTests.this.catcher).isNotNull();
then(span)
.hasTraceIdEqualTo(HystrixAnnotationsIntegrationTests.this.catcher
.getTraceId())
.hasNameEqualTo(HystrixAnnotationsIntegrationTests.this.catcher
.getSpanName());
}
});
}
private void thenSpanInHystrixThreadIsCreated() {
Awaitility.await().atMost(5, SECONDS).until(new Runnable() {
@Override
public void run() {
then(HystrixAnnotationsIntegrationTests.this.catcher.getSpan())
.nameStartsWith("hystrix").isALocalComponentSpan();
}
Awaitility.await().atMost(5, SECONDS).untilAsserted(() -> {
then(HystrixAnnotationsIntegrationTests.this.catcher.getSpan())
.nameStartsWith("hystrix").isALocalComponentSpan();
});
}

View File

@@ -1,6 +1,6 @@
package org.springframework.cloud.sleuth.instrument.rxjava;
import static com.jayway.awaitility.Awaitility.await;
import static org.awaitility.Awaitility.await;
import static java.util.concurrent.TimeUnit.SECONDS;
import static org.springframework.cloud.sleuth.assertions.SleuthAssertions.then;
@@ -70,7 +70,7 @@ public class SleuthRxJavaTests {
then(this.caller.toString()).isEqualTo("actual_action");
then(this.tracer.getCurrentSpan()).isNull();
await().atMost(5, SECONDS)
.until(() -> then(this.listener.getEvents()).hasSize(1));
.untilAsserted(() -> then(this.listener.getEvents()).hasSize(1));
then(this.listener.getEvents().get(0)).hasNameEqualTo("rxjava");
then(this.listener.getEvents().get(0)).isExportable();
then(this.listener.getEvents().get(0)).hasATag(Span.SPAN_LOCAL_COMPONENT_TAG_NAME,

View File

@@ -16,10 +16,6 @@
package org.springframework.cloud.sleuth.instrument.scheduling;
import static com.jayway.awaitility.Awaitility.await;
import static java.util.concurrent.TimeUnit.SECONDS;
import static org.springframework.cloud.sleuth.assertions.SleuthAssertions.then;
import java.util.concurrent.atomic.AtomicBoolean;
import org.hamcrest.Matchers;
@@ -36,6 +32,10 @@ import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.test.context.junit4.SpringRunner;
import static java.util.concurrent.TimeUnit.SECONDS;
import static org.awaitility.Awaitility.await;
import static org.springframework.cloud.sleuth.assertions.SleuthAssertions.then;
@RunWith(SpringRunner.class)
@SpringBootTest(classes = { ScheduledTestConfiguration.class })
public class TracingOnScheduledTests {
@@ -47,13 +47,13 @@ public class TracingOnScheduledTests {
@Test
public void should_have_span_set_after_scheduled_method_has_been_executed() {
await().atMost(5, SECONDS).until(spanIsSetOnAScheduledMethod());
await().atMost(5, SECONDS).untilAsserted(this::spanIsSetOnAScheduledMethod);
}
@Test
public void should_have_a_new_span_set_each_time_a_scheduled_method_has_been_executed() {
Span firstSpan = this.beanWithScheduledMethod.getSpan();
await().atMost(5, SECONDS).until(differentSpanHasBeenSetThan(firstSpan));
final Span firstSpan = this.beanWithScheduledMethod.getSpan();
await().atMost(5, SECONDS).untilAsserted(() -> differentSpanHasBeenSetThan(firstSpan));
}
@Test
@@ -65,27 +65,19 @@ public class TracingOnScheduledTests {
}
private Runnable spanIsSetOnAScheduledMethod() {
return new Runnable() {
@Override
public void run() {
Span storedSpan = TracingOnScheduledTests.this.beanWithScheduledMethod
.getSpan();
then(storedSpan).isNotNull();
then(storedSpan.getTraceId()).isNotNull();
then(storedSpan).hasATag("class", "TestBeanWithScheduledMethod");
then(storedSpan).hasATag("method", "scheduledMethod");
}
return () -> {
Span storedSpan = TracingOnScheduledTests.this.beanWithScheduledMethod
.getSpan();
then(storedSpan).isNotNull();
then(storedSpan.getTraceId()).isNotNull();
then(storedSpan).hasATag("class", "TestBeanWithScheduledMethod");
then(storedSpan).hasATag("method", "scheduledMethod");
};
}
private Runnable differentSpanHasBeenSetThan(final Span spanToCompare) {
return new Runnable() {
@Override
public void run() {
then(TracingOnScheduledTests.this.beanWithScheduledMethod.getSpan())
.isNotEqualTo(spanToCompare);
}
};
return () -> then(TracingOnScheduledTests.this.beanWithScheduledMethod.getSpan())
.isNotEqualTo(spanToCompare);
}
}

View File

@@ -16,7 +16,6 @@
package org.springframework.cloud.sleuth.instrument.web;
import com.jayway.awaitility.Awaitility;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -42,6 +41,7 @@ import org.springframework.test.annotation.DirtiesContext;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.web.client.RestTemplate;
import org.awaitility.Awaitility;
import javax.annotation.PostConstruct;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
@@ -81,7 +81,7 @@ public class SpringDataInstrumentationTests {
then(noOfNames).isEqualTo(8);
then(this.arrayListSpanAccumulator.getSpans()).isNotEmpty();
Awaitility.await().until(() -> {
Awaitility.await().untilAsserted(() -> {
then(new ListOfSpans(this.arrayListSpanAccumulator.getSpans()))
.hasASpanWithName("http:/reservations")
.hasASpanWithTagKeyEqualTo("mvc.controller.class");

View File

@@ -23,7 +23,7 @@ import org.springframework.scheduling.annotation.Async;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.test.context.junit4.SpringRunner;
import com.jayway.awaitility.Awaitility;
import org.awaitility.Awaitility;
@RunWith(SpringRunner.class)
@SpringBootTest(classes = {
@@ -53,17 +53,13 @@ public class TraceAsyncIntegrationTests {
}
private void thenTraceIdIsPassedFromTheCurrentThreadToTheAsyncOne(final Span span) {
Awaitility.await().atMost(5, SECONDS).until(new Runnable() {
@Override
public void run() {
then(TraceAsyncIntegrationTests.this.classPerformingAsyncLogic.getSpan())
.hasTraceIdEqualTo(span.getTraceId())
.hasNameEqualTo("invoke-asynchronous-logic")
.isALocalComponentSpan()
.hasATag("class", "ClassPerformingAsyncLogic")
.hasATag("method", "invokeAsynchronousLogic");
}
});
Awaitility.await().atMost(5, SECONDS).untilAsserted(
() -> then(TraceAsyncIntegrationTests.this.classPerformingAsyncLogic.getSpan())
.hasTraceIdEqualTo(span.getTraceId())
.hasNameEqualTo("invoke-asynchronous-logic")
.isALocalComponentSpan()
.hasATag("class", "ClassPerformingAsyncLogic")
.hasATag("method", "invokeAsynchronousLogic"));
}
@After

View File

@@ -49,7 +49,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;
import static com.jayway.awaitility.Awaitility.await;
import static org.awaitility.Awaitility.await;
import static java.util.concurrent.TimeUnit.SECONDS;
import static org.springframework.cloud.sleuth.assertions.SleuthAssertions.then;
@@ -83,9 +83,11 @@ public class TraceFilterCustomExtractorTests {
} finally {
this.tracer.close(newSpan);
}
await().atMost(5, SECONDS).until(() -> then(this.accumulator.getSpans().stream().filter(
span -> span.getSpanId() == newSpan.getSpanId()).findFirst().get())
.hasTraceIdEqualTo(newSpan.getTraceId()));
await().atMost(5, SECONDS).untilAsserted(() -> {
then(this.accumulator.getSpans().stream().filter(
span -> span.getSpanId() == newSpan.getSpanId()).findFirst().get())
.hasTraceIdEqualTo(newSpan.getTraceId());
});
BDDAssertions.then(responseEntity.getBody())
.containsEntry("correlationid", Span.idToHex(newSpan.getTraceId()))
.containsKey("myspanid")

View File

@@ -51,7 +51,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.AsyncRestTemplate;
import com.jayway.awaitility.Awaitility;
import org.awaitility.Awaitility;
import static org.springframework.boot.test.context.SpringBootTest.WebEnvironment.RANDOM_PORT;
import static org.springframework.cloud.sleuth.assertions.SleuthAssertions.then;
@@ -206,7 +206,7 @@ public class TraceWebAsyncClientAutoConfigurationTests {
}
Awaitility.await().until(() -> {
Awaitility.await().untilAsserted(() -> {
then(new ArrayList<>(this.accumulator.getSpans()).stream()
.filter(span -> span.logs().stream().filter(log -> Span.CLIENT_RECV.equals(log.getEvent()))
.findFirst().isPresent()).findFirst().get()).matches(

View File

@@ -16,10 +16,18 @@
package org.springframework.cloud.sleuth.instrument.web.client.feign.servererrors;
import com.netflix.hystrix.exception.HystrixRuntimeException;
import com.netflix.loadbalancer.BaseLoadBalancer;
import com.netflix.loadbalancer.ILoadBalancer;
import com.netflix.loadbalancer.Server;
import feign.codec.Decoder;
import feign.codec.ErrorDecoder;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import org.awaitility.Awaitility;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
@@ -54,15 +62,6 @@ import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;
import com.jayway.awaitility.Awaitility;
import com.netflix.hystrix.exception.HystrixRuntimeException;
import com.netflix.loadbalancer.BaseLoadBalancer;
import com.netflix.loadbalancer.ILoadBalancer;
import com.netflix.loadbalancer.Server;
import feign.codec.Decoder;
import feign.codec.ErrorDecoder;
import static org.springframework.cloud.sleuth.assertions.SleuthAssertions.then;
/**
@@ -93,7 +92,7 @@ public class FeignClientServerErrorTests {
} catch (HystrixRuntimeException e) {
}
Awaitility.await().until(() -> {
Awaitility.await().untilAsserted(() -> {
then(this.capture.toString())
.doesNotContain("Tried to close span but it is not the current span");
then(ExceptionUtils.getLastException()).isNull();
@@ -110,7 +109,7 @@ public class FeignClientServerErrorTests {
} catch (HystrixRuntimeException e) {
}
Awaitility.await().until(() -> {
Awaitility.await().untilAsserted(() -> {
then(this.capture.toString())
.doesNotContain("Tried to close span but it is not the current span");
then(ExceptionUtils.getLastException()).isNull();
@@ -124,7 +123,7 @@ public class FeignClientServerErrorTests {
} catch (HystrixRuntimeException e) {
}
Awaitility.await().until(() -> {
Awaitility.await().untilAsserted(() -> {
then(this.capture.toString()).doesNotContain("Tried to close span but it is not the current span");
then(ExceptionUtils.getLastException()).isNull();
});
@@ -137,9 +136,10 @@ public class FeignClientServerErrorTests {
} catch (HystrixRuntimeException e) {
}
Awaitility.await().until(() -> {
Awaitility.await().untilAsserted(() -> {
then(this.capture.toString()).doesNotContain("Tried to close span but it is not the current span");
then(ExceptionUtils.getLastException()).isNull();
});
}
@@ -150,7 +150,7 @@ public class FeignClientServerErrorTests {
} catch (HystrixRuntimeException e) {
}
Awaitility.await().until(() -> {
Awaitility.await().untilAsserted(() -> {
then(this.capture.toString()).doesNotContain("Tried to close span but it is not the current span");
then(ExceptionUtils.getLastException()).isNull();
});

View File

@@ -16,13 +16,6 @@
package org.springframework.cloud.sleuth.instrument.web.client.integration;
import com.jayway.awaitility.Awaitility;
import com.netflix.loadbalancer.BaseLoadBalancer;
import com.netflix.loadbalancer.ILoadBalancer;
import com.netflix.loadbalancer.Server;
import junitparams.JUnitParamsRunner;
import junitparams.Parameters;
import java.lang.invoke.MethodHandles;
import java.util.ArrayList;
import java.util.Collections;
@@ -76,6 +69,14 @@ import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.HttpClientErrorException;
import org.springframework.web.client.RestTemplate;
import org.awaitility.Awaitility;
import com.netflix.loadbalancer.BaseLoadBalancer;
import com.netflix.loadbalancer.ILoadBalancer;
import com.netflix.loadbalancer.Server;
import junitparams.JUnitParamsRunner;
import junitparams.Parameters;
import static junitparams.JUnitParamsRunner.$;
import static org.assertj.core.api.Assertions.fail;
import static org.springframework.cloud.sleuth.assertions.SleuthAssertions.then;
@@ -112,7 +113,7 @@ public class WebClientTests {
ResponseEntityProvider provider) {
ResponseEntity<String> response = provider.get(this);
Awaitility.await().atMost(2, TimeUnit.SECONDS).until(() -> {
Awaitility.await().atMost(2, TimeUnit.SECONDS).untilAsserted(() -> {
then(getHeader(response, Span.TRACE_ID_NAME)).isNull();
then(getHeader(response, Span.SPAN_ID_NAME)).isNull();
List<Span> spans = new ArrayList<>(this.listener.getSpans());

View File

@@ -30,7 +30,7 @@ import org.springframework.test.context.TestPropertySource;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.web.client.RestTemplate;
import static com.jayway.awaitility.Awaitility.await;
import static org.awaitility.Awaitility.await;
import static java.util.Arrays.asList;
import static java.util.concurrent.TimeUnit.SECONDS;
import static java.util.stream.Collectors.toList;
@@ -59,7 +59,7 @@ public class MultipleHopsIntegrationTests {
public void should_prepare_spans_for_export() throws Exception {
this.restTemplate.getForObject("http://localhost:" + this.config.port + "/greeting", String.class);
await().atMost(5, SECONDS).until(() -> {
await().atMost(5, SECONDS).untilAsserted(() -> {
then(this.arrayListSpanAccumulator.getSpans().stream().map(Span::getName)
.collect(
toList())).containsAll(asList("http:/greeting", "message:greetings",
@@ -82,7 +82,7 @@ public class MultipleHopsIntegrationTests {
URI.create("http://localhost:" + this.config.port + "/greeting"));
this.restTemplate.exchange(requestEntity, String.class);
await().atMost(5, SECONDS).until(() -> {
await().atMost(5, SECONDS).untilAsserted(() -> {
then(new ListOfSpans(this.arrayListSpanAccumulator.getSpans()))
.everySpanHasABaggage("foo", "bar")
.anySpanHasABaggage("baz", "baz");

View File

@@ -103,7 +103,7 @@
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.jayway.awaitility</groupId>
<groupId>org.awaitility</groupId>
<artifactId>awaitility</artifactId>
<scope>test</scope>
</dependency>

View File

@@ -63,11 +63,13 @@ public class MessagingApplicationTests extends AbstractIntegrationTest {
public void should_have_passed_trace_id_when_message_is_about_to_be_sent() {
long traceId = new Random().nextLong();
await().atMost(5, SECONDS).until(httpMessageWithTraceIdInHeadersIsSuccessfullySent(sampleAppUrl + "/", traceId));
await().atMost(5, SECONDS).untilAsserted(() ->
httpMessageWithTraceIdInHeadersIsSuccessfullySent(sampleAppUrl + "/", traceId).run()
);
await().atMost(5, SECONDS).until(() -> {
thenAllSpansHaveTraceIdEqualTo(traceId);
});
await().atMost(5, SECONDS).untilAsserted(() ->
thenAllSpansHaveTraceIdEqualTo(traceId)
);
}
@Test
@@ -75,9 +77,11 @@ public class MessagingApplicationTests extends AbstractIntegrationTest {
long traceId = new Random().nextLong();
long spanId = new Random().nextLong();
await().atMost(5, SECONDS).until(httpMessageWithTraceIdInHeadersIsSuccessfullySent(sampleAppUrl + "/", traceId, spanId));
await().atMost(5, SECONDS).untilAsserted(() ->
httpMessageWithTraceIdInHeadersIsSuccessfullySent(sampleAppUrl + "/", traceId, spanId).run()
);
await().atMost(5, SECONDS).until(() -> {
await().atMost(5, SECONDS).untilAsserted(() -> {
thenAllSpansHaveTraceIdEqualTo(traceId);
thenTheSpansHaveProperParentStructure();
});
@@ -87,9 +91,11 @@ public class MessagingApplicationTests extends AbstractIntegrationTest {
public void should_have_passed_trace_id_with_annotations_in_async_thread_when_message_is_about_to_be_sent() {
long traceId = new Random().nextLong();
await().atMost(5, SECONDS).until(httpMessageWithTraceIdInHeadersIsSuccessfullySent(sampleAppUrl + "/xform", traceId));
await().atMost(5, SECONDS).untilAsserted(() ->
httpMessageWithTraceIdInHeadersIsSuccessfullySent(sampleAppUrl + "/xform", traceId).run()
);
await().atMost(5, SECONDS).until(() -> {
await().atMost(5, SECONDS).untilAsserted(() -> {
thenAllSpansHaveTraceIdEqualTo(traceId);
thenThereIsAtLeastOneBinaryAnnotationWithKey("background-sleep-millis");
});

View File

@@ -106,7 +106,7 @@
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.jayway.awaitility</groupId>
<groupId>org.awaitility</groupId>
<artifactId>awaitility</artifactId>
<scope>compile</scope>
</dependency>

View File

@@ -15,23 +15,32 @@
*/
package tools;
import com.jayway.awaitility.Awaitility;
import com.jayway.awaitility.core.ConditionFactory;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.junit.After;
import org.junit.Before;
import org.springframework.cloud.sleuth.trace.IntegrationTestSpanContextHolder;
import org.springframework.http.*;
import org.springframework.web.client.RestTemplate;
import zipkin.Codec;
import zipkin.Span;
import java.lang.invoke.MethodHandles;
import java.net.URI;
import java.util.*;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.Optional;
import java.util.stream.Collectors;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.awaitility.Awaitility;
import org.awaitility.core.ConditionFactory;
import org.junit.After;
import org.junit.Before;
import org.springframework.cloud.sleuth.trace.IntegrationTestSpanContextHolder;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpMethod;
import org.springframework.http.HttpStatus;
import org.springframework.http.RequestEntity;
import org.springframework.http.ResponseEntity;
import org.springframework.web.client.RestTemplate;
import static java.util.concurrent.TimeUnit.SECONDS;
import static org.assertj.core.api.BDDAssertions.then;

View File

@@ -99,7 +99,7 @@
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.jayway.awaitility</groupId>
<groupId>org.awaitility</groupId>
<artifactId>awaitility</artifactId>
<scope>test</scope>
</dependency>

View File

@@ -60,7 +60,8 @@ public class ZipkinStreamTests extends AbstractIntegrationTest {
@Before
public void setup() {
await().atMost(10, SECONDS).until(zipkinServerIsUp());
await().atMost(10, SECONDS)
.untilAsserted(() -> zipkinServerIsUp().run());
}
@Test
@@ -70,7 +71,9 @@ public class ZipkinStreamTests extends AbstractIntegrationTest {
this.input.send(messageWithSpan(span));
await().atMost(5, SECONDS).until(allSpansWereRegisteredInZipkinWithTraceIdEqualTo(this.traceId));
await().atMost(5, SECONDS).untilAsserted(() ->
allSpansWereRegisteredInZipkinWithTraceIdEqualTo(this.traceId)
);
}
private Message<Spans> messageWithSpan(Span span) {

View File

@@ -15,6 +15,12 @@
*/
package integration;
import integration.ZipkinTests.WaitUntilZipkinIsUpConfig;
import sample.SampleZipkinApplication;
import tools.AbstractIntegrationTest;
import zipkin.junit.ZipkinRule;
import zipkin.server.EnableZipkinServer;
import java.net.URI;
import java.util.Random;
@@ -33,12 +39,6 @@ import org.springframework.context.annotation.Primary;
import org.springframework.test.context.TestPropertySource;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import integration.ZipkinTests.WaitUntilZipkinIsUpConfig;
import sample.SampleZipkinApplication;
import tools.AbstractIntegrationTest;
import zipkin.junit.ZipkinRule;
import zipkin.server.EnableZipkinServer;
import static java.util.concurrent.TimeUnit.SECONDS;
@RunWith(SpringJUnit4ClassRunner.class)
@@ -67,10 +67,14 @@ public class ZipkinTests extends AbstractIntegrationTest {
public void should_propagate_spans_to_zipkin() {
long traceId = new Random().nextLong();
await().atMost(10, SECONDS).until(httpMessageWithTraceIdInHeadersIsSuccessfullySent(
this.sampleAppUrl + "/hi2", traceId));
await().atMost(10, SECONDS).untilAsserted(() ->
httpMessageWithTraceIdInHeadersIsSuccessfullySent(
this.sampleAppUrl + "/hi2", traceId).run()
);
await().atMost(10, SECONDS).until(allSpansWereRegisteredInZipkinWithTraceIdEqualTo(traceId));
await().atMost(10, SECONDS).untilAsserted(() ->
allSpansWereRegisteredInZipkinWithTraceIdEqualTo(traceId).run()
);
}
@Override

View File

@@ -63,7 +63,7 @@
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.jayway.awaitility</groupId>
<groupId>org.awaitility</groupId>
<artifactId>awaitility</artifactId>
<scope>test</scope>
</dependency>

View File

@@ -25,9 +25,9 @@ import static org.mockito.Mockito.verify;
import java.util.Collection;
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.LinkedBlockingQueue;
import javax.annotation.PostConstruct;
import org.awaitility.Awaitility;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -59,8 +59,6 @@ import org.springframework.integration.annotation.ServiceActivator;
import org.springframework.messaging.Message;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import com.jayway.awaitility.Awaitility;
/**
* @author Dave Syer
*
@@ -93,7 +91,7 @@ public class StreamSpanListenerTests {
this.tracer.close(context);
Awaitility.await().until(() -> assertThat(StreamSpanListenerTests.this.test.spans()).hasSize(1));
Awaitility.await().untilAsserted(() -> assertThat(StreamSpanListenerTests.this.test.spans()).hasSize(1));
}
@Test
@@ -107,7 +105,7 @@ public class StreamSpanListenerTests {
this.tracer.close(context);
Awaitility.await().until(() -> assertThat(StreamSpanListenerTests.this.test.spans()).hasSize(2));
Awaitility.await().untilAsserted(() -> assertThat(StreamSpanListenerTests.this.test.spans()).hasSize(2));
}
void logServerReceived(Span parent) {