[ARVADOS] created: 92a203c4cf8713a7e28e3d18117d167878dbf804
git at public.curoverse.com
git at public.curoverse.com
Thu May 14 22:04:20 EDT 2015
at 92a203c4cf8713a7e28e3d18117d167878dbf804 (commit)
commit 92a203c4cf8713a7e28e3d18117d167878dbf804
Author: Tom Clegg <tom at curoverse.com>
Date: Thu May 14 22:06:46 2015 -0400
5748: Time out leak tests after 20s.
diff --git a/services/keepstore/handler_test.go b/services/keepstore/handler_test.go
index 7855769..5c367ae 100644
--- a/services/keepstore/handler_test.go
+++ b/services/keepstore/handler_test.go
@@ -813,25 +813,31 @@ func TestPutHandlerNoBufferleak(t *testing.T) {
KeepVM = MakeTestVolumeManager(2)
defer KeepVM.Close()
- // Unfortunately this will just hang if the bug is present, because
- // bufferPool.Get() blocks forever. To make this actually fail we need
- // some kind of watchdog timer that kills the test after a while.
-
- for i := 0; i < maxBuffers+1; i += 1 {
- // Unauthenticated request, no server key
- // => OK (unsigned response)
- unsigned_locator := "/" + TEST_HASH
- response := IssueRequest(
- &RequestTester{
+ ok := make(chan bool)
+ go func() {
+ for i := 0; i < maxBuffers+1; i += 1 {
+ // Unauthenticated request, no server key
+ // => OK (unsigned response)
+ unsigned_locator := "/" + TEST_HASH
+ response := IssueRequest(
+ &RequestTester{
method: "PUT",
uri: unsigned_locator,
request_body: TEST_BLOCK,
})
- ExpectStatusCode(t,
- "TestPutHandlerBufferleak", http.StatusOK, response)
- ExpectBody(t,
- "TestPutHandlerBufferleak",
- TEST_HASH_PUT_RESPONSE, response)
+ ExpectStatusCode(t,
+ "TestPutHandlerBufferleak", http.StatusOK, response)
+ ExpectBody(t,
+ "TestPutHandlerBufferleak",
+ TEST_HASH_PUT_RESPONSE, response)
+ }
+ ok <- true
+ }()
+ select {
+ case <-time.After(20*time.Second):
+ // If the buffer pool leaks, the test goroutine hangs.
+ t.Fatal("test did not finish, assuming pool leaked")
+ case <-ok:
}
}
@@ -849,20 +855,30 @@ func TestGetHandlerNoBufferleak(t *testing.T) {
t.Error(err)
}
- for i := 0; i < maxBuffers+1; i += 1 {
- // Unauthenticated request, unsigned locator
- // => OK
- unsigned_locator := "/" + TEST_HASH
- response := IssueRequest(
- &RequestTester{
+ ok := make(chan bool)
+ go func() {
+ for i := 0; i < maxBuffers+1; i += 1 {
+ // Unauthenticated request, unsigned locator
+ // => OK
+ unsigned_locator := "/" + TEST_HASH
+ response := IssueRequest(
+ &RequestTester{
method: "GET",
uri: unsigned_locator,
})
- ExpectStatusCode(t,
- "Unauthenticated request, unsigned locator", http.StatusOK, response)
- ExpectBody(t,
- "Unauthenticated request, unsigned locator",
- string(TEST_BLOCK),
- response)
+ ExpectStatusCode(t,
+ "Unauthenticated request, unsigned locator", http.StatusOK, response)
+ ExpectBody(t,
+ "Unauthenticated request, unsigned locator",
+ string(TEST_BLOCK),
+ response)
+ }
+ ok <- true
+ }()
+ select {
+ case <-time.After(20*time.Second):
+ // If the buffer pool leaks, the test goroutine hangs.
+ t.Fatal("test did not finish, assuming pool leaked")
+ case <-ok:
}
}
commit 9e20ed8567fd8f622f02ad1fc43d486dc3a601b1
Author: Tom Clegg <tom at curoverse.com>
Date: Thu May 14 21:52:12 2015 -0400
5748: Put() always takes a non-nil buf.
diff --git a/services/keepstore/bufferpool.go b/services/keepstore/bufferpool.go
index 0b216d7..373bfc7 100644
--- a/services/keepstore/bufferpool.go
+++ b/services/keepstore/bufferpool.go
@@ -39,8 +39,6 @@ func (p *bufferPool) Get(size int) []byte {
}
func (p *bufferPool) Put(buf []byte) {
- if buf != nil {
- p.Pool.Put(buf)
- <-p.limiter
- }
+ p.Pool.Put(buf)
+ <-p.limiter
}
diff --git a/services/keepstore/handlers.go b/services/keepstore/handlers.go
index 7c9ae64..16c39c2 100644
--- a/services/keepstore/handlers.go
+++ b/services/keepstore/handlers.go
@@ -514,7 +514,6 @@ func GetBlock(hash string, update_timestamp bool) ([]byte, error) {
if !os.IsNotExist(err) {
log.Printf("GetBlock: reading %s: %s\n", hash, err)
}
- bufs.Put(buf)
continue
}
// Check the file checksum.
-----------------------------------------------------------------------
hooks/post-receive
--
More information about the arvados-commits
mailing list