Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit1ae49de

Browse files
fix: Fix flaky test (#1254)
1 parentbb5f3d1 commit1ae49de

File tree

1 file changed

+20
-15
lines changed

1 file changed

+20
-15
lines changed

‎tests/unit/pubsub_v1/publisher/test_publisher_client.py‎

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -332,21 +332,26 @@ def test_opentelemetry_publish(creds, span_exporter):
332332
client.publish(TOPIC,b"message")
333333
spans=span_exporter.get_finished_spans()
334334

335-
# Span 1: Publisher Flow control span
336-
# Span 2: Publisher Batching span
337-
# Publish Create Span would still be active, and hence not exported.
338-
flow_control_span=spans[0]
339-
assertflow_control_span.name=="publisher flow control"
340-
assertflow_control_span.kind==trace.SpanKind.INTERNAL
341-
# Assert the Publisher Flow Control Span has a parent(the Publish Create
342-
# span is still active, and hence unexported. So, the value of parent cannot
343-
# be asserted)
344-
assertflow_control_span.parentisnotNone
345-
346-
batching_span=spans[1]
347-
assertbatching_span.name=="publisher batching"
348-
assertbatching_span.kind==trace.SpanKind.INTERNAL
349-
assertbatching_span.parentisnotNone
335+
# Publisher Flow control and batching spans would be ended in the
336+
# publish() function and are deterministically expected to be in the
337+
# list of exported spans. The Publish Create span and Publish RPC span
338+
# are run async and end at a non-deterministic time. Hence,
339+
# asserting that we have atleast two spans(flow control and batching span)
340+
assertlen(spans)>=2
341+
flow_control_span=None
342+
batching_span=None
343+
forspaninspans:
344+
ifspan.name=="publisher flow control":
345+
flow_control_span=span
346+
assertflow_control_span.kind==trace.SpanKind.INTERNAL
347+
assertflow_control_span.parentisnotNone
348+
ifspan.name=="publisher batching":
349+
batching_span=span
350+
assertbatching_span.kind==trace.SpanKind.INTERNAL
351+
assertbatching_span.parentisnotNone
352+
353+
assertflow_control_spanisnotNone
354+
assertbatching_spanisnotNone
350355

351356

352357
deftest_init_w_api_endpoint(creds):

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp