[audit][tests-docs] Widespread sleep-based synchronization in autests (109 'sleep N' steps, 33 time.sleep calls) invites timing flakiness
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 48/100
Research direction
Start with tests/gold_tests/pluginTest/traffic_dump/traffic_dump.test.py around lines 343-362, then review the other named .test.py files and Python helpers for the reported sleep counts. Check the existing autest Ready, Condition-based file or log waiting, and traffic_ctl polling patterns first. Done means replacing timing-based synchronization with event or deadline-based waits and adding CI lint coverage for new bare sleep commands.
Written by the indexing model from the issue text.
Description
Severity: medium · Category: testing
Location: tests/gold_tests/pluginTest/traffic_dump/traffic_dump.test.py:359
What's wrong
gold_tests contains 109 'sleep N' shell-command test steps in .test.py files plus 33 time.sleep() calls in Python helpers, many of which gate assertions on wall-clock guesses rather than events. traffic_dump.test.py is representative: after 'traffic_ctl plugin msg traffic_dump.limit 0' it runs a test step whose Command is literally 'sleep 2' (line 343, comment 'Give ATS some time to process the change') and later 'sleep 2' at line 359 followed immediately by 'file.Exists = False' for the expected-absent dump file — a negative assertion that passes vacuously if the plugin is merely slow, and six such sleep-2 steps exist in this one file. Other examples: block_errors.test.py uses six 'sleep 30' watcher processes; slice_prefetch.test.py:138 prefixes a curl with 'sleep 5'; stek_share.test.py:293 'sleep 10 && curl'. One test has already been permanently disabled for exactly this failure mode (see log_retention finding).
Evidence
traffic_dump.test.py:358-362: '# Sleep 2 seconds to give the replay plugin plenty of time to write the file.'
'tr.Processes.Default.Command = "sleep 2"' / 'file = tr.Disk.File(replay_file_session_12)' / 'file.Exists = False'.
// Counts: grep for sleep in *.test.py = 109 lines; time.sleep in tests/gold_tests/**/*.py = 33.
Suggested fix
Replace timing sleeps with condition polling: autest Ready conditions, Condition-based file/log waiting (ATS already has 'await' log-watch patterns), or traffic_ctl polling loops with deadline. Add an autest lint (tests/CI) flagging bare 'sleep' commands in new tests.
Filed from an automated multi-lens codebase audit. Full report: CODEBASE_AUDIT.md / audit-report.html on branch claude/codebase-audit-review-9nw7vz.
- Dominant language
- C++
- Stars
- 0
- Forks
- 0
- Avg merge
- 8h 2m
- Merged PRs (30d)
- 21
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from JakeChampion/trafficserver
-
10.2 area:standards audit severity:low
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
-
10.2 area:plugin-api audit severity:medium
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
-
area:httpsm audit severity:medium
Difficulty 1/5 Under an hour Newbie friendliness 86/100
-
area:security audit severity:medium
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
-
[10.2][hdrs] obs-fold continuation silently dropped when CRLF lands on an input-buffer boundary Open10.2 area:hdrs audit severity:medium
Difficulty 4/5 3-5 days Newbie friendliness 48/100
All issues in JakeChampion/trafficserver
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 86/100
-
Sensor initialization takes very long when `--initial-sim-time` is set to current UNIX timestamp Open
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
gazebosim/gz-sensors#662 · 1 comment ·
-
enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
-
comp-datalake
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
ClickHouse/ClickHouse#121222 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
LadybirdBrowser/ladybird#12123 ·