forked from TrueCloudLab/distribution
8ca960a0b5
This requires some discussion of how we will handle errors due to network problems and after further changes in that direction some more stress testing. There is also an upcomming commit implementing zero fill on WriteStream when offset is greater than the current size of the file.
62 lines
1.6 KiB
Go
62 lines
1.6 KiB
Go
package s3
|
|
|
|
import (
|
|
"io/ioutil"
|
|
"os"
|
|
"strconv"
|
|
"testing"
|
|
|
|
"github.com/crowdmob/goamz/aws"
|
|
"github.com/docker/docker-registry/storagedriver"
|
|
"github.com/docker/docker-registry/storagedriver/testsuites"
|
|
|
|
"gopkg.in/check.v1"
|
|
)
|
|
|
|
// Hook up gocheck into the "go test" runner.
|
|
func Test(t *testing.T) { check.TestingT(t) }
|
|
|
|
func init() {
|
|
accessKey := os.Getenv("AWS_ACCESS_KEY")
|
|
secretKey := os.Getenv("AWS_SECRET_KEY")
|
|
bucket := os.Getenv("S3_BUCKET")
|
|
encrypt := os.Getenv("S3_ENCRYPT")
|
|
region := os.Getenv("AWS_REGION")
|
|
root, err := ioutil.TempDir("", "driver-")
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
|
|
s3DriverConstructor := func(region aws.Region) (storagedriver.StorageDriver, error) {
|
|
shouldEncrypt, err := strconv.ParseBool(encrypt)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return New(accessKey, secretKey, bucket, root, region, shouldEncrypt)
|
|
}
|
|
|
|
// Skip S3 storage driver tests if environment variable parameters are not provided
|
|
skipCheck := func() string {
|
|
if accessKey == "" || secretKey == "" || bucket == "" || encrypt == "" {
|
|
return "Must set AWS_ACCESS_KEY, AWS_SECRET_KEY, S3_BUCKET, and S3_ENCRYPT to run S3 tests"
|
|
}
|
|
return ""
|
|
}
|
|
|
|
// for _, region := range aws.Regions {
|
|
// if region == aws.USGovWest {
|
|
// continue
|
|
// }
|
|
|
|
testsuites.RegisterInProcessSuite(func() (storagedriver.StorageDriver, error) {
|
|
return s3DriverConstructor(aws.GetRegion(region))
|
|
}, skipCheck)
|
|
// testsuites.RegisterIPCSuite(driverName, map[string]string{
|
|
// "accesskey": accessKey,
|
|
// "secretkey": secretKey,
|
|
// "region": region.Name,
|
|
// "bucket": bucket,
|
|
// "encrypt": encrypt,
|
|
// }, skipCheck)
|
|
// }
|
|
}
|