diff --git a/storagedriver/filesystem/filesystem_test.go b/storagedriver/filesystem/filesystem_test.go index c445e178..15ef9663 100644 --- a/storagedriver/filesystem/filesystem_test.go +++ b/storagedriver/filesystem/filesystem_test.go @@ -19,6 +19,6 @@ func init() { filesystemDriverConstructor := func() (storagedriver.StorageDriver, error) { return NewDriver(rootDirectory), nil } - testsuites.RegisterInProcessSuite(filesystemDriverConstructor) - testsuites.RegisterIPCSuite("filesystem", map[string]string{"RootDirectory": rootDirectory}) + testsuites.RegisterInProcessSuite(filesystemDriverConstructor, testsuites.NeverSkip) + testsuites.RegisterIPCSuite("filesystem", map[string]string{"RootDirectory": rootDirectory}, testsuites.NeverSkip) } diff --git a/storagedriver/inmemory/inmemory_test.go b/storagedriver/inmemory/inmemory_test.go index fa62d30d..accbb5f8 100644 --- a/storagedriver/inmemory/inmemory_test.go +++ b/storagedriver/inmemory/inmemory_test.go @@ -15,6 +15,6 @@ func init() { inmemoryDriverConstructor := func() (storagedriver.StorageDriver, error) { return NewDriver(), nil } - testsuites.RegisterInProcessSuite(inmemoryDriverConstructor) - testsuites.RegisterIPCSuite("inmemory", nil) + testsuites.RegisterInProcessSuite(inmemoryDriverConstructor, testsuites.NeverSkip) + testsuites.RegisterIPCSuite("inmemory", nil, testsuites.NeverSkip) } diff --git a/storagedriver/s3/s3_test.go b/storagedriver/s3/s3_test.go index 400ec7ad..b6862ab9 100644 --- a/storagedriver/s3/s3_test.go +++ b/storagedriver/s3/s3_test.go @@ -24,6 +24,13 @@ func init() { return NewDriver(accessKey, secretKey, aws.GetRegion(region), true, bucket) } - testsuites.RegisterInProcessSuite(s3DriverConstructor) - testsuites.RegisterIPCSuite("s3", map[string]string{"accessKey": accessKey, "secretKey": secretKey, "region": region, "bucket": bucket, "encrypt": encrypt}) + skipCheck := func() string { + 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) } diff --git a/storagedriver/testsuites/testsuites.go b/storagedriver/testsuites/testsuites.go index dae5cc08..ff93b038 100644 --- a/storagedriver/testsuites/testsuites.go +++ b/storagedriver/testsuites/testsuites.go @@ -17,13 +17,14 @@ import ( // Hook up gocheck into the "go test" runner func Test(t *testing.T) { TestingT(t) } -func RegisterInProcessSuite(driverConstructor DriverConstructor) { +func RegisterInProcessSuite(driverConstructor DriverConstructor, skipCheck SkipCheck) { Suite(&DriverSuite{ Constructor: driverConstructor, + SkipCheck: skipCheck, }) } -func RegisterIPCSuite(driverName string, ipcParams map[string]string) { +func RegisterIPCSuite(driverName string, ipcParams map[string]string, skipCheck SkipCheck) { suite := &DriverSuite{ Constructor: func() (storagedriver.StorageDriver, error) { d, err := ipc.NewDriverClient(driverName, ipcParams) @@ -36,20 +37,30 @@ func RegisterIPCSuite(driverName string, ipcParams map[string]string) { } return d, nil }, + SkipCheck: skipCheck, } suite.Teardown = func() error { + if suite.StorageDriver == nil { + return nil + } + driverClient := suite.StorageDriver.(*ipc.StorageDriverClient) return driverClient.Stop() } Suite(suite) } +type SkipCheck func() (reason string) + +var NeverSkip = func() string { return "" } + type DriverConstructor func() (storagedriver.StorageDriver, error) type DriverTeardown func() error type DriverSuite struct { Constructor DriverConstructor Teardown DriverTeardown + SkipCheck storagedriver.StorageDriver } @@ -59,6 +70,9 @@ type TestDriverConfig struct { } func (suite *DriverSuite) SetUpSuite(c *C) { + if reason := suite.SkipCheck(); reason != "" { + c.Skip(reason) + } d, err := suite.Constructor() c.Assert(err, IsNil) suite.StorageDriver = d @@ -129,7 +143,7 @@ func (suite *DriverSuite) TestContinueStreamAppend(c *C) { filename := randomString(32) defer suite.StorageDriver.Delete(filename) - chunkSize := uint64(5 * 1024 * 1024) + chunkSize := uint64(10 * 1024 * 1024) contentsChunk1 := []byte(randomString(chunkSize)) contentsChunk2 := []byte(randomString(chunkSize))