storage: unflake content encoding test

Add retry for file upload in
TestIntegration_NewReaderWithContentEncodingGzip.

The client should be retrying this error already, but
it isn't, perhaps due to google-api-go-client#392. I'll
see if this retry can be removed after fixing this issue.

Fixes #1968.

Change-Id: I63a4d1878b982161892dd8018d32db8410a7b455
Reviewed-on: https://code-review.googlesource.com/c/gocloud/+/56010
Reviewed-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Cody Oss <codyoss@google.com>
diff --git a/storage/integration_test.go b/storage/integration_test.go
index 44d034c..ed3cf2b 100644
--- a/storage/integration_test.go
+++ b/storage/integration_test.go
@@ -2970,22 +2970,30 @@
 	bkt := client.Bucket(uidSpace.New())
 	h.mustCreate(bkt, projectID, nil)
 	defer h.mustDeleteBucket(bkt)
-
 	obj := bkt.Object("decompressive-transcoding")
-	// Firstly upload the gzip compressed file.
-	w := obj.NewWriter(ctx)
 	original := bytes.Repeat([]byte("a"), 4<<10)
-	// Compress and upload the content.
-	gzw := gzip.NewWriter(w)
-	if _, err := gzw.Write(original); err != nil {
-		t.Fatalf("Failed to compress content: %v", err)
-	}
-	if err := gzw.Close(); err != nil {
-		t.Fatalf("Failed to compress content: %v", err)
-	}
-	if err := w.Close(); err != nil {
-		t.Fatalf("Failed to finish uploading the file: %v", err)
-	}
+
+	// Wrap the file upload in a retry.
+	// TODO: Investigate removing retry after resolving
+	// https://github.com/googleapis/google-api-go-client/issues/392.
+	err := retry(ctx, func() error {
+		// Firstly upload the gzip compressed file.
+		w := obj.NewWriter(ctx)
+		// Compress and upload the content.
+		gzw := gzip.NewWriter(w)
+		if _, err := gzw.Write(original); err != nil {
+			return fmt.Errorf("Failed to compress content: %v", err)
+		}
+		if err := gzw.Close(); err != nil {
+			return fmt.Errorf("Failed to compress content: %v", err)
+		}
+		if err := w.Close(); err != nil {
+			return fmt.Errorf("Failed to finish uploading the file: %v", err)
+		}
+		return nil
+	},
+		nil)
+
 	defer h.mustDeleteObject(obj)
 
 	// Now update the Content-Encoding and Content-Type to enable