Runs s3 storagedriver tests against all regions (excluding gov)

This commit is contained in:
Brian Bland 2014-12-08 15:47:37 -08:00
parent f3f70d151d
commit 9e38ca2231

View file

@ -20,32 +20,37 @@ func Test(t *testing.T) { check.TestingT(t) }
func init() {
accessKey := os.Getenv("AWS_ACCESS_KEY")
secretKey := os.Getenv("AWS_SECRET_KEY")
region := os.Getenv("AWS_REGION")
bucket := os.Getenv("S3_BUCKET")
encrypt := os.Getenv("S3_ENCRYPT")
s3DriverConstructor := func() (storagedriver.StorageDriver, error) {
s3DriverConstructor := func(region aws.Region) (storagedriver.StorageDriver, error) {
shouldEncrypt, err := strconv.ParseBool(encrypt)
if err != nil {
return nil, err
}
return New(accessKey, secretKey, aws.GetRegion(region), shouldEncrypt, bucket)
return New(accessKey, secretKey, region, shouldEncrypt, bucket)
}
// Skip S3 storage driver tests if environment variable parameters are not provided
skipCheck := func() string {
if accessKey == "" || secretKey == "" || region == "" || bucket == "" || encrypt == "" {
return "Must set AWS_ACCESS_KEY, AWS_SECRET_KEY, AWS_REGION, S3_BUCKET, and S3_ENCRYPT to run S3 tests"
if accessKey == "" || secretKey == "" || bucket == "" || encrypt == "" {
return "Must set AWS_ACCESS_KEY, AWS_SECRET_KEY, S3_BUCKET, and S3_ENCRYPT to run S3 tests"
}
return ""
}
testsuites.RegisterInProcessSuite(s3DriverConstructor, skipCheck)
testsuites.RegisterIPCSuite(driverName, map[string]string{
"accesskey": accessKey,
"secretkey": secretKey,
"region": region,
"bucket": bucket,
"encrypt": encrypt,
}, skipCheck)
for _, region := range aws.Regions {
if region == aws.USGovWest {
continue
}
testsuites.RegisterInProcessSuite(s3DriverConstructor(region), skipCheck)
testsuites.RegisterIPCSuite(driverName, map[string]string{
"accesskey": accessKey,
"secretkey": secretKey,
"region": region.Name,
"bucket": bucket,
"encrypt": encrypt,
}, skipCheck)
}
}