From 01d7d109cbd3396d3e7b719fb911369f1c67927d Mon Sep 17 00:00:00 2001 From: Julio Lopez Date: Wed, 22 Dec 2021 20:40:56 -0800 Subject: [PATCH] s3/test: fix minio bucket creation in tests (#1617) --- repo/blob/s3/s3_storage_test.go | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/repo/blob/s3/s3_storage_test.go b/repo/blob/s3/s3_storage_test.go index 1c6fd6d44..28a37d769 100644 --- a/repo/blob/s3/s3_storage_test.go +++ b/repo/blob/s3/s3_storage_test.go @@ -257,7 +257,7 @@ func TestS3StorageMinio(t *testing.T) { DoNotUseTLS: true, } - getOrCreateBucket(t, options) + createBucket(t, options) testStorage(t, options, true, blob.PutOptions{}) } @@ -292,7 +292,7 @@ func TestS3StorageMinioSelfSignedCert(t *testing.T) { DoNotVerifyTLS: true, } - getOrCreateBucket(t, options) + createBucket(t, options) testStorage(t, options, true, blob.PutOptions{}) } @@ -333,7 +333,7 @@ func TestS3StorageMinioSTS(t *testing.T) { kopiaAccessKeyID, kopiaSecretKey, kopiaSessionToken := createMinioSessionToken(t, minioEndpoint, minioRootAccessKeyID, minioRootSecretAccessKey, minioBucketName) - getOrCreateBucket(t, &Options{ + createBucket(t, &Options{ Endpoint: minioEndpoint, AccessKeyID: minioRootAccessKeyID, SecretAccessKey: minioRootSecretAccessKey, @@ -518,6 +518,14 @@ func getOrCreateBucket(tb testing.TB, opt *Options) { getOrMakeBucket(tb, minioClient, opt, false) } +func createBucket(tb testing.TB, opt *Options) { + tb.Helper() + + minioClient := createClient(tb, opt) + + makeBucket(tb, minioClient, opt, false) +} + func getOrMakeBucket(tb testing.TB, cli *minio.Client, opt *Options, objectLocking bool) { tb.Helper() @@ -532,6 +540,14 @@ func getOrMakeBucket(tb testing.TB, cli *minio.Client, opt *Options, objectLocki return } + makeBucket(tb, cli, opt, objectLocking) +} + +func makeBucket(tb testing.TB, cli *minio.Client, opt *Options, objectLocking bool) { + tb.Helper() + + ctx := testlogging.Context(tb) + if err := cli.MakeBucket(ctx, opt.BucketName, minio.MakeBucketOptions{ Region: opt.Region, ObjectLocking: objectLocking,