Skip to content

Commit

Permalink
azureblob and fstests - Modify integration tests to include new
Browse files Browse the repository at this point in the history
optional setting to test SetTier on only few supported tiers.

Remove unused optional interface ListTiers and backend and internal tests
  • Loading branch information
sandeepkru authored and ncw committed Sep 18, 2018
1 parent e0c5f7f commit b94d87a
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 33 deletions.
19 changes: 0 additions & 19 deletions backend/azureblob/azureblob.go
Expand Up @@ -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")
Expand Down Expand Up @@ -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 += "/"
Expand Down Expand Up @@ -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{}
Expand Down
4 changes: 1 addition & 3 deletions backend/azureblob/azureblob_internal_test.go
Expand Up @@ -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)
Expand Down
5 changes: 3 additions & 2 deletions backend/azureblob/azureblob_test.go
Expand Up @@ -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"},
})
}
21 changes: 12 additions & 9 deletions fstest/fstests/fstests.go
Expand Up @@ -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
Expand Down Expand Up @@ -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")
}
}

Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit b94d87a

Please sign in to comment.