"rsync for cloud storage" - Google Drive, S3, Dropbox, Backblaze B2, One Drive, Swift, Hubic, Wasabi, Google Cloud Storage, Azure Blob, Azure Files, Yandex Files
Go azure-blobazure-blob-storageazure-filesbackblaze-b2cloud-storagedropboxencryptionftpfuse-filesystemgogolanggoogle-cloud-storagegoogle-driveonedriveopenstack-swiftrclones3sftpsyncwebdav
serve s3: skip TestS3Minio when the docker test framework is unavailable
Nick Craig-Wood9c9fbebf7f3f
diff --git a/cmd/serve/s3/s3_test.go b/cmd/serve/s3/s3_test.goindex 1ebf6bf56..2baf487f3 100644--- a/cmd/serve/s3/s3_test.go+++ b/cmd/serve/s3/s3_test.go@@ -27,6 +27,7 @@ import ("github.com/rclone/rclone/fs/object""github.com/rclone/rclone/fs/rc""github.com/rclone/rclone/fstest"+ "github.com/rclone/rclone/fstest/testy""github.com/rclone/rclone/lib/random""github.com/rclone/rclone/vfs/vfscommon""github.com/stretchr/testify/assert"@@ -84,6 +85,7 @@ func TestS3(t *testing.T) {// this exercises that streaming path in serve s3 - the path the local// backing in TestS3 cannot cover.func TestS3Minio(t *testing.T) {+ testy.SkipUnlessDocker(t)servetest.RunWithBackend(t, "s3", startS3(t), "TestS3Minio:")}diff --git a/fstest/testy/testy.go b/fstest/testy/testy.goindex 5b73c0139..dcbffc39a 100644--- a/fstest/testy/testy.go+++ b/fstest/testy/testy.go@@ -3,6 +3,9 @@ package testyimport ("os"+ "os/exec"+ "runtime"+ "sync""testing")@@ -18,3 +21,37 @@ func SkipUnreliable(t *testing.T) {}t.Skip("Skipping Unreliable Test on CI")}++var dockerOnce struct {+ sync.Once+ ok bool+}++// HaveDocker returns true if the fstest/testserver docker framework can+// be used on this host. The framework brings up containers (e.g. minio)+// by exec'ing the bash init.d scripts which in turn shell out to docker,+// so it needs both a POSIX shell (not available on Windows) and a+// reachable docker daemon. The result is cached after the first call.+func HaveDocker() bool {+ dockerOnce.Do(func() {+ // The init.d scripts are bash and cannot be exec'd on Windows.+ if runtime.GOOS == "windows" {+ return+ }+ // docker version exits non-zero if the client is installed but+ // the daemon is unreachable, which is exactly what we want to+ // detect.+ dockerOnce.ok = exec.Command("docker", "version").Run() == nil+ })+ return dockerOnce.ok+}++// SkipUnlessDocker skips this test unless a working docker daemon is+// available. Use it for tests that rely on the fstest/testserver docker+// framework, which is not available on all platforms (e.g. Windows and+// macOS CI runners).+func SkipUnlessDocker(t *testing.T) {+ if !HaveDocker() {+ t.Skip("Skipping test as docker is not available")+ }+}