test: fix flaky allocation metrics test server startup#4445
test: fix flaky allocation metrics test server startup#4445markmandel merged 3 commits intoagones-dev:mainfrom
Conversation
|
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
markmandel
left a comment
There was a problem hiding this comment.
Thanks for tacking this!
| _ = server.Run(ctxHTTP, 0) | ||
| }() | ||
| time.Sleep(300 * time.Millisecond) | ||
| err = wait.PollUntilContextTimeout(context.Background(), 10*time.Millisecond, 5*time.Second, true, func(_ context.Context) (bool, error) { |
There was a problem hiding this comment.
We're moving to using https://pkg.go.dev/github.com/stretchr/testify/require#EventuallyWithT for polling tests -- it gives a much better developer surface and also error messages.
|
/gcbrun |
|
Build Succeeded 🥳 Build Id: 0cd6d6ce-0486-402b-9eee-c8e4d73d0783 The following development artifacts have been built, and will exist for the next 30 days:
A preview of the website (the last 30 builds are retained): To install this version: |
markmandel
left a comment
There was a problem hiding this comment.
Thanks for tackling this! Almost there.
|
|
||
| metricsURL := startMetricsServerForTest(t, server) | ||
|
|
||
| err := wait.PollUntilContextTimeout(context.Background(), 10*time.Millisecond, time.Second, true, func(_ context.Context) (bool, error) { |
There was a problem hiding this comment.
Same thing as well here please - EventuallyWithT.
Also means that if assert.NoError(t, resp.Body.Close()) fails for some reason it will get reported appropriately.
There was a problem hiding this comment.
Ok, thanks, I did that too
|
/gcbrun |
|
Build Succeeded 🥳 Build Id: 770e853b-be34-49ae-930f-42b0cde024bc The following development artifacts have been built, and will exist for the next 30 days:
A preview of the website (the last 30 builds are retained): To install this version: |
|
/gcbrun |
|
Build Succeeded 🥳 Build Id: 49acc863-e448-4988-9ee8-17bff6ffca22 The following development artifacts have been built, and will exist for the next 30 days:
A preview of the website (the last 30 builds are retained): To install this version: |
* test: fix flaky allocation metrics test server startup * test: use EventuallyWithT for metrics readiness poll * test: use EventuallyWithT in start metrics server test --------- Co-authored-by: srpvpn <srpvpn@users.noreply.github.com>
Title
test: fix flaky TestAllocationMetrics port conflict and startup race
Changes:
3001) from the test path.127.0.0.1:0).time.Sleep(300ms)with readiness polling against the metrics endpoint.TestStartMetricsServerto validate server bootstrap helper behavior.Fix #4444