Added circle.ci integration

- also limited to 5 seconds awaits
This commit is contained in:
Marcin Grzejszczak
2016-07-11 15:14:21 +02:00
parent 81f70ff071
commit f199321878
13 changed files with 57 additions and 63 deletions

View File

@@ -16,9 +16,12 @@
package org.springframework.cloud.sleuth.instrument.hystrix;
import java.util.concurrent.atomic.AtomicReference;
import com.jayway.awaitility.Awaitility;
import com.netflix.hystrix.contrib.javanica.annotation.HystrixCommand;
import com.netflix.hystrix.strategy.HystrixPlugins;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.BeforeClass;
@@ -38,8 +41,7 @@ import org.springframework.context.annotation.Configuration;
import org.springframework.test.annotation.DirtiesContext;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import java.util.concurrent.atomic.AtomicReference;
import static java.util.concurrent.TimeUnit.SECONDS;
import static org.assertj.core.api.BDDAssertions.then;
import static org.springframework.cloud.sleuth.assertions.SleuthAssertions.then;
@@ -89,7 +91,7 @@ public class HystrixAnnotationsIntegrationTests {
private void thenSpanInHystrixThreadIsContinued(final Span span) {
then(span).isNotNull();
Awaitility.await().until(new Runnable() {
Awaitility.await().atMost(5, SECONDS).until(new Runnable() {
@Override
public void run() {
then(HystrixAnnotationsIntegrationTests.this.catcher).isNotNull();
@@ -103,7 +105,7 @@ public class HystrixAnnotationsIntegrationTests {
}
private void thenSpanInHystrixThreadIsCreated() {
Awaitility.await().until(new Runnable() {
Awaitility.await().atMost(5, SECONDS).until(new Runnable() {
@Override
public void run() {
then(HystrixAnnotationsIntegrationTests.this.catcher.getSpan())

View File

@@ -29,6 +29,7 @@ import rx.plugins.RxJavaPlugins;
import rx.schedulers.Schedulers;
import static com.jayway.awaitility.Awaitility.await;
import static java.util.concurrent.TimeUnit.SECONDS;
import static org.springframework.cloud.sleuth.assertions.SleuthAssertions.then;
@RunWith(SpringJUnit4ClassRunner.class)
@@ -65,7 +66,7 @@ public class SleuthRxJavaTests {
then(this.caller.toString()).isEqualTo("actual_action");
then(this.tracer.getCurrentSpan()).isNull();
await().until(() -> then(this.listener.getEvents()).hasSize(1));
await().atMost(5, SECONDS).until(() -> 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, "rxjava");

View File

@@ -33,6 +33,7 @@ import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import static com.jayway.awaitility.Awaitility.await;
import static java.util.concurrent.TimeUnit.SECONDS;
import static org.springframework.cloud.sleuth.assertions.SleuthAssertions.then;
@RunWith(SpringJUnit4ClassRunner.class)
@@ -44,18 +45,18 @@ public class TracingOnScheduledTests {
@Test
public void should_have_span_set_after_scheduled_method_has_been_executed() {
await().until(spanIsSetOnAScheduledMethod());
await().atMost(5, SECONDS).until(spanIsSetOnAScheduledMethod());
}
@Test
public void should_have_a_new_span_set_each_time_a_scheduled_method_has_been_executed() {
Span firstSpan = this.beanWithScheduledMethod.getSpan();
await().until(differentSpanHasBeenSetThan(firstSpan));
await().atMost(5, SECONDS).until(differentSpanHasBeenSetThan(firstSpan));
}
@Test
public void should_not_span_in_the_scheduled_class_that_matches_skip_pattern() throws Exception {
await().untilAtomic(this.beanWithScheduledMethodToBeIgnored.isExecuted(), Matchers.is(true));
await().atMost(5, SECONDS).untilAtomic(this.beanWithScheduledMethodToBeIgnored.isExecuted(), Matchers.is(true));
then(this.beanWithScheduledMethodToBeIgnored.getSpan()).isNull();
}

View File

@@ -21,6 +21,7 @@ import org.springframework.scheduling.annotation.Async;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import static java.util.concurrent.TimeUnit.SECONDS;
import static org.springframework.cloud.sleuth.assertions.SleuthAssertions.then;
@RunWith(SpringJUnit4ClassRunner.class)
@@ -49,7 +50,7 @@ public class TraceAsyncIntegrationTests {
}
private void thenTraceIdIsPassedFromTheCurrentThreadToTheAsyncOne(final Span span) {
Awaitility.await().until(new Runnable() {
Awaitility.await().atMost(5, SECONDS).until(new Runnable() {
@Override
public void run() {
then(TraceAsyncIntegrationTests.this.classPerformingAsyncLogic.getSpan())

View File

@@ -53,6 +53,7 @@ import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;
import static com.jayway.awaitility.Awaitility.await;
import static java.util.concurrent.TimeUnit.SECONDS;
import static org.assertj.core.api.BDDAssertions.then;
import static org.springframework.cloud.sleuth.assertions.SleuthAssertions.then;
@@ -86,7 +87,7 @@ public class TraceFilterCustomExtractorTests {
ResponseEntity<Map> responseHeaders = this.restTemplate.exchange(requestEntity,
Map.class);
await().until(() -> then(this.accumulator.getSpans().stream().filter(
await().atMost(5, SECONDS).until(() -> then(this.accumulator.getSpans().stream().filter(
span -> span.getSpanId() == spanId).findFirst().get())
.hasTraceIdEqualTo(traceId));
then(responseHeaders.getBody())

View File

@@ -22,6 +22,7 @@ import org.springframework.test.web.servlet.setup.DefaultMockMvcBuilder;
import static com.jayway.awaitility.Awaitility.await;
import static java.util.Arrays.asList;
import static java.util.concurrent.TimeUnit.SECONDS;
import static java.util.stream.Collectors.toList;
import static org.assertj.core.api.BDDAssertions.then;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
@@ -46,7 +47,7 @@ public class MultipleHopsIntegrationTests extends AbstractMvcIntegrationTest {
this.mockMvc.perform(get("/greeting")).andExpect(
MockMvcResultMatchers.status().isOk());
await().until(() -> {
await().atMost(5, SECONDS).until(() -> {
then(this.arrayListSpanAccumulator.getSpans().stream().map(Span::getName)
.collect(
toList())).containsAll(asList("http:/greeting", "message:greetings",