azureblob and fstests - Modify integration tests to include new

optional setting to test SetTier on only few supported tiers.

Remove unused optional interface ListTiers and backend and internal tests
This commit is contained in:
sandeepkru 2018-09-18 05:25:20 -07:00 committed by Nick Craig-Wood
parent e0c5f7ff1b
commit b94d87ae2d
4 changed files with 16 additions and 33 deletions

View File

@ -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 // retryErrorCodes is a slice of error codes that we will retry
var retryErrorCodes = []int{ var retryErrorCodes = []int{
401, // Unauthorized (eg "Token has expired") 401, // Unauthorized (eg "Token has expired")
@ -321,7 +308,6 @@ func NewFs(name, root string, m configmap.Mapper) (fs.Fs, error) {
BucketBased: true, BucketBased: true,
SetTier: true, SetTier: true,
GetTier: true, GetTier: true,
ListTiers: true,
}).Fill(f) }).Fill(f)
if f.root != "" { if f.root != "" {
f.root += "/" f.root += "/"
@ -1337,11 +1323,6 @@ func (o *Object) GetTier() string {
return string(o.accessTier) 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 // Check the interfaces are satisfied
var ( var (
_ fs.Fs = &Fs{} _ fs.Fs = &Fs{}

View File

@ -11,9 +11,7 @@ import (
func (f *Fs) InternalTest(t *testing.T) { func (f *Fs) InternalTest(t *testing.T) {
// Check first feature flags are set on this // Check first feature flags are set on this
// remote // remote
enabled := f.Features().ListTiers enabled := f.Features().SetTier
assert.True(t, enabled)
enabled = f.Features().SetTier
assert.True(t, enabled) assert.True(t, enabled)
enabled = f.Features().GetTier enabled = f.Features().GetTier
assert.True(t, enabled) assert.True(t, enabled)

View File

@ -14,7 +14,8 @@ import (
// TestIntegration runs integration tests against the remote // TestIntegration runs integration tests against the remote
func TestIntegration(t *testing.T) { func TestIntegration(t *testing.T) {
fstests.Run(t, &fstests.Opt{ fstests.Run(t, &fstests.Opt{
RemoteName: "TestAzureBlob:", RemoteName: "TestAzureBlob:",
NilObject: (*azureblob.Object)(nil), NilObject: (*azureblob.Object)(nil),
TiersToTest: []string{"Hot", "Cool"},
}) })
} }

View File

@ -137,9 +137,9 @@ type Opt struct {
RemoteName string RemoteName string
NilObject fs.Object NilObject fs.Object
ExtraConfig []ExtraConfigItem ExtraConfig []ExtraConfigItem
SkipBadWindowsCharacters bool // skips unusable characters for windows if set SkipBadWindowsCharacters bool // skips unusable characters for windows if set
SkipFsMatch bool // if set skip exact matching of Fs value 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 // 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) { skipIfNotSetTier := func(t *testing.T) {
skipIfNotOk(t) skipIfNotOk(t)
if remote.Features().SetTier == false { if remote.Features().SetTier == false ||
t.Skip("FS has no SetTier interface") 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) { t.Run("TestSetTier", func(t *testing.T) {
skipIfNotSetTier(t) skipIfNotSetTier(t)
obj := findObject(t, remote, file1.Path) obj := findObject(t, remote, file1.Path)
lister, ok := obj.(fs.ListTierer)
assert.NotNil(t, ok)
supportedTiers := lister.ListTiers()
setter, ok := obj.(fs.SetTierer) setter, ok := obj.(fs.SetTierer)
assert.NotNil(t, ok) assert.NotNil(t, ok)
getter, ok := obj.(fs.GetTierer) getter, ok := obj.(fs.GetTierer)
assert.NotNil(t, ok) 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 { for _, tier := range supportedTiers {
err := setter.SetTier(tier) err := setter.SetTier(tier)
assert.Nil(t, err) assert.Nil(t, err)