[ARVADOS] updated: fba6fa53d377c6704849a2bdb731be9a0eec3aa2
git at public.curoverse.com
git at public.curoverse.com
Mon Oct 12 09:14:38 EDT 2015
Summary of changes:
tools/keep-rsync/keep-rsync.go | 7 +-
tools/keep-rsync/keep-rsync_test.go | 133 ++++++++++++++++++++++++------------
2 files changed, 92 insertions(+), 48 deletions(-)
via fba6fa53d377c6704849a2bdb731be9a0eec3aa2 (commit)
from e1492d82f4326cc58531b92844118b987575846e (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 fba6fa53d377c6704849a2bdb731be9a0eec3aa2
Author: radhika <radhika at curoverse.com>
Date: Mon Oct 12 09:13:45 2015 -0400
7167: some more error tests such as error getting block from src and error putting block to dst.
diff --git a/tools/keep-rsync/keep-rsync.go b/tools/keep-rsync/keep-rsync.go
index 226b597..d619ff3 100644
--- a/tools/keep-rsync/keep-rsync.go
+++ b/tools/keep-rsync/keep-rsync.go
@@ -2,7 +2,6 @@ package main
import (
"bytes"
- "errors"
"flag"
"git.curoverse.com/arvados.git/sdk/go/arvadosclient"
"git.curoverse.com/arvados.git/sdk/go/keepclient"
@@ -299,15 +298,11 @@ func copyBlocksToDst(toBeCopied []string) error {
}
log.Printf("Copying block: %q", locator)
- _, rep, err := kcDst.PutB(data)
+ _, _, err = kcDst.PutB(data)
if err != nil {
log.Printf("Error putting block data: %q %v", locator, err)
return err
}
- if rep != replications {
- log.Printf("Failed to put enough number of replicas. Wanted: %d; Put: %d", replications, rep)
- return errors.New("Failed to put enough number of replicas")
- }
done++
log.Printf("%.2f%% done", float64(done)/float64(total)*100)
diff --git a/tools/keep-rsync/keep-rsync_test.go b/tools/keep-rsync/keep-rsync_test.go
index 26e87f0..3ea1b95 100644
--- a/tools/keep-rsync/keep-rsync_test.go
+++ b/tools/keep-rsync/keep-rsync_test.go
@@ -9,6 +9,7 @@ import (
"testing"
"time"
+ "git.curoverse.com/arvados.git/sdk/go/arvadosclient"
"git.curoverse.com/arvados.git/sdk/go/arvadostest"
"git.curoverse.com/arvados.git/sdk/go/keepclient"
@@ -31,11 +32,19 @@ func (s *ServerRequiredSuite) SetUpSuite(c *C) {
func (s *ServerRequiredSuite) SetUpTest(c *C) {
arvadostest.ResetEnv()
+
+ // reset all variables between tests
+ srcConfig = arvadosclient.APIConfig{}
+ dstConfig = arvadosclient.APIConfig{}
+ blobSigningKey = ""
srcKeepServicesJSON = ""
dstKeepServicesJSON = ""
replications = 0
prefix = ""
- blobSigningKey = ""
+ arvSrc = arvadosclient.ArvadosClient{}
+ arvDst = arvadosclient.ArvadosClient{}
+ kcSrc = &keepclient.KeepClient{}
+ kcDst = &keepclient.KeepClient{}
}
func (s *ServerRequiredSuite) TearDownSuite(c *C) {
@@ -49,7 +58,7 @@ var testKeepServicesJSON = "{ \"kind\":\"arvados#keepServiceList\", \"etag\":\"\
// The test setup hence tweaks keep-rsync initialization to achieve this.
// First invoke initializeKeepRsync and then invoke StartKeepWithParams
// to create the keep servers to be used as destination.
-func setupRsync(c *C, enforcePermissions bool, overwrite bool) {
+func setupRsync(c *C, enforcePermissions bool, setupDstServers bool) {
// srcConfig
srcConfig.APIHost = os.Getenv("ARVADOS_API_HOST")
srcConfig.APIToken = os.Getenv("ARVADOS_API_TOKEN")
@@ -74,7 +83,7 @@ func setupRsync(c *C, enforcePermissions bool, overwrite bool) {
// Create an additional keep server to be used as destination and reload kcDst
// Set replications to 1 since those many keep servers were created for dst.
- if overwrite {
+ if setupDstServers {
arvadostest.StartKeepWithParams(true, enforcePermissions)
replications = 1
@@ -292,11 +301,57 @@ func testKeepRsync(c *C, enforcePermissions bool, indexPrefix string) {
prefix = indexPrefix
+ // setupTestData
+ setupTestData(c, enforcePermissions, prefix)
+
+ err := performKeepRsync()
+ c.Check(err, IsNil)
+
+ // Now GetIndex from dst and verify that all 5 from src and the 2 extra blocks are found
+ dstIndex, err := getUniqueLocators(kcDst, "")
+ c.Check(err, IsNil)
+
+ if prefix == "" {
+ for _, locator := range srcLocators {
+ _, ok := dstIndex[locator]
+ c.Assert(ok, Equals, true)
+ }
+ } else {
+ for _, locator := range srcLocatorsMatchingPrefix {
+ _, ok := dstIndex[locator]
+ c.Assert(ok, Equals, true)
+ }
+ }
+
+ for _, locator := range extraDstLocators {
+ _, ok := dstIndex[locator]
+ c.Assert(ok, Equals, true)
+ }
+
+ if prefix == "" {
+ // all blocks from src and the two extra blocks
+ c.Assert(len(dstIndex), Equals, len(srcLocators)+len(extraDstLocators))
+ } else {
+ // one matching prefix, 2 that were initially copied into dst along with src, and the extra blocks
+ c.Assert(len(dstIndex), Equals, len(srcLocatorsMatchingPrefix)+len(extraDstLocators)+2)
+ }
+}
+
+// Setup test data in src and dst.
+var srcLocators []string
+var srcLocatorsMatchingPrefix []string
+var dstLocators []string
+var extraDstLocators []string
+
+func setupTestData(c *C, enforcePermissions bool, indexPrefix string) {
+ srcLocators = []string{}
+ srcLocatorsMatchingPrefix = []string{}
+ dstLocators = []string{}
+ extraDstLocators = []string{}
+
tomorrow := time.Now().AddDate(0, 0, 1)
// Put a few blocks in src using kcSrc
- var srcLocators []string
- var srcLocatorsMatchingPrefix []string
for i := 0; i < 5; i++ {
data := []byte(fmt.Sprintf("test-data-%d", i))
hash := fmt.Sprintf("%x", md5.Sum(data))
@@ -324,7 +379,6 @@ func testKeepRsync(c *C, enforcePermissions bool, indexPrefix string) {
}
// Put first two of those src blocks in dst using kcDst
- var dstLocators []string
for i := 0; i < 2; i++ {
data := []byte(fmt.Sprintf("test-data-%d", i))
hash := fmt.Sprintf("%x", md5.Sum(data))
@@ -349,7 +403,6 @@ func testKeepRsync(c *C, enforcePermissions bool, indexPrefix string) {
}
// Put two more blocks in dst; they are not in src at all
- var extraDstLocators []string
for i := 0; i < 2; i++ {
data := []byte(fmt.Sprintf("other-data-%d", i))
hash := fmt.Sprintf("%x", md5.Sum(data))
@@ -372,38 +425,6 @@ func testKeepRsync(c *C, enforcePermissions bool, indexPrefix string) {
extraDstLocators = append(extraDstLocators, fmt.Sprintf("%s+%d", hash, blocklen))
}
-
- err := performKeepRsync()
- c.Check(err, IsNil)
-
- // Now GetIndex from dst and verify that all 5 from src and the 2 extra blocks are found
- dstIndex, err := getUniqueLocators(kcDst, "")
- c.Check(err, IsNil)
-
- if prefix == "" {
- for _, locator := range srcLocators {
- _, ok := dstIndex[locator]
- c.Assert(ok, Equals, true)
- }
- } else {
- for _, locator := range srcLocatorsMatchingPrefix {
- _, ok := dstIndex[locator]
- c.Assert(ok, Equals, true)
- }
- }
-
- for _, locator := range extraDstLocators {
- _, ok := dstIndex[locator]
- c.Assert(ok, Equals, true)
- }
-
- if prefix == "" {
- // all blocks from src and the two extra blocks
- c.Assert(len(dstIndex), Equals, len(srcLocators)+len(extraDstLocators))
- } else {
- // one matching prefix, 2 that were initially copied into dst along with src, and the extra blocks
- c.Assert(len(dstIndex), Equals, len(srcLocatorsMatchingPrefix)+len(extraDstLocators)+2)
- }
}
// Setup rsync using srcKeepServicesJSON with fake keepservers.
@@ -411,10 +432,10 @@ func testKeepRsync(c *C, enforcePermissions bool, indexPrefix string) {
func (s *ServerRequiredSuite) TestErrorDuringRsync_FakeSrcKeepservers(c *C) {
srcKeepServicesJSON = testKeepServicesJSON
- setupRsync(c, false, true)
+ setupRsync(c, false, false)
err := performKeepRsync()
- c.Check(err, NotNil)
+ c.Check(strings.HasSuffix(err.Error(), "no such host"), Equals, true)
}
// Setup rsync using dstKeepServicesJSON with fake keepservers.
@@ -425,5 +446,33 @@ func (s *ServerRequiredSuite) TestErrorDuringRsync_FakeDstKeepservers(c *C) {
setupRsync(c, false, false)
err := performKeepRsync()
- c.Check(err, NotNil)
+ c.Check(strings.HasSuffix(err.Error(), "no such host"), Equals, true)
+}
+
+// Test rsync with signature error during Get from src.
+func (s *ServerRequiredSuite) TestErrorDuringRsync_ErrorGettingBlockFromSrc(c *C) {
+ setupRsync(c, true, true)
+
+ // put some blocks in src and dst
+ setupTestData(c, true, "")
+
+ // Change blob signing key to a fake key, so that Get from src fails
+ blobSigningKey = "123456789012345678901234yhksjoll2grmku38mi7yxd66h5j4q9w4jzanezacp8s6q0ro3hxakfye02152hncy6zml2ed0uc"
+
+ err := performKeepRsync()
+ c.Check(err.Error(), Equals, "Block not found")
+}
+
+// Test rsync with error during Put to src.
+func (s *ServerRequiredSuite) TestErrorDuringRsync_ErrorPuttingBlockInDst(c *C) {
+ setupRsync(c, false, true)
+
+ // put some blocks in src and dst
+ setupTestData(c, true, "")
+
+ // Increase Want_replicas on dst to result in insufficient replicas error during Put
+ kcDst.Want_replicas = 2
+
+ err := performKeepRsync()
+ c.Check(err.Error(), Equals, "Could not write sufficient replicas")
}
-----------------------------------------------------------------------
hooks/post-receive
--
More information about the arvados-commits
mailing list