|
@@ -459,4 +459,66 @@ rsync_override_only = true
|
|
So(ok, ShouldBeTrue)
|
|
So(ok, ShouldBeTrue)
|
|
So(p.options, ShouldResemble, []string{"--bar", "baz"})
|
|
So(p.options, ShouldResemble, []string{"--bar", "baz"})
|
|
})
|
|
})
|
|
|
|
+
|
|
|
|
+ Convey("rsync global options should work", t, func() {
|
|
|
|
+ tmpfile, err := os.CreateTemp("", "tunasync")
|
|
|
|
+ So(err, ShouldEqual, nil)
|
|
|
|
+ defer os.Remove(tmpfile.Name())
|
|
|
|
+
|
|
|
|
+ cfgBlob1 := `
|
|
|
|
+[global]
|
|
|
|
+name = "test_worker"
|
|
|
|
+log_dir = "/var/log/tunasync/{{.Name}}"
|
|
|
|
+mirror_dir = "/data/mirrors"
|
|
|
|
+concurrent = 10
|
|
|
|
+interval = 240
|
|
|
|
+retry = 3
|
|
|
|
+timeout = 86400
|
|
|
|
+rsync_options = ["--global"]
|
|
|
|
+
|
|
|
|
+[manager]
|
|
|
|
+api_base = "https://127.0.0.1:5000"
|
|
|
|
+token = "some_token"
|
|
|
|
+
|
|
|
|
+[server]
|
|
|
|
+hostname = "worker1.example.com"
|
|
|
|
+listen_addr = "127.0.0.1"
|
|
|
|
+listen_port = 6000
|
|
|
|
+ssl_cert = "/etc/tunasync.d/worker1.cert"
|
|
|
|
+ssl_key = "/etc/tunasync.d/worker1.key"
|
|
|
|
+
|
|
|
|
+[[mirrors]]
|
|
|
|
+name = "foo"
|
|
|
|
+provider = "rsync"
|
|
|
|
+upstream = "rsync://foo.bar/"
|
|
|
|
+interval = 720
|
|
|
|
+retry = 2
|
|
|
|
+timeout = 3600
|
|
|
|
+mirror_dir = "/data/foo"
|
|
|
|
+rsync_override = ["--override"]
|
|
|
|
+rsync_options = ["--local"]
|
|
|
|
+`
|
|
|
|
+
|
|
|
|
+ err = os.WriteFile(tmpfile.Name(), []byte(cfgBlob1), 0644)
|
|
|
|
+ So(err, ShouldEqual, nil)
|
|
|
|
+ defer tmpfile.Close()
|
|
|
|
+
|
|
|
|
+ cfg, err := LoadConfig(tmpfile.Name())
|
|
|
|
+ So(err, ShouldBeNil)
|
|
|
|
+
|
|
|
|
+ providers := map[string]mirrorProvider{}
|
|
|
|
+ for _, m := range cfg.Mirrors {
|
|
|
|
+ p := newMirrorProvider(m, cfg)
|
|
|
|
+ providers[p.Name()] = p
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ p, ok := providers["foo"].(*rsyncProvider)
|
|
|
|
+ So(ok, ShouldBeTrue)
|
|
|
|
+ So(p.options, ShouldResemble, []string{
|
|
|
|
+ "--override", // from mirror.rsync_override
|
|
|
|
+ "--timeout=120", // generated by newRsyncProvider
|
|
|
|
+ "--global", // from global.rsync_options
|
|
|
|
+ "--local", // from mirror.rsync_options
|
|
|
|
+ })
|
|
|
|
+ })
|
|
}
|
|
}
|