test(storage): unflake PostPolicyV4 test
This test verifies that the upload works using a basic net/http
client, so we need to account for the fact that that client doesn't
include retries.
Fixes
@@ -4588,6 +4588,12 @@ func verifySignedURL(url string, headers map[string][]string, expectedFileBody [
// verifies that it was uploaded correctly
func verifyPostPolicy(pv4 *PostPolicyV4, obj *ObjectHandle, bytesToWrite []byte, statusCodeOnSuccess int) error {
ctx := context.Background()
+ var res *http.Response
+
+ // Request is sent using a vanilla net/http client, so there are no built-in
+ // retries. We must wrap with a retry to prevent flakes.
+ return retry(ctx,
+ func() error {
formBuf := new(bytes.Buffer)
mw := multipart.NewWriter(formBuf)
for fieldName, value := range pv4.Fields {
@@ -4618,11 +4624,13 @@ func verifyPostPolicy(pv4 *PostPolicyV4, obj *ObjectHandle, bytesToWrite []byte,
req.Header.Set("Content-Type", mw.FormDataContentType())
// Send request
- res, err := http.DefaultClient.Do(req)
+ res, err = http.DefaultClient.Do(req)
if err != nil {
return err
}
-
+ return nil
+ },
+ func() error {
// Check response
if g, w := res.StatusCode, statusCodeOnSuccess; g != w {
blob, _ := httputil.DumpResponse(res, true)
@@ -4656,6 +4664,7 @@ func verifyPostPolicy(pv4 *PostPolicyV4, obj *ObjectHandle, bytesToWrite []byte,
return fmt.Errorf("Body mismatch: got - want +\n%s", diff)
}
return nil
+ })
}
func newTestClientWithExplicitCredentials(ctx context.Context, t *testing.T) *Client {
