Skip to content

Commit

Permalink
Merge pull request #135699 from cockroachdb/blathers/backport-release…
Browse files Browse the repository at this point in the history
…-24.2-135595

release-24.2: cloud: use uuid as bucket name
  • Loading branch information
msbutler authored Nov 19, 2024
2 parents ca06ffd + c58657d commit 3ffa7d9
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 13 deletions.
1 change: 1 addition & 0 deletions pkg/cloud/amazon/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ go_test(
"//pkg/testutils",
"//pkg/testutils/skip",
"//pkg/util/leaktest",
"//pkg/util/uuid",
"@com_github_aws_aws_sdk_go//aws/awserr",
"@com_github_aws_aws_sdk_go//aws/credentials",
"@com_github_aws_aws_sdk_go//aws/request",
Expand Down
12 changes: 6 additions & 6 deletions pkg/cloud/amazon/s3_storage_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import (
"github.com/cockroachdb/cockroach/pkg/testutils"
"github.com/cockroachdb/cockroach/pkg/testutils/skip"
"github.com/cockroachdb/cockroach/pkg/util/leaktest"
"github.com/cockroachdb/cockroach/pkg/util/uuid"
"github.com/cockroachdb/errors"
"github.com/stretchr/testify/require"
)
Expand Down Expand Up @@ -540,11 +541,11 @@ func TestS3BucketDoesNotExist(t *testing.T) {
q.Add(cloud.AuthParam, cloud.AuthParamImplicit)
q.Add(S3RegionParam, "us-east-1")

// Very long, very random bucket name, that hopefully nobody will ever create.
bucket := "VIBK1H88MOJ665V2RAPVH6X3TWUS0HCWTW5A27AFPPLHMABKH7X445K86K1BP2"
u := url.URL{
Scheme: "s3",
Host: bucket,
Scheme: "s3",
// Use UUID to create a random bucket name that does not exist. If this was
// a constent, someone could create the bucket and break the test.
Host: uuid.NewV4().String(),
Path: "backup-test",
RawQuery: q.Encode(),
}
Expand Down Expand Up @@ -575,8 +576,7 @@ func TestS3BucketDoesNotExist(t *testing.T) {
}

_, _, err = s.ReadFile(ctx, "", cloud.ReadOptions{NoFileSize: true})
require.Error(t, err, "")
require.True(t, errors.Is(err, cloud.ErrFileDoesNotExist), "error is not cloud.ErrFileDoesNotExist: %v", err)
require.ErrorIs(t, err, cloud.ErrFileDoesNotExist)
}

func TestAntagonisticS3Read(t *testing.T) {
Expand Down
1 change: 1 addition & 0 deletions pkg/cloud/gcp/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ go_test(
"//pkg/testutils/skip",
"//pkg/util/ioctx",
"//pkg/util/leaktest",
"//pkg/util/uuid",
"@com_github_cockroachdb_errors//:errors",
"@com_github_googleapis_gax_go_v2//apierror",
"@com_github_stretchr_testify//assert",
Expand Down
13 changes: 6 additions & 7 deletions pkg/cloud/gcp/gcs_storage_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import (
"github.com/cockroachdb/cockroach/pkg/testutils/skip"
"github.com/cockroachdb/cockroach/pkg/util/ioctx"
"github.com/cockroachdb/cockroach/pkg/util/leaktest"
"github.com/cockroachdb/errors"
"github.com/cockroachdb/cockroach/pkg/util/uuid"
"github.com/stretchr/testify/require"
"golang.org/x/oauth2/google"
)
Expand Down Expand Up @@ -355,13 +355,13 @@ func TestFileDoesNotExist(t *testing.T) {
)
require.NoError(t, err)
_, _, err = s.ReadFile(context.Background(), "", cloud.ReadOptions{NoFileSize: true})
require.Error(t, err, "")
require.True(t, errors.Is(err, cloud.ErrFileDoesNotExist))
require.ErrorIs(t, err, cloud.ErrFileDoesNotExist)
}

{
// Invalid gsBucket.
gsFile := "gs://cockroach-fixtures-us-east1-invalid/tpch-csv/sf-1/region.tbl?AUTH=implicit"
// Use a random UUID as the name of the bucket that does not exist in order
// to avoid name squating.
gsFile := fmt.Sprintf("gs://%s/tpch-csv/sf-1/region.tbl?AUTH=implicit", uuid.NewV4())
conf, err := cloud.ExternalStorageConfFromURI(gsFile, user)
require.NoError(t, err)

Expand All @@ -373,8 +373,7 @@ func TestFileDoesNotExist(t *testing.T) {
)
require.NoError(t, err)
_, _, err = s.ReadFile(context.Background(), "", cloud.ReadOptions{NoFileSize: true})
require.Error(t, err, "")
require.True(t, errors.Is(err, cloud.ErrFileDoesNotExist))
require.ErrorIs(t, err, cloud.ErrFileDoesNotExist)
}
}

Expand Down

0 comments on commit 3ffa7d9

Please sign in to comment.