Adds conditional SkipCheck for storage driver tests
This commit is contained in:
parent
bac40b2b35
commit
ff81f3a719
4 changed files with 30 additions and 9 deletions
|
@ -19,6 +19,6 @@ func init() {
|
||||||
filesystemDriverConstructor := func() (storagedriver.StorageDriver, error) {
|
filesystemDriverConstructor := func() (storagedriver.StorageDriver, error) {
|
||||||
return NewDriver(rootDirectory), nil
|
return NewDriver(rootDirectory), nil
|
||||||
}
|
}
|
||||||
testsuites.RegisterInProcessSuite(filesystemDriverConstructor)
|
testsuites.RegisterInProcessSuite(filesystemDriverConstructor, testsuites.NeverSkip)
|
||||||
testsuites.RegisterIPCSuite("filesystem", map[string]string{"RootDirectory": rootDirectory})
|
testsuites.RegisterIPCSuite("filesystem", map[string]string{"RootDirectory": rootDirectory}, testsuites.NeverSkip)
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,6 +15,6 @@ func init() {
|
||||||
inmemoryDriverConstructor := func() (storagedriver.StorageDriver, error) {
|
inmemoryDriverConstructor := func() (storagedriver.StorageDriver, error) {
|
||||||
return NewDriver(), nil
|
return NewDriver(), nil
|
||||||
}
|
}
|
||||||
testsuites.RegisterInProcessSuite(inmemoryDriverConstructor)
|
testsuites.RegisterInProcessSuite(inmemoryDriverConstructor, testsuites.NeverSkip)
|
||||||
testsuites.RegisterIPCSuite("inmemory", nil)
|
testsuites.RegisterIPCSuite("inmemory", nil, testsuites.NeverSkip)
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,6 +24,13 @@ func init() {
|
||||||
return NewDriver(accessKey, secretKey, aws.GetRegion(region), true, bucket)
|
return NewDriver(accessKey, secretKey, aws.GetRegion(region), true, bucket)
|
||||||
}
|
}
|
||||||
|
|
||||||
testsuites.RegisterInProcessSuite(s3DriverConstructor)
|
skipCheck := func() string {
|
||||||
testsuites.RegisterIPCSuite("s3", map[string]string{"accessKey": accessKey, "secretKey": secretKey, "region": region, "bucket": bucket, "encrypt": encrypt})
|
if accessKey == "" || secretKey == "" || region == "" || bucket == "" || encrypt == "" {
|
||||||
|
return "Must set ACCESS_KEY, SECRET_KEY, AWS_REGION, S3_BUCKET, and S3_ENCRYPT to run S3 tests"
|
||||||
|
}
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
|
||||||
|
testsuites.RegisterInProcessSuite(s3DriverConstructor, skipCheck)
|
||||||
|
testsuites.RegisterIPCSuite("s3", map[string]string{"accessKey": accessKey, "secretKey": secretKey, "region": region, "bucket": bucket, "encrypt": encrypt}, skipCheck)
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,13 +17,14 @@ import (
|
||||||
// Hook up gocheck into the "go test" runner
|
// Hook up gocheck into the "go test" runner
|
||||||
func Test(t *testing.T) { TestingT(t) }
|
func Test(t *testing.T) { TestingT(t) }
|
||||||
|
|
||||||
func RegisterInProcessSuite(driverConstructor DriverConstructor) {
|
func RegisterInProcessSuite(driverConstructor DriverConstructor, skipCheck SkipCheck) {
|
||||||
Suite(&DriverSuite{
|
Suite(&DriverSuite{
|
||||||
Constructor: driverConstructor,
|
Constructor: driverConstructor,
|
||||||
|
SkipCheck: skipCheck,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func RegisterIPCSuite(driverName string, ipcParams map[string]string) {
|
func RegisterIPCSuite(driverName string, ipcParams map[string]string, skipCheck SkipCheck) {
|
||||||
suite := &DriverSuite{
|
suite := &DriverSuite{
|
||||||
Constructor: func() (storagedriver.StorageDriver, error) {
|
Constructor: func() (storagedriver.StorageDriver, error) {
|
||||||
d, err := ipc.NewDriverClient(driverName, ipcParams)
|
d, err := ipc.NewDriverClient(driverName, ipcParams)
|
||||||
|
@ -36,20 +37,30 @@ func RegisterIPCSuite(driverName string, ipcParams map[string]string) {
|
||||||
}
|
}
|
||||||
return d, nil
|
return d, nil
|
||||||
},
|
},
|
||||||
|
SkipCheck: skipCheck,
|
||||||
}
|
}
|
||||||
suite.Teardown = func() error {
|
suite.Teardown = func() error {
|
||||||
|
if suite.StorageDriver == nil {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
driverClient := suite.StorageDriver.(*ipc.StorageDriverClient)
|
driverClient := suite.StorageDriver.(*ipc.StorageDriverClient)
|
||||||
return driverClient.Stop()
|
return driverClient.Stop()
|
||||||
}
|
}
|
||||||
Suite(suite)
|
Suite(suite)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type SkipCheck func() (reason string)
|
||||||
|
|
||||||
|
var NeverSkip = func() string { return "" }
|
||||||
|
|
||||||
type DriverConstructor func() (storagedriver.StorageDriver, error)
|
type DriverConstructor func() (storagedriver.StorageDriver, error)
|
||||||
type DriverTeardown func() error
|
type DriverTeardown func() error
|
||||||
|
|
||||||
type DriverSuite struct {
|
type DriverSuite struct {
|
||||||
Constructor DriverConstructor
|
Constructor DriverConstructor
|
||||||
Teardown DriverTeardown
|
Teardown DriverTeardown
|
||||||
|
SkipCheck
|
||||||
storagedriver.StorageDriver
|
storagedriver.StorageDriver
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -59,6 +70,9 @@ type TestDriverConfig struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (suite *DriverSuite) SetUpSuite(c *C) {
|
func (suite *DriverSuite) SetUpSuite(c *C) {
|
||||||
|
if reason := suite.SkipCheck(); reason != "" {
|
||||||
|
c.Skip(reason)
|
||||||
|
}
|
||||||
d, err := suite.Constructor()
|
d, err := suite.Constructor()
|
||||||
c.Assert(err, IsNil)
|
c.Assert(err, IsNil)
|
||||||
suite.StorageDriver = d
|
suite.StorageDriver = d
|
||||||
|
@ -129,7 +143,7 @@ func (suite *DriverSuite) TestContinueStreamAppend(c *C) {
|
||||||
filename := randomString(32)
|
filename := randomString(32)
|
||||||
defer suite.StorageDriver.Delete(filename)
|
defer suite.StorageDriver.Delete(filename)
|
||||||
|
|
||||||
chunkSize := uint64(5 * 1024 * 1024)
|
chunkSize := uint64(10 * 1024 * 1024)
|
||||||
|
|
||||||
contentsChunk1 := []byte(randomString(chunkSize))
|
contentsChunk1 := []byte(randomString(chunkSize))
|
||||||
contentsChunk2 := []byte(randomString(chunkSize))
|
contentsChunk2 := []byte(randomString(chunkSize))
|
||||||
|
|
Loading…
Reference in a new issue