-
Notifications
You must be signed in to change notification settings - Fork 851
[autest] thread_config: fix race and skip on macOS #12940
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -19,92 +19,130 @@ | |||||
|
|
||||||
| import psutil | ||||||
| import argparse | ||||||
| import os | ||||||
| import sys | ||||||
|
|
||||||
|
|
||||||
| def count_threads(ts_path, etnet_threads, accept_threads, task_threads, aio_threads): | ||||||
|
|
||||||
| for p in psutil.process_iter(['name', 'cwd', 'threads']): | ||||||
|
|
||||||
| # Find the pid corresponding to the ats process we started in autest. | ||||||
| # It needs to match the process name and the binary path. | ||||||
| # If autest can expose the pid of the process this is not needed anymore. | ||||||
| if p.name() == '[TS_MAIN]' and p.cwd() == ts_path: | ||||||
|
|
||||||
| etnet_check = set() | ||||||
| accept_check = set() | ||||||
| task_check = set() | ||||||
| aio_check = set() | ||||||
|
|
||||||
| for t in p.threads(): | ||||||
|
|
||||||
| import time | ||||||
|
|
||||||
| COUNT_THREAD_WAIT_SECONDS = 10.0 | ||||||
| COUNT_THREAD_POLL_SECONDS = 0.1 | ||||||
|
|
||||||
|
|
||||||
| def _count_threads_once(ts_path, etnet_threads, accept_threads, task_threads, aio_threads): | ||||||
| """ | ||||||
| Return (code, message) for a single snapshot of ATS thread state. | ||||||
| """ | ||||||
| for p in psutil.process_iter(): | ||||||
| try: | ||||||
| # Find the pid corresponding to the ats process we started in autest. | ||||||
| # It needs to match the process name and the binary path. | ||||||
| # If autest can expose the pid of the process this is not needed anymore. | ||||||
| process_name = p.name() | ||||||
| process_cwd = p.cwd() | ||||||
| process_exe = p.exe() | ||||||
| if process_cwd != ts_path: | ||||||
| continue | ||||||
| if process_name != '[TS_MAIN]' and process_name != 'traffic_server' and os.path.basename( | ||||||
| process_exe) != 'traffic_server': | ||||||
| continue | ||||||
| except (psutil.NoSuchProcess, psutil.AccessDenied, psutil.ZombieProcess): | ||||||
| continue | ||||||
|
|
||||||
| etnet_check = set() | ||||||
| accept_check = set() | ||||||
| task_check = set() | ||||||
| aio_check = set() | ||||||
|
|
||||||
| try: | ||||||
| threads = p.threads() | ||||||
| except (psutil.NoSuchProcess, psutil.AccessDenied, psutil.ZombieProcess): | ||||||
| return 1, 'Could not inspect ATS process threads.' | ||||||
|
||||||
| return 1, 'Could not inspect ATS process threads.' | |
| return 12, 'Could not inspect ATS process threads.' |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -20,6 +20,7 @@ | |
|
|
||
| Test.Summary = 'Test that Trafficserver starts with different thread configurations.' | ||
| Test.ContinueOnFail = True | ||
| Test.SkipUnless(Condition.IsPlatform("linux")) | ||
|
Comment on lines
21
to
+23
|
||
|
|
||
| ts = Test.MakeATSProcess('ts-1_exec-0_accept-1_task-1_aio') | ||
| ts.Disk.records_config.update( | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the process scan loop,
p.exe()is fetched before checking whetherp.cwd()matchests_path. Sinceexe()can be relatively expensive and can raiseAccessDenied, consider only callingp.exe()after thecwd(and possiblyname) filter passes to reduce overhead and avoid unnecessary permission failures during iteration.