Skip to content

Commit f4a7c9c

Browse files
olavloitesduskis
authored andcommitted
---
yaml --- r: 22973 b: refs/heads/autosynth-bigtable c: bab445b h: refs/heads/master i: 22971: fc03513
1 parent 2826533 commit f4a7c9c

2 files changed

Lines changed: 19 additions & 2 deletions

File tree

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ refs/heads/autosynth-asset: 7d535c3023644faa89492d4a553d8c403e073fa7
124124
refs/heads/autosynth-automl: 7fcabb1e54ca9ded6bec10f41590d29ece3a6367
125125
refs/heads/autosynth-bigquerydatatransfer: d88aa5aae5fd9d3c6d75bbab1a05162c6d4d948f
126126
refs/heads/autosynth-bigquerystorage: d2c53da3b012e38c662e4df0738042435f19365f
127-
refs/heads/autosynth-bigtable: 554c109518b4d70e6264a1cd2b1a13be65e230f9
127+
refs/heads/autosynth-bigtable: bab445bc0653297ef94543cb97e6c8c440b806a3
128128
refs/heads/autosynth-bigtable-admin: 6379a2bc712f2736c83de0e009b4d26da4fa82ca
129129
refs/heads/autosynth-containeranalysis: 0f377286f60df2b6fd37c183bf170c68dc014cfb
130130
refs/heads/autosynth-datastore: 9acd400b484d6691a080c9152a331d88d24fefc1

branches/autosynth-bigtable/google-cloud-clients/google-cloud-pubsub/src/test/java/com/google/cloud/pubsub/v1/OpenCensusUtilTest.java

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,9 @@
2222
import static com.google.cloud.pubsub.v1.OpenCensusUtil.TRACE_CONTEXT_KEY;
2323
import static org.junit.Assert.assertEquals;
2424
import static org.junit.Assert.assertNotEquals;
25+
import static org.junit.Assert.fail;
2526

27+
import com.google.common.base.Stopwatch;
2628
import com.google.protobuf.ByteString;
2729
import com.google.pubsub.v1.PubsubMessage;
2830
import io.opencensus.common.Scope;
@@ -40,6 +42,7 @@
4042
import io.opencensus.trace.export.SpanData;
4143
import java.util.Collection;
4244
import java.util.List;
45+
import java.util.concurrent.TimeUnit;
4346
import org.junit.Test;
4447

4548
/** Tests for {@link OpenCensusUtil}. */
@@ -123,8 +126,8 @@ private TestMessageReceiver(SpanContext parentLinkedSpan, TagContext originalTag
123126
@Override
124127
public void receiveMessage(PubsubMessage message, AckReplyConsumer consumer) {
125128
assertEquals(originalTagContext, tagger.getCurrentTagContext());
129+
assertSpanCount(1);
126130
Collection<SpanData> spanDatas = runningSpanStore.getRunningSpans(RECEIVER_FILTER);
127-
assertEquals(spanDatas.size(), 1);
128131
for (SpanData spanData : spanDatas) {
129132
List<Link> links = spanData.getLinks().getLinks();
130133
assertEquals(links.size(), 1);
@@ -135,5 +138,19 @@ public void receiveMessage(PubsubMessage message, AckReplyConsumer consumer) {
135138
}
136139
consumer.ack();
137140
}
141+
142+
private void assertSpanCount(int expected) {
143+
Stopwatch watch = Stopwatch.createStarted();
144+
while (true) {
145+
Collection<SpanData> spanDatas = runningSpanStore.getRunningSpans(RECEIVER_FILTER);
146+
if (spanDatas.size() == 1) {
147+
break;
148+
}
149+
Thread.yield();
150+
if (watch.elapsed(TimeUnit.SECONDS) >= 5) {
151+
fail();
152+
}
153+
}
154+
}
138155
}
139156
}

0 commit comments

Comments
 (0)