Skip to content

[autest] thread_config: fix race and skip on macOS#12940

Open
moonchen wants to merge 1 commit intoapache:masterfrom
moonchen:fix-check-threads-race
Open

[autest] thread_config: fix race and skip on macOS#12940
moonchen wants to merge 1 commit intoapache:masterfrom
moonchen:fix-check-threads-race

Conversation

@moonchen
Copy link
Contributor

@moonchen moonchen commented Mar 4, 2026

check_threads.py now uses a short bounded poll/retry window so thread-count validation doesn’t fail on startup races.

The test is also skipped on macOS because per-thread introspection used by this check is not available there.

check_threads.py now uses a short bounded poll/retry window so thread-count validation doesn’t fail on startup races; the test is also skipped on macOS because per-thread introspection used by this check is not reliably available there.
@moonchen moonchen requested review from bneradt and Copilot March 4, 2026 20:20
@moonchen moonchen self-assigned this Mar 4, 2026
@moonchen moonchen added the AuTest label Mar 4, 2026
@moonchen moonchen added this to 11-Dev Mar 4, 2026
@moonchen moonchen added this to the 11.0.0 milestone Mar 4, 2026
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates the thread_config gold test to be more reliable during ATS startup by adding a bounded poll/retry window for thread-count validation, and it restricts the test to platforms where per-thread introspection is supported.

Changes:

  • Add a bounded poll/retry loop in check_threads.py to avoid thread-count validation failing due to startup races.
  • Skip the thread_config gold test on non-Linux platforms via SkipUnless(IsPlatform("linux")).

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
tests/gold_tests/thread_config/thread_config.test.py Skips the thread configuration test unless running on Linux.
tests/gold_tests/thread_config/check_threads.py Adds retry-based thread counting and expands ATS process matching logic for more robust detection.

try:
threads = p.threads()
except (psutil.NoSuchProcess, psutil.AccessDenied, psutil.ZombieProcess):
return 1, 'Could not inspect ATS process threads.'
Copy link

Copilot AI Mar 4, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

p.threads() failure returns exit code 1 ("Could not inspect ATS process threads."), but count_threads() treats code 1 as a retryable "process not found yet" condition. This can hide a real permission/psutil error for up to the full wait window and makes the exit code ambiguous. Consider using a distinct non-retry exit code for thread-inspection failures (or exclude this case from retry_codes).

Suggested change
return 1, 'Could not inspect ATS process threads.'
return 12, 'Could not inspect ATS process threads.'

Copilot uses AI. Check for mistakes.
Comment on lines +41 to +46
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
Copy link

Copilot AI Mar 4, 2026

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 whether p.cwd() matches ts_path. Since exe() can be relatively expensive and can raise AccessDenied, consider only calling p.exe() after the cwd (and possibly name) filter passes to reduce overhead and avoid unnecessary permission failures during iteration.

Suggested change
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
if process_cwd != ts_path:
continue
if process_name != '[TS_MAIN]' and process_name != 'traffic_server':
process_exe = p.exe()
if os.path.basename(process_exe) != 'traffic_server':
continue

Copilot uses AI. Check for mistakes.
Comment on lines 21 to +23
Test.Summary = 'Test that Trafficserver starts with different thread configurations.'
Test.ContinueOnFail = True
Test.SkipUnless(Condition.IsPlatform("linux"))
Copy link

Copilot AI Mar 4, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR description says the test is skipped on macOS, but this change skips it on all non-Linux platforms (SkipUnless(IsPlatform("linux"))). If the thread introspection works on other supported OSes (e.g., FreeBSD), consider using a macOS-specific skip instead, or update the PR description to match the broader skip behavior.

Copilot uses AI. Check for mistakes.
Copy link
Contributor

@brbzull0 brbzull0 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems we are addressing the same issue #12916
I'm kinda inclined to yours as it catches a few things mine doesn't.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

3 participants