pulumi/pkg/testing/integration
Michael Bridgen 171f41f028 Fix AssertHTTPResultWithRetry
`err` is declared outside the retry loop, and tested after all the
retries to see if it is non-nil; however, err is shadowed inside the
loop so will never be non-nil outside. If all the attempts are failures,
it'll time out then try to read the body of the response and probably
panic.

This commit fixes that problem by only assigning to err inside the loop.
A related problem is that failing all the attempts doesn't result in an
error, it just breaks the loop. Again it's possible to get a panic. So:
assign an error value when abandoning the retries.

Also: make sure response bodies are read and closed, to co-operate with
connection pooling.

Lastly, a tweak that helps fail faster: rather than sleeping then seeing
if the deadline has passed, check whether sleeping will break the
deadline. It will always try once, in any case.

Signed-off-by: Michael Bridgen <mbridgen@pulumi.com>
2022-11-15 10:41:54 +00:00
..
command.go Don't disable ambiant providers during tests (#9404) 2022-04-15 11:14:47 +02:00
doc.go Document Go packages (#6009) 2021-01-11 11:07:59 -07:00
program.go feat(programtest): Enable ProgramTest for Azure-Native split modules 2022-10-16 21:43:43 -07:00
program_test.go ci: radical idea - what if slow tests & no stdout makes GH consider runner dead? 2022-03-06 14:52:13 -08:00
pulumi.go Fix tests that have incomplete project config. Correct docs for CreatePulumiRepo 2022-10-04 21:29:42 +02:00
s3reporter.go [breaking] Changing the version of go.mod in sdk / pkg to be v3 2021-04-14 19:32:18 +01:00
util.go Fix AssertHTTPResultWithRetry 2022-11-15 10:41:54 +00:00
util_test.go Fix AssertHTTPResultWithRetry 2022-11-15 10:41:54 +00:00