2
2
mirror of https://github.com/octoleo/restic.git synced 2024-11-11 15:51:02 +00:00

test/s3: Retry connection to Minio server

This commit is contained in:
Alexander Neumann 2017-06-15 19:51:55 +02:00
parent eb7fc12e01
commit bbca31b661

View File

@ -103,6 +103,21 @@ type MinioTestConfig struct {
stopServer func() stopServer func()
} }
func openS3(t testing.TB, cfg MinioTestConfig) (be restic.Backend, err error) {
for i := 0; i < 10; i++ {
be, err = s3.Open(cfg.Config)
if err != nil {
t.Logf("s3 open: try %d: error %v", i, err)
time.Sleep(500 * time.Millisecond)
continue
}
break
}
return be, err
}
func newMinioTestSuite(ctx context.Context, t testing.TB) *test.Suite { func newMinioTestSuite(ctx context.Context, t testing.TB) *test.Suite {
return &test.Suite{ return &test.Suite{
// NewConfig returns a config for a new temporary backend that will be used in tests. // NewConfig returns a config for a new temporary backend that will be used in tests.
@ -127,7 +142,7 @@ func newMinioTestSuite(ctx context.Context, t testing.TB) *test.Suite {
Create: func(config interface{}) (restic.Backend, error) { Create: func(config interface{}) (restic.Backend, error) {
cfg := config.(MinioTestConfig) cfg := config.(MinioTestConfig)
be, err := s3.Open(cfg.Config) be, err := openS3(t, cfg)
if err != nil { if err != nil {
return nil, err return nil, err
} }