Merge branch '7167-keep-rsync-test-setup' into 7167-keep-rsync
[arvados.git] / tools / keep-rsync / keep-rsync_test.go
index 6c815280ccca83ce861ccda766250ccb255b239d..c612e537258bf1c05742f27a7997ca99f1b6c369 100644 (file)
@@ -54,7 +54,6 @@ func setupRsync(c *C, enforcePermissions bool) {
        dstConfig.APIToken = os.Getenv("ARVADOS_API_TOKEN")
        dstConfig.APIHostInsecure = matchTrue.MatchString(os.Getenv("ARVADOS_API_HOST_INSECURE"))
 
-       replications = 1
        if enforcePermissions {
                blobSigningKey = "zfhgfenhffzltr9dixws36j1yhksjoll2grmku38mi7yxd66h5j4q9w4jzanezacp8s6q0ro3hxakfye02152hncy6zml2ed0uc"
        }
@@ -70,7 +69,7 @@ func setupRsync(c *C, enforcePermissions bool) {
        // Create two more keep servers to be used as destination
        arvadostest.StartKeepWithParams(true, enforcePermissions)
 
-       // load kcDst
+       // load kcDst; set Want_replicas as 1 since that is how many keep servers are created for dst.
        kcDst, err = keepclient.MakeKeepClient(&arvDst)
        c.Assert(err, Equals, nil)
        kcDst.Want_replicas = 1
@@ -227,6 +226,25 @@ func (s *ServerRequiredSuite) TestRsyncWithBlobSigning_PutInOne_GetFromOtherShou
        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)
+}
+
 // Put some blocks in Src and some more in Dst
 // And copy missing blocks from Src to Dst
 func (s *ServerRequiredSuite) TestKeepRsync(c *C) {