Skip to content

"rsync for cloud storage" - Google Drive, S3, Dropbox, Backblaze B2, One Drive, Swift, Hubic, Wasabi, Google Cloud Storage, Azure Blob, Azure Files, Yandex Files

fstest/test_all: add oneonly flag to only run one test per backend if required

Nick Craig-Wood1bfd07567ecc
diff --git a/fstest/test_all/config.go b/fstest/test_all/config.go
index ecffb2753..d906c0926 100644
--- a/fstest/test_all/config.go
+++ b/fstest/test_all/config.go
@@ -28,6 +28,7 @@ type Backend struct {
Remote string // name of the test remote
SubDir bool // set to test with -sub-dir
FastList bool // set to test with -fast-list
+ OneOnly bool // set to run only one backend test at once
}
// MakeRuns creates Run objects the Backend and Test
@@ -52,6 +53,7 @@ func (b *Backend) MakeRuns(t *Test) (runs []*Run) {
SubDir: subdir,
FastList: fastlist,
NoRetries: t.NoRetries,
+ OneOnly: b.OneOnly,
}
if t.AddBackend {
run.Path = path.Join(run.Path, b.Backend)
diff --git a/fstest/test_all/config.yaml b/fstest/test_all/config.yaml
index 25738416a..89d523263 100644
--- a/fstest/test_all/config.yaml
+++ b/fstest/test_all/config.yaml
@@ -77,6 +77,7 @@ backends:
remote: "TestQingStor:"
subdir: false
fastlist: false
+ oneonly: true
- backend: "azureblob"
remote: "TestAzureBlob:"
subdir: true
diff --git a/fstest/test_all/run.go b/fstest/test_all/run.go
index a3d51fbf5..a9de44370 100644
--- a/fstest/test_all/run.go
+++ b/fstest/test_all/run.go
@@ -14,6 +14,7 @@ import (
"regexp"
"runtime"
"strings"
+ "sync"
"time"
"github.com/ncw/rclone/fs"
@@ -21,6 +22,12 @@ import (
const testBase = "github.com/ncw/rclone/"
+// Control concurrency per backend if required
+var (
+ oneOnlyMu sync.Mutex
+ oneOnly = map[string]*sync.Mutex{}
+)
+
// Run holds info about a running test
//
// A run just runs one command line, but it can be run multiple times
@@ -33,6 +40,7 @@ type Run struct {
SubDir bool // add -sub-dir to tests
FastList bool // add -fast-list to tests
NoRetries bool // don't retry if set
+ OneOnly bool // only run test for this backend at once
// Internals
cmdLine []string
cmdString string
@@ -300,6 +308,17 @@ func (r *Run) FailedTests() string {
// Run runs all the trials for this test
func (r *Run) Run(logDir string, result chan<- *Run) {
+ if r.OneOnly {
+ oneOnlyMu.Lock()
+ mu := oneOnly[r.Backend]
+ if mu == nil {
+ mu = new(sync.Mutex)
+ oneOnly[r.Backend] = mu
+ }
+ oneOnlyMu.Unlock()
+ mu.Lock()
+ defer mu.Unlock()
+ }
r.Init()
r.logDir = logDir
for r.try = 1; r.try <= *maxTries; r.try++ {