1
0
mirror of https://github.com/distribution/distribution synced 2024-11-06 19:35:52 +01:00

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

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