Skip to content

Commit 8ce0ec5

Browse files
committed
move testagent test
1 parent 10b3c45 commit 8ce0ec5

File tree

4 files changed

+29
-29
lines changed

4 files changed

+29
-29
lines changed

tests/integration/test_integration_snapshots.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -352,3 +352,24 @@ def test_encode_span_with_large_unicode_string_attributes(encoding):
352352
with override_global_config(dict(_trace_api=encoding)):
353353
with tracer.trace(name="á" * 25000, resource="â" * 25001) as span:
354354
span.set_tag(key="å" * 25001, value="ä" * 2000)
355+
356+
357+
@pytest.mark.snapshot
358+
@pytest.mark.subprocess(env={"DD_TRACE_PARTIAL_FLUSH_ENABLED": "true", "DD_TRACE_PARTIAL_FLUSH_MIN_SPANS": "2"})
359+
def test_aggregator_partial_flush_finished_counter_out_of_sync():
360+
"""Regression test for IndexError when num_finished counter is out of sync with finished spans."""
361+
from ddtrace import tracer
362+
363+
span1 = tracer.start_span("span1")
364+
span2 = tracer.start_span("span2", child_of=span1)
365+
span3 = tracer.start_span("span3", child_of=span1)
366+
# Manually set duration_ns before finish() to simulate finished state
367+
# This creates edge case: span1 appears finished but hasn't gone through on_span_finish yet
368+
span1.duration_ns = 1
369+
# span2 finishes, incrementing num_finished to 1
370+
span2.finish()
371+
# span1.finish() increments num_finished to 2, triggering partial flush check (2 >= 2)
372+
# remove_finished() may return empty if span1 was already processed/removed
373+
# Without defensive check, accessing finished[0] would raise IndexError
374+
span1.finish()
375+
span3.finish()
Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,18 +10,18 @@
1010
"error": 0,
1111
"meta": {
1212
"_dd.p.dm": "-0",
13-
"_dd.p.tid": "6927e33800000000",
13+
"_dd.p.tid": "6928928300000000",
1414
"language": "python",
15-
"runtime-id": "ad4d778d938e4a2cb585384bd0b7eabf"
15+
"runtime-id": "3f1e5366e3024949b5ea4186ef167625"
1616
},
1717
"metrics": {
1818
"_dd.py.partial_flush": 2.0,
1919
"_dd.tracer_kr": 1.0,
2020
"_sampling_priority_v1": 1.0,
21-
"process_id": 49860.0
21+
"process_id": 35909.0
2222
},
2323
"duration": 1,
24-
"start": 1764221752629842000
24+
"start": 1764266627479686000
2525
},
2626
{
2727
"name": "span2",
@@ -33,7 +33,7 @@
3333
"type": "",
3434
"error": 0,
3535
"duration": 12000,
36-
"start": 1764221752629863000
36+
"start": 1764266627479706000
3737
},
3838
{
3939
"name": "span3",
@@ -44,6 +44,6 @@
4444
"parent_id": 1,
4545
"type": "",
4646
"error": 0,
47-
"duration": 10000,
48-
"start": 1764221752629872000
47+
"duration": 11000,
48+
"start": 1764266627479714000
4949
}]]

tests/suitespec.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,7 @@ suites:
265265
- '@futures'
266266
- '@ci_visibility'
267267
- tests/tracer/*
268-
- tests/snapshots/test*
268+
- tests/snapshots/test_*
269269
retry: 2
270270
runner: riot
271271
vendor:

tests/tracer/test_processors.py

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -387,27 +387,6 @@ def test_aggregator_partial_flush_2_spans():
387387
assert parent.get_metric("_dd.py.partial_flush") is None
388388

389389

390-
@pytest.mark.snapshot
391-
@pytest.mark.subprocess(env={"DD_TRACE_PARTIAL_FLUSH_ENABLED": "true", "DD_TRACE_PARTIAL_FLUSH_MIN_SPANS": "2"})
392-
def test_aggregator_partial_flush_finished_counter_out_of_sync():
393-
"""Regression test for IndexError when num_finished counter is out of sync with finished spans."""
394-
from ddtrace import tracer
395-
396-
span1 = tracer.start_span("span1")
397-
span2 = tracer.start_span("span2", child_of=span1)
398-
span3 = tracer.start_span("span3", child_of=span1)
399-
# Manually set duration_ns before finish() to simulate finished state
400-
# This creates edge case: span1 appears finished but hasn't gone through on_span_finish yet
401-
span1.duration_ns = 1
402-
# span2 finishes, incrementing num_finished to 1
403-
span2.finish()
404-
# span1.finish() increments num_finished to 2, triggering partial flush check (2 >= 2)
405-
# remove_finished() may return empty if span1 was already processed/removed
406-
# Without defensive check, accessing finished[0] would raise IndexError
407-
span1.finish()
408-
span3.finish()
409-
410-
411390
@pytest.mark.subprocess(env={"DD_TRACE_PARTIAL_FLUSH_ENABLED": "true", "DD_TRACE_PARTIAL_FLUSH_MIN_SPANS": "2"})
412391
def test_trace_top_level_span_processor_partial_flushing():
413392
"""Parent span and child span have the same service name"""

0 commit comments

Comments
 (0)