mirror of
https://github.com/rclone/rclone.git
synced 2025-12-15 15:53:41 +00:00
bisync: deglobalize to fix concurrent runs via rc - fixes #8675
Before this change, bisync used some global variables, which could cause errors if running multiple concurrent bisync runs through the rc. (Running normally from the command line was not affected.) This change deglobalizes those variables so that multiple bisync runs can be safely run at once, from the same rclone instance.
This commit is contained in:
@@ -176,6 +176,7 @@ var (
|
||||
// Flag -refresh-times helps with Dropbox tests failing with message
|
||||
// "src and dst identical but can't set mod time without deleting and re-uploading"
|
||||
argRefreshTimes = flag.Bool("refresh-times", false, "Force refreshing the target modtime, useful for Dropbox (default: false)")
|
||||
ignoreLogs = flag.Bool("ignore-logs", false, "skip comparing log lines but still compare listings")
|
||||
)
|
||||
|
||||
// bisyncTest keeps all test data in a single place
|
||||
@@ -264,6 +265,25 @@ func TestBisyncRemoteRemote(t *testing.T) {
|
||||
testBisync(t, remote, remote)
|
||||
}
|
||||
|
||||
// make sure rc can cope with running concurrent jobs
|
||||
func TestBisyncConcurrent(t *testing.T) {
|
||||
oldArgTestCase := argTestCase
|
||||
*argTestCase = "basic"
|
||||
*ignoreLogs = true // not useful to compare logs here because both runs will be logging at once
|
||||
t.Cleanup(func() {
|
||||
argTestCase = oldArgTestCase
|
||||
*ignoreLogs = false
|
||||
})
|
||||
|
||||
t.Run("test1", testParallel)
|
||||
t.Run("test2", testParallel)
|
||||
}
|
||||
|
||||
func testParallel(t *testing.T) {
|
||||
t.Parallel()
|
||||
TestBisyncRemoteRemote(t)
|
||||
}
|
||||
|
||||
// TestBisync is a test engine for bisync test cases.
|
||||
func testBisync(t *testing.T, path1, path2 string) {
|
||||
ctx := context.Background()
|
||||
@@ -1441,6 +1461,9 @@ func (b *bisyncTest) compareResults() int {
|
||||
resultText := b.mangleResult(b.workDir, file, false)
|
||||
|
||||
if fileType(file) == "log" {
|
||||
if *ignoreLogs {
|
||||
continue
|
||||
}
|
||||
// save mangled logs so difference is easier on eyes
|
||||
goldenFile := filepath.Join(b.logDir, "mangled.golden.log")
|
||||
resultFile := filepath.Join(b.logDir, "mangled.result.log")
|
||||
|
||||
Reference in New Issue
Block a user