Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

ThomasK33
Copy link
Member

@ThomasK33 ThomasK33 commented Sep 12, 2025

This PR adds a readiness wait to OAuth2 metadata endpoint tests to avoid rare races with server startup. Instead of immediately making HTTP requests, the tests now use testutil.Eventually to retry the requests until they succeed, with a short interval between attempts. This helps prevent flaky tests that might fail due to timing issues during server initialization.

Fixes: coder/internal#996

Fix flake in TestOAuth2AuthorizationServerMetadata by polling the .well-known endpoints until they return 200 and valid JSON, using testutil.Eventually.
Root cause: the test server can accept requests before the real handler is installed in coderdtest, returning 200 with an empty body which causes JSON decode EOF. The readiness loop avoids this race without sleeps and holds under t.Parallel().
This fixes the following issue: coder/internal#996

Change-Id: I466815d35f03bb75ef448d6f3431cd4b6efe2570
Signed-off-by: Thomas Kosiewski <[email protected]>
Copy link
Member Author

This stack of pull requests is managed by Graphite. Learn more about stacking.

@ThomasK33 ThomasK33 requested a review from johnstcn September 12, 2025 21:19
@ThomasK33 ThomasK33 marked this pull request as ready for review September 12, 2025 21:20
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.

Flaky Test: TestOAuth2AuthorizationServerMetadata
1 participant