[ARVADOS] updated: e531e2bb20a6ad0acaef4c7a19fb7625f94ccc0c

git at public.curoverse.com git at public.curoverse.com
Fri Oct 9 08:31:40 EDT 2015


Summary of changes:
 tools/keep-rsync/keep-rsync.go      | 12 +++++++++++-
 tools/keep-rsync/keep-rsync_test.go | 22 ++++++++++++++++++++--
 2 files changed, 31 insertions(+), 3 deletions(-)

       via  e531e2bb20a6ad0acaef4c7a19fb7625f94ccc0c (commit)
       via  dfc31c02280518a4040a7168326b5fbfe742ed28 (commit)
      from  9cb175a358a7ac410901827d5f7de6a5aabe52bf (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.


commit e531e2bb20a6ad0acaef4c7a19fb7625f94ccc0c
Author: radhika <radhika at curoverse.com>
Date:   Thu Oct 8 16:19:37 2015 -0400

    7167: add tests to replications count

diff --git a/tools/keep-rsync/keep-rsync.go b/tools/keep-rsync/keep-rsync.go
index 3c1a402..d569421 100644
--- a/tools/keep-rsync/keep-rsync.go
+++ b/tools/keep-rsync/keep-rsync.go
@@ -58,7 +58,7 @@ func main() {
 	flag.IntVar(
 		&replications,
 		"replications",
-		3,
+		0,
 		"Number of replications to write to the destination.")
 
 	flag.StringVar(
@@ -151,10 +151,14 @@ func initializeKeepRsync() (err error) {
 		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
diff --git a/tools/keep-rsync/keep-rsync_test.go b/tools/keep-rsync/keep-rsync_test.go
index 52a4eba..6bc0cb7 100644
--- a/tools/keep-rsync/keep-rsync_test.go
+++ b/tools/keep-rsync/keep-rsync_test.go
@@ -66,9 +66,6 @@ func setupRsync(c *C, enforcePermissions bool) {
 	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)
 
@@ -228,3 +225,22 @@ func (s *ServerRequiredSuite) TestRsyncWithBlobSigning_PutInOne_GetFromOtherShou
 	_, _, _, 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)
+}

commit dfc31c02280518a4040a7168326b5fbfe742ed28
Author: radhika <radhika at curoverse.com>
Date:   Thu Oct 8 16:00:14 2015 -0400

    7167: get replications count from destination api discovery doc and use it as default.

diff --git a/tools/keep-rsync/keep-rsync.go b/tools/keep-rsync/keep-rsync.go
index 313c188..3c1a402 100644
--- a/tools/keep-rsync/keep-rsync.go
+++ b/tools/keep-rsync/keep-rsync.go
@@ -151,6 +151,12 @@ func initializeKeepRsync() (err error) {
 		return
 	}
 
+	// Get default replication value from destination
+	value, err := arvDst.Discovery("defaultCollectionReplication")
+	if err == nil {
+		replications = int(value.(float64))
+	}
+
 	// if srcKeepServicesJSON is provided, use it to load services; else, use DiscoverKeepServers
 	if srcKeepServicesJSON == "" {
 		kcSrc, err = keepclient.MakeKeepClient(&arvSrc)
diff --git a/tools/keep-rsync/keep-rsync_test.go b/tools/keep-rsync/keep-rsync_test.go
index c2a8112..52a4eba 100644
--- a/tools/keep-rsync/keep-rsync_test.go
+++ b/tools/keep-rsync/keep-rsync_test.go
@@ -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"
 	}
@@ -67,10 +66,13 @@ func setupRsync(c *C, enforcePermissions bool) {
 	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)
 
-	// 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

-----------------------------------------------------------------------


hooks/post-receive
-- 




More information about the arvados-commits mailing list