Fix flaky CI test by replacing external dependency#769
Merged
Conversation
…rver The TestExecuteHook_CurlWebhook test was failing intermittently in CI with 'signal: killed' errors due to external dependency on httpbin.org. This fix replaces the external HTTP request with a local httptest.Server to eliminate network-related flakiness and make the test deterministic. Changes: - Replace httpbin.org with httptest.NewServer for reliable testing - Add request verification to ensure the webhook functionality works - Maintain the same test coverage while eliminating external dependency Co-authored-by: Maksym Pavlenko <[email protected]>
|
|
||
| func TestExecuteHook_CurlWebhook(t *testing.T) { | ||
| // Create a local test server to avoid external dependencies | ||
| receivedData := "" |
Contributor
There was a problem hiding this comment.
Race condition: The receivedData and receivedHeaders variables are accessed concurrently without synchronization. The test goroutine writes to these variables in the HTTP handler while the main test goroutine reads them in the assertions. This could lead to flaky test behavior.
Suggested change
| receivedData := "" | |
| // Create a local test server to avoid external dependencies | |
| var receivedData string | |
| var receivedHeaders = make(map[string]string) | |
| var mu sync.Mutex |
Contributor
|
Race condition found: The test has concurrent access to shared variables without synchronization. The HTTP handler goroutine writes to receivedData and receivedHeaders while the main test goroutine reads them, which can cause data races and potentially flaky behavior. Fix: Add sync.Mutex and protect all access to the shared variables. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #768
The
TestExecuteHook_CurlWebhooktest was failing intermittently in CI with 'signal: killed' errors due to external dependency on httpbin.org. This fix replaces the external HTTP request with a local httptest.Server to eliminate network-related flakiness and make the test deterministic.Changes:
Generated with Claude Code