flag.IntVar(
&replications,
"replications",
- 3,
+ 0,
"Number of replications to write to the destination.")
flag.StringVar(
return
}
- // Get default replication value from destination
- value, err := arvDst.Discovery("defaultCollectionReplication")
- if err == nil {
- replications = int(value.(float64))
+ // Get default replications value from destination, if it is not already provided
+ if replications == 0 {
+ value, err := arvDst.Discovery("defaultCollectionReplication")
+ if err == nil {
+ replications = int(value.(float64))
+ } else {
+ replications = 2
+ }
}
// if srcKeepServicesJSON is provided, use it to load services; else, use DiscoverKeepServers
err := initializeKeepRsync()
c.Assert(err, Equals, nil)
- // Must have got replication value as 2 from dst discovery document
- c.Assert(replications, Equals, 2)
-
// Create two more keep servers to be used as destination
arvadostest.StartKeepWithParams(true, enforcePermissions)
_, _, _, err = kcSrc.Get(locatorInDst)
c.Assert(err.Error(), Equals, "Block not found")
}
+
+// Test keep-rsync initialization with default replications count
+func (s *ServerRequiredSuite) TestInitializeRsyncDefaultReplicationsCount(c *C) {
+ setupRsync(c, false)
+
+ // Must have got default replications value as 2 from dst discovery document
+ c.Assert(replications, Equals, 2)
+}
+
+// Test keep-rsync initialization with replications count argument
+func (s *ServerRequiredSuite) TestInitializeRsyncReplicationsCount(c *C) {
+ // set replications to 3 to mimic passing input argument
+ replications = 3
+
+ setupRsync(c, false)
+
+ // Since replications value is provided, default is not used
+ c.Assert(replications, Equals, 3)
+}