Skip to content

"rsync for cloud storage" - Google Drive, S3, Dropbox, Backblaze B2, One Drive, Swift, Hubic, Wasabi, Google Cloud Storage, Azure Blob, Azure Files, Yandex Files

azureblob and fstests - Modify integration tests to include new optional setting to test SetTier on only few supported tiers.

sandeepkrub94d87ae2dc8
diff --git a/backend/azureblob/azureblob.go b/backend/azureblob/azureblob.go
index 89731cf77..192a5236d 100644
--- a/backend/azureblob/azureblob.go
+++ b/backend/azureblob/azureblob.go
@@ -191,19 +191,6 @@ func validateAccessTier(tier string) bool {
}
}
-// validAccessTiers returns list of supported storage tiers on azureblob fs
-func validAccessTiers() []string {
- validTiers := [...]azblob.AccessTierType{azblob.AccessTierHot, azblob.AccessTierCool,
- azblob.AccessTierArchive}
-
- var tiers [len(validTiers)]string
-
- for i, tier := range validTiers {
- tiers[i] = string(tier)
- }
- return tiers[:]
-}
-
// retryErrorCodes is a slice of error codes that we will retry
var retryErrorCodes = []int{
401, // Unauthorized (eg "Token has expired")
@@ -321,7 +308,6 @@ func NewFs(name, root string, m configmap.Mapper) (fs.Fs, error) {
BucketBased: true,
SetTier: true,
GetTier: true,
- ListTiers: true,
}).Fill(f)
if f.root != "" {
f.root += "/"
@@ -1337,11 +1323,6 @@ func (o *Object) GetTier() string {
return string(o.accessTier)
}
-// ListTiers returns list of storage tiers supported on this object
-func (o *Object) ListTiers() []string {
- return validAccessTiers()
-}
-
// Check the interfaces are satisfied
var (
_ fs.Fs = &Fs{}
diff --git a/backend/azureblob/azureblob_internal_test.go b/backend/azureblob/azureblob_internal_test.go
index 68dc6a517..017f27d12 100644
--- a/backend/azureblob/azureblob_internal_test.go
+++ b/backend/azureblob/azureblob_internal_test.go
@@ -11,9 +11,7 @@ import (
func (f *Fs) InternalTest(t *testing.T) {
// Check first feature flags are set on this
// remote
- enabled := f.Features().ListTiers
- assert.True(t, enabled)
- enabled = f.Features().SetTier
+ enabled := f.Features().SetTier
assert.True(t, enabled)
enabled = f.Features().GetTier
assert.True(t, enabled)
diff --git a/backend/azureblob/azureblob_test.go b/backend/azureblob/azureblob_test.go
index 3a36d71de..d752b2dec 100644
--- a/backend/azureblob/azureblob_test.go
+++ b/backend/azureblob/azureblob_test.go
@@ -14,7 +14,8 @@ import (
// TestIntegration runs integration tests against the remote
func TestIntegration(t *testing.T) {
fstests.Run(t, &fstests.Opt{
- RemoteName: "TestAzureBlob:",
- NilObject: (*azureblob.Object)(nil),
+ RemoteName: "TestAzureBlob:",
+ NilObject: (*azureblob.Object)(nil),
+ TiersToTest: []string{"Hot", "Cool"},
})
}
diff --git a/fstest/fstests/fstests.go b/fstest/fstests/fstests.go
index 9440f809b..073933234 100644
--- a/fstest/fstests/fstests.go
+++ b/fstest/fstests/fstests.go
@@ -137,9 +137,9 @@ type Opt struct {
RemoteName string
NilObject fs.Object
ExtraConfig []ExtraConfigItem
- SkipBadWindowsCharacters bool // skips unusable characters for windows if set
- SkipFsMatch bool // if set skip exact matching of Fs value
-
+ SkipBadWindowsCharacters bool // skips unusable characters for windows if set
+ SkipFsMatch bool // if set skip exact matching of Fs value
+ TiersToTest []string // List of tiers which can be tested in setTier test
}
// Run runs the basic integration tests for a remote using the remote
@@ -200,11 +200,12 @@ func Run(t *testing.T, opt *Opt) {
}
}
- // Skip if remote is not SetTier capable
+ // Skip if remote is not SetTier and GetTier capable
skipIfNotSetTier := func(t *testing.T) {
skipIfNotOk(t)
- if remote.Features().SetTier == false {
- t.Skip("FS has no SetTier interface")
+ if remote.Features().SetTier == false ||
+ remote.Features().GetTier == false {
+ t.Skip("FS has no SetTier & GetTier interfaces")
}
}
@@ -1071,13 +1072,15 @@ func Run(t *testing.T, opt *Opt) {
t.Run("TestSetTier", func(t *testing.T) {
skipIfNotSetTier(t)
obj := findObject(t, remote, file1.Path)
- lister, ok := obj.(fs.ListTierer)
- assert.NotNil(t, ok)
- supportedTiers := lister.ListTiers()
setter, ok := obj.(fs.SetTierer)
assert.NotNil(t, ok)
getter, ok := obj.(fs.GetTierer)
assert.NotNil(t, ok)
+ // If interfaces are supported TiersToTest should contain
+ // at least one entry
+ supportedTiers := opt.TiersToTest
+ assert.NotEmpty(t, supportedTiers)
+ // test set tier changes on supported storage classes or tiers
for _, tier := range supportedTiers {
err := setter.SetTier(tier)
assert.Nil(t, err)