X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/c9018ad3b7f67f2f15a6a6671bf271858926586e..62817f027167fbe5fc5b66bbdc04261da16fe3ef:/tools/keep-rsync/keep-rsync_test.go diff --git a/tools/keep-rsync/keep-rsync_test.go b/tools/keep-rsync/keep-rsync_test.go index f1091887d5..e728890388 100644 --- a/tools/keep-rsync/keep-rsync_test.go +++ b/tools/keep-rsync/keep-rsync_test.go @@ -4,6 +4,7 @@ import ( "crypto/md5" "fmt" "io/ioutil" + "log" "os" "strings" "testing" @@ -59,7 +60,7 @@ func (s *ServerRequiredSuite) SetUpTest(c *C) { } func (s *ServerRequiredSuite) TearDownTest(c *C) { - arvadostest.StopKeepWithParams(3) + arvadostest.StopKeep(3) } func (s *DoMainTestSuite) SetUpTest(c *C) { @@ -94,7 +95,7 @@ func setupRsync(c *C, enforcePermissions bool, replications int) { } // Start Keep servers - arvadostest.StartKeepWithParams(3, enforcePermissions) + arvadostest.StartKeep(3, enforcePermissions) // setup keepclients var err error @@ -327,7 +328,8 @@ func (s *ServerRequiredSuite) TestErrorDuringRsync_FakeSrcKeepservers(c *C) { setupRsync(c, false, 1) err := performKeepRsync(kcSrc, kcDst, "", "") - c.Check(strings.HasSuffix(err.Error(), "no such host"), Equals, true) + log.Printf("Err = %v", err) + c.Check(strings.Contains(err.Error(), "no such host"), Equals, true) } // Setup rsync using dstKeepServicesJSON with fake keepservers. @@ -338,7 +340,8 @@ func (s *ServerRequiredSuite) TestErrorDuringRsync_FakeDstKeepservers(c *C) { setupRsync(c, false, 1) err := performKeepRsync(kcSrc, kcDst, "", "") - c.Check(strings.HasSuffix(err.Error(), "no such host"), Equals, true) + log.Printf("Err = %v", err) + c.Check(strings.Contains(err.Error(), "no such host"), Equals, true) } // Test rsync with signature error during Get from src. @@ -352,7 +355,7 @@ func (s *ServerRequiredSuite) TestErrorDuringRsync_ErrorGettingBlockFromSrc(c *C blobSigningKey = "thisisfakeblobsigningkey" err := performKeepRsync(kcSrc, kcDst, blobSigningKey, "") - c.Check(strings.HasSuffix(err.Error(), "Block not found"), Equals, true) + c.Check(strings.Contains(err.Error(), "HTTP 403 \"Forbidden\""), Equals, true) } // Test rsync with error during Put to src. @@ -366,7 +369,7 @@ func (s *ServerRequiredSuite) TestErrorDuringRsync_ErrorPuttingBlockInDst(c *C) kcDst.Want_replicas = 2 err := performKeepRsync(kcSrc, kcDst, blobSigningKey, "") - c.Check(strings.HasSuffix(err.Error(), "Could not write sufficient replicas"), Equals, true) + c.Check(strings.Contains(err.Error(), "Could not write sufficient replicas"), Equals, true) } // Test loadConfig func @@ -410,7 +413,7 @@ func (s *ServerNotRequiredSuite) TestLoadConfig_MissingSrcConfig(c *C) { // Test loadConfig func - error reading config func (s *ServerNotRequiredSuite) TestLoadConfig_ErrorLoadingSrcConfig(c *C) { _, _, err := loadConfig("no-such-config-file") - c.Assert(strings.HasSuffix(err.Error(), "no such file or directory"), Equals, true) + c.Assert(strings.Contains(err.Error(), "no such file or directory"), Equals, true) } func setupConfigFile(c *C, name string) *os.File { @@ -421,6 +424,7 @@ func setupConfigFile(c *C, name string) *os.File { fileContent := "ARVADOS_API_HOST=" + os.Getenv("ARVADOS_API_HOST") + "\n" fileContent += "ARVADOS_API_TOKEN=" + os.Getenv("ARVADOS_API_TOKEN") + "\n" fileContent += "ARVADOS_API_HOST_INSECURE=" + os.Getenv("ARVADOS_API_HOST_INSECURE") + "\n" + fileContent += "ARVADOS_EXTERNAL_CLIENT=false\n" fileContent += "ARVADOS_BLOB_SIGNING_KEY=abcdefg" _, err = file.Write([]byte(fileContent)) @@ -468,7 +472,7 @@ func (s *DoMainTestSuite) Test_doMainWithSrcAndDstConfig(c *C) { // Start keepservers. Since we are not doing any tweaking as in setupRsync func, // kcSrc and kcDst will be the same and no actual copying to dst will happen, but that's ok. - arvadostest.StartKeep() + arvadostest.StartKeep(2, false) err := doMain() c.Check(err, IsNil)