Skip to content

Commit 2de47ef

Browse files
olavloitesduskis
authored andcommitted
---
yaml --- r: 22519 b: refs/heads/autosynth-automl c: bab445b h: refs/heads/master i: 22517: 94311fc 22515: e70053f 22511: d4ae605
1 parent 25a3ea7 commit 2de47ef

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
@@ -121,7 +121,7 @@ refs/heads/spanner: b01127f885b4611bf1852abb0ce481eeb7fcc131
121121
refs/tags/v0.68.0: 9cc799fcf68c82ab431d425fefa58ef615ce8e5b
122122
refs/tags/v0.69.0: 78f67a29e8b9c46ba01de566a2eae0fd1c03edea
123123
refs/heads/autosynth-asset: 7d535c3023644faa89492d4a553d8c403e073fa7
124-
refs/heads/autosynth-automl: 554c109518b4d70e6264a1cd2b1a13be65e230f9
124+
refs/heads/autosynth-automl: bab445bc0653297ef94543cb97e6c8c440b806a3
125125
refs/heads/autosynth-bigquerydatatransfer: 564833a85642d4194adc025f021e10e723154246
126126
refs/heads/autosynth-bigquerystorage: a75c34ed7a11741669121be69a7021a00f1133ce
127127
refs/heads/autosynth-bigtable: 45891a7178142c84a16d6a0b792f8ecb950a3159

branches/autosynth-automl/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)