Add retries when creating S3 Storage obj in test
It is observed that travis CI fails sometimes due
to access key validation issue in TestS3StorageWithSessionToken.
Assuming this issue is due to eventual consistency,
we have added retries while creating S3 Storage obj
"github.com/minio/minio/pkg/madmin"
"github.com/kopia/kopia/internal/blobtesting"
+ "github.com/kopia/kopia/internal/retry"
"github.com/kopia/kopia/repo/blob"
)
@@ -85,7 +86,8 @@ func testStorage(t *testing.T, accessID, secretKey, sessionToken string) {
data := make([]byte, 8)
rand.Read(data) //nolint:errcheck
- st, err := New(context.Background(), &Options{
+ attempt := func() (interface{}, error) {
+ return New(context.Background(), &Options{
AccessKeyID: accessID,
SecretAccessKey: secretKey,
SessionToken: sessionToken,
@@ -93,10 +95,14 @@ func testStorage(t *testing.T, accessID, secretKey, sessionToken string) {
BucketName: bucketName,
Prefix: fmt.Sprintf("test-%v-%x-", time.Now().Unix(), data),
})
+ }
+
+ v, err := retry.WithExponentialBackoff("New() S3 storage", attempt, func(err error) bool { return err != nil })
if err != nil {
t.Fatalf("err: %v", err)
}
+ st := v.(blob.Storage)
blobtesting.VerifyStorage(ctx, t, st)
blobtesting.AssertConnectionInfoRoundTrips(ctx, t, st)
