Refactor the multi-host salt install page.
[arvados.git] / services / keepstore / bufferpool_test.go
index 8726a19150c7faf2f309cc6b3ba647d9aa40dd54..13e1cb4f332ba180857aef747b3086e9251466ee 100644 (file)
@@ -1,15 +1,16 @@
-package main
+// Copyright (C) The Arvados Authors. All rights reserved.
+//
+// SPDX-License-Identifier: AGPL-3.0
+
+package keepstore
 
 import (
-       . "gopkg.in/check.v1"
-       "testing"
+       "context"
        "time"
-)
 
-// Gocheck boilerplate
-func TestBufferPool(t *testing.T) {
-       TestingT(t)
-}
+       "git.arvados.org/arvados.git/sdk/go/ctxlog"
+       . "gopkg.in/check.v1"
+)
 
 var _ = Suite(&BufferPoolSuite{})
 
@@ -18,16 +19,16 @@ type BufferPoolSuite struct{}
 // Initialize a default-sized buffer pool for the benefit of test
 // suites that don't run main().
 func init() {
-       bufs = newBufferPool(maxBuffers, BlockSize)
+       bufs = newBufferPool(ctxlog.FromContext(context.Background()), 12, BlockSize)
 }
 
 // Restore sane default after bufferpool's own tests
 func (s *BufferPoolSuite) TearDownTest(c *C) {
-       bufs = newBufferPool(maxBuffers, BlockSize)
+       bufs = newBufferPool(ctxlog.FromContext(context.Background()), 12, BlockSize)
 }
 
 func (s *BufferPoolSuite) TestBufferPoolBufSize(c *C) {
-       bufs := newBufferPool(2, 10)
+       bufs := newBufferPool(ctxlog.TestLogger(c), 2, 10)
        b1 := bufs.Get(1)
        bufs.Get(2)
        bufs.Put(b1)
@@ -36,14 +37,14 @@ func (s *BufferPoolSuite) TestBufferPoolBufSize(c *C) {
 }
 
 func (s *BufferPoolSuite) TestBufferPoolUnderLimit(c *C) {
-       bufs := newBufferPool(3, 10)
+       bufs := newBufferPool(ctxlog.TestLogger(c), 3, 10)
        b1 := bufs.Get(10)
        bufs.Get(10)
        testBufferPoolRace(c, bufs, b1, "Get")
 }
 
 func (s *BufferPoolSuite) TestBufferPoolAtLimit(c *C) {
-       bufs := newBufferPool(2, 10)
+       bufs := newBufferPool(ctxlog.TestLogger(c), 2, 10)
        b1 := bufs.Get(10)
        bufs.Get(10)
        testBufferPoolRace(c, bufs, b1, "Put")
@@ -67,7 +68,7 @@ func testBufferPoolRace(c *C, bufs *bufferPool, unused []byte, expectWin string)
 }
 
 func (s *BufferPoolSuite) TestBufferPoolReuse(c *C) {
-       bufs := newBufferPool(2, 10)
+       bufs := newBufferPool(ctxlog.TestLogger(c), 2, 10)
        bufs.Get(10)
        last := bufs.Get(10)
        // The buffer pool is allowed to throw away unused buffers