pulumi/pkg/testing
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
..
integration Fix AssertHTTPResultWithRetry 2022-11-15 10:41:54 +00:00