projects
/
arvados.git
/ commitdiff
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
f1e315a
)
8724: test assertion improvements
author
radhika <radhika@curoverse.com>
Thu, 7 Apr 2016 13:51:06 +0000
(09:51 -0400)
committer
radhika <radhika@curoverse.com>
Thu, 7 Apr 2016 13:51:06 +0000
(09:51 -0400)
tools/keep-block-check/keep-block-check_test.go
patch
|
blob
|
history
diff --git
a/tools/keep-block-check/keep-block-check_test.go
b/tools/keep-block-check/keep-block-check_test.go
index 0c56e55d07109b6ee770a5a546596f6e2c884b4c..8f8b927c9923150b174d2613ba3fd5c4620314f0 100644
(file)
--- a/
tools/keep-block-check/keep-block-check_test.go
+++ b/
tools/keep-block-check/keep-block-check_test.go
@@
-147,16
+147,16
@@
func setupBlockHashFile(c *C, name string, blocks []string) string {
return file.Name()
}
return file.Name()
}
-func checkErrorLog(c *C, blocks []string,
msg
string) {
+func checkErrorLog(c *C, blocks []string,
prefix, suffix
string) {
buf, _ := ioutil.ReadFile(tempLogFileName)
if len(blocks) == 0 {
buf, _ := ioutil.ReadFile(tempLogFileName)
if len(blocks) == 0 {
- expected :=
`HEAD .*` + msg
+ expected :=
prefix + `.*` + suffix
match, _ := regexp.MatchString(expected, string(buf))
c.Assert(match, Equals, false)
return
}
for _, hash := range blocks {
match, _ := regexp.MatchString(expected, string(buf))
c.Assert(match, Equals, false)
return
}
for _, hash := range blocks {
- expected :=
hash + `.*` + msg
+ expected :=
prefix + `.*` + hash + `.*` + suffix
match, _ := regexp.MatchString(expected, string(buf))
c.Assert(match, Equals, true)
}
match, _ := regexp.MatchString(expected, string(buf))
c.Assert(match, Equals, true)
}
@@
-166,35
+166,35
@@
func (s *ServerRequiredSuite) TestBlockCheck(c *C) {
setupKeepBlockCheck(c, false)
setupTestData(c)
performKeepBlockCheck(kc, blobSigningKey, "", allLocators)
setupKeepBlockCheck(c, false)
setupTestData(c)
performKeepBlockCheck(kc, blobSigningKey, "", allLocators)
- checkErrorLog(c, []string{}, "Block not found") // no errors
+ checkErrorLog(c, []string{}, "
head", "
Block not found") // no errors
}
func (s *ServerRequiredSuite) TestBlockCheckWithBlobSigning(c *C) {
setupKeepBlockCheck(c, true)
setupTestData(c)
performKeepBlockCheck(kc, blobSigningKey, "", allLocators)
}
func (s *ServerRequiredSuite) TestBlockCheckWithBlobSigning(c *C) {
setupKeepBlockCheck(c, true)
setupTestData(c)
performKeepBlockCheck(kc, blobSigningKey, "", allLocators)
- checkErrorLog(c, []string{}, "Block not found") // no errors
+ checkErrorLog(c, []string{}, "
head", "
Block not found") // no errors
}
func (s *ServerRequiredSuite) TestBlockCheck_NoSuchBlock(c *C) {
setupKeepBlockCheck(c, false)
setupTestData(c)
performKeepBlockCheck(kc, blobSigningKey, "", []string{TestHash, TestHash2})
}
func (s *ServerRequiredSuite) TestBlockCheck_NoSuchBlock(c *C) {
setupKeepBlockCheck(c, false)
setupTestData(c)
performKeepBlockCheck(kc, blobSigningKey, "", []string{TestHash, TestHash2})
- checkErrorLog(c, []string{TestHash, TestHash2}, "Block not found")
+ checkErrorLog(c, []string{TestHash, TestHash2}, "
head", "
Block not found")
}
func (s *ServerRequiredSuite) TestBlockCheck_NoSuchBlock_WithMatchingPrefix(c *C) {
setupKeepBlockCheck(c, false)
setupTestData(c)
performKeepBlockCheck(kc, blobSigningKey, "aaa", []string{TestHash, TestHash2})
}
func (s *ServerRequiredSuite) TestBlockCheck_NoSuchBlock_WithMatchingPrefix(c *C) {
setupKeepBlockCheck(c, false)
setupTestData(c)
performKeepBlockCheck(kc, blobSigningKey, "aaa", []string{TestHash, TestHash2})
- checkErrorLog(c, []string{TestHash, TestHash2}, "Block not found")
+ checkErrorLog(c, []string{TestHash, TestHash2}, "
head", "
Block not found")
}
func (s *ServerRequiredSuite) TestBlockCheck_NoSuchBlock_WithPrefixMismatch(c *C) {
setupKeepBlockCheck(c, false)
setupTestData(c)
performKeepBlockCheck(kc, blobSigningKey, "999", []string{TestHash, TestHash2})
}
func (s *ServerRequiredSuite) TestBlockCheck_NoSuchBlock_WithPrefixMismatch(c *C) {
setupKeepBlockCheck(c, false)
setupTestData(c)
performKeepBlockCheck(kc, blobSigningKey, "999", []string{TestHash, TestHash2})
- checkErrorLog(c, []string{}, "Block not found") // no errors
+ checkErrorLog(c, []string{}, "
head", "
Block not found") // no errors
}
// Setup block-check using keepServicesJSON with fake keepservers.
}
// Setup block-check using keepServicesJSON with fake keepservers.
@@
-203,14
+203,14
@@
func (s *ServerRequiredSuite) TestErrorDuringKeepBlockCheck_FakeKeepservers(c *C
keepServicesJSON = testKeepServicesJSON
setupKeepBlockCheck(c, false)
performKeepBlockCheck(kc, blobSigningKey, "", []string{TestHash, TestHash2})
keepServicesJSON = testKeepServicesJSON
setupKeepBlockCheck(c, false)
performKeepBlockCheck(kc, blobSigningKey, "", []string{TestHash, TestHash2})
- checkErrorLog(c, []string{TestHash, TestHash2}, "
timeou
t")
+ checkErrorLog(c, []string{TestHash, TestHash2}, "
head", "no such hos
t")
}
func (s *ServerRequiredSuite) TestBlockCheck_BadSignature(c *C) {
setupKeepBlockCheck(c, true)
setupTestData(c)
performKeepBlockCheck(kc, "badblobsigningkey", "", []string{TestHash, TestHash2})
}
func (s *ServerRequiredSuite) TestBlockCheck_BadSignature(c *C) {
setupKeepBlockCheck(c, true)
setupTestData(c)
performKeepBlockCheck(kc, "badblobsigningkey", "", []string{TestHash, TestHash2})
- checkErrorLog(c, []string{TestHash, TestHash2}, "HTTP 403")
+ checkErrorLog(c, []string{TestHash, TestHash2}, "
head", "
HTTP 403")
}
// Test keep-block-check initialization with keepServicesJSON
}
// Test keep-block-check initialization with keepServicesJSON
@@
-305,5
+305,5
@@
func (s *DoMainTestSuite) Test_doMain(c *C) {
err := doMain()
c.Check(err, IsNil)
err := doMain()
c.Check(err, IsNil)
- checkErrorLog(c, []string{TestHash, TestHash2}, "Block not found")
+ checkErrorLog(c, []string{TestHash, TestHash2}, "
head", "
Block not found")
}
}