Skip to content

Provider URL validation tests: count only the lookups the code under test made - #12771

Merged
danielhanchen merged 1 commit into
mainfrom
ci-provider-dns-own-hosts
Oct 5, 2026
Merged

danielhanchen merged 1 commit into
mainfrom
ci-provider-dns-own-hosts

Conversation

@danielhanchen

Copy link
Copy Markdown
Member

Summary

Two tests in studio/backend/tests/test_provider_base_url_validation.py fail intermittently on PRs that do not touch the provider code:

Both pass in isolation on main. Both are off by exactly one.

Cause

The tests replace socket.getaddrinfo for the whole process and count every call the fake receives. Any other thread in the same xdist worker that resolves a name while the patch is in place lands in the fake too and is counted, for example a client or background refresh left behind by an earlier test. The fakes also make that unrelated caller sleep 30 seconds. The product is behaving correctly. The count is reading lookups it did not make.

Change

  • New helper _for_test_hosts(fake): answers this file's .example hosts with the fake and passes every other lookup to the real resolver.
  • Used in the five tests that count calls: the two above, plus test_dns_alias_verdict_is_cached, test_the_opt_in_path_shares_the_one_lookup and test_the_opt_in_path_does_not_re_resolve_after_a_timeout, which have the same exposure.
  • New test_a_lookup_from_another_thread_is_not_counted pins the routing. A concurrent getaddrinfo("localhost") from another thread must not reach the fake. Without the routing it fails with ['localhost', 'route.example'] == ['route.example'].

Verification

test_provider_base_url_validation.py: 131 passed.

…test made

socket.getaddrinfo is patched process-wide, so a lookup from any other thread in
the xdist worker also reached the fake and was counted: 'assert 33 == 32' in
test_stalled_lookups_do_not_pile_up (#12759) and 'assert 3 == 2' in
test_a_timed_out_lookup_is_not_remembered (#12750), on PRs that do not touch the
provider code. Route this file's .example hosts to the fake and everything else
to the real resolver in the five tests that count calls, and pin the routing.
@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 5, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-05T19:04:53.765438Z 35b4393 Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. You're on a roll.

Reviewed commit: 35b43934db

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Oct 5, 2026
@danielhanchen
danielhanchen merged commit e3e67e0 into main Oct 5, 2026
@danielhanchen
danielhanchen deleted the ci-provider-dns-own-hosts branch October 5, 2026 19:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant