Skip to content

Commit

Permalink
tools: amend test skipping logic
Browse files Browse the repository at this point in the history
Signed-off-by: Alex Aizman <[email protected]>
  • Loading branch information
alex-aizman committed Jun 23, 2024
1 parent 397e1e2 commit 8f50f04
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 17 deletions.
4 changes: 3 additions & 1 deletion ais/test/scripted_cli_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,12 +120,14 @@ func TestPrefetchLatestRemaisUsingScript(t *testing.T) {
}

func TestCopySyncWithOutOfBandUsingRemaisScript(t *testing.T) {
bck := cliBck
tools.CheckSkip(t, &tools.SkipTestArgs{
Bck: bck,
Long: true,
RequiresRemoteCluster: true,
CloudBck: true,
})

bck := cliBck
var (
bucketName = bck.Cname("")
cmd = exec.Command("./scripts/cp-sync-remais-out-of-band.sh", "--bucket", bucketName)
Expand Down
11 changes: 1 addition & 10 deletions tools/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ func BucketExists(tb testing.TB, proxyURL string, bck cmn.Bck) (bool, error) {
return false, err
}

func isRemoteBucket(tb testing.TB, proxyURL string, bck cmn.Bck) bool {
func isRemoteAndPresentBucket(tb testing.TB, proxyURL string, bck cmn.Bck) bool {
if !bck.IsRemote() {
return false
}
Expand All @@ -120,15 +120,6 @@ func isRemoteBucket(tb testing.TB, proxyURL string, bck cmn.Bck) bool {
return exists
}

func isCloudBucket(tb testing.TB, proxyURL string, bck cmn.Bck) bool {
if !bck.IsCloud() {
return false
}
exists, err := BucketExists(tb, proxyURL, bck)
tassert.CheckFatal(tb, err)
return exists
}

func PutObjRR(bp api.BaseParams, bck cmn.Bck, objName string, objSize int64, cksumType string) error {
reader, err := readers.NewRand(objSize, cksumType)
if err != nil {
Expand Down
21 changes: 15 additions & 6 deletions tools/skip.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,17 +59,26 @@ func CheckSkip(tb testing.TB, args *SkipTestArgs) {
tb.Skipf(fmtSkippingShort, tb.Name())
}
if args.RemoteBck {
tassert.Fatalf(tb, !args.Bck.IsEmpty(), "bucket is missing in the args")
proxyURL := GetPrimaryURL()
if !isRemoteBucket(tb, proxyURL, args.Bck) {
tb.Skipf("%s requires a remote bucket (have %q)", tb.Name(), args.Bck)
if !isRemoteAndPresentBucket(tb, proxyURL, args.Bck) {
tb.Skipf("%s requires a remote in-cluster bucket (have %s)", tb.Name(), args.Bck)
}
}
if args.CloudBck || args.RequiredCloudProvider != "" {
proxyURL := GetPrimaryURL()
if !isCloudBucket(tb, proxyURL, args.Bck) {
tb.Skipf("%s requires a cloud bucket", tb.Name())
tassert.Fatalf(tb, !args.Bck.IsEmpty(), "bucket is missing in the args")
cname := args.Bck.Cname("")
if !args.Bck.IsCloud() {
tb.Skipf("%s requires cloud bucket (have %s)", tb.Name(), cname)
} else if args.RequiredCloudProvider != "" && args.RequiredCloudProvider != args.Bck.Provider {
tb.Skipf("%s requires a cloud bucket with %s provider", tb.Name(), args.RequiredCloudProvider)
tb.Skipf("%s requires cloud bucket with %s provider (have %s)", tb.Name(), args.RequiredCloudProvider, cname)
} else {
proxyURL := GetPrimaryURL()
exists, err := BucketExists(tb, proxyURL, args.Bck)
tassert.CheckFatal(tb, err)
if !exists {
tb.Skipf("%s requires cloud bucket %s to be in-cluster", tb.Name(), cname)
}
}
}

Expand Down

0 comments on commit 8f50f04

Please sign in to comment.