github.com/m3db/m3@v1.5.0/src/dbnode/client/host_queue_test.go (about)

     1  // Copyright (c) 2016 Uber Technologies, Inc.
     2  //
     3  // Permission is hereby granted, free of charge, to any person obtaining a copy
     4  // of this software and associated documentation files (the "Software"), to deal
     5  // in the Software without restriction, including without limitation the rights
     6  // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
     7  // copies of the Software, and to permit persons to whom the Software is
     8  // furnished to do so, subject to the following conditions:
     9  //
    10  // The above copyright notice and this permission notice shall be included in
    11  // all copies or substantial portions of the Software.
    12  //
    13  // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
    14  // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
    15  // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
    16  // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
    17  // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
    18  // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
    19  // THE SOFTWARE.
    20  
    21  package client
    22  
    23  import "github.com/m3db/m3/src/x/pool"
    24  
    25  var (
    26  	smallPoolOptions = pool.NewObjectPoolOptions().SetSize(1)
    27  
    28  	testWriteBatchRawPool   writeBatchRawRequestPool
    29  	testWriteBatchRawV2Pool writeBatchRawV2RequestPool
    30  
    31  	testWriteArrayPool   writeBatchRawRequestElementArrayPool
    32  	testWriteV2ArrayPool writeBatchRawV2RequestElementArrayPool
    33  
    34  	testWriteTaggedBatchRawPool   writeTaggedBatchRawRequestPool
    35  	testWriteTaggedBatchRawV2Pool writeTaggedBatchRawV2RequestPool
    36  
    37  	testWriteTaggedArrayPool   writeTaggedBatchRawRequestElementArrayPool
    38  	testWriteTaggedV2ArrayPool writeTaggedBatchRawV2RequestElementArrayPool
    39  
    40  	testFetchBatchRawV2Pool      fetchBatchRawV2RequestPool
    41  	testFetchBatchRawV2ArrayPool fetchBatchRawV2RequestElementArrayPool
    42  )
    43  
    44  func init() {
    45  	testWriteBatchRawPool = newWriteBatchRawRequestPool(smallPoolOptions)
    46  	testWriteBatchRawPool.Init()
    47  	testWriteBatchRawV2Pool = newWriteBatchRawV2RequestPool(smallPoolOptions)
    48  	testWriteBatchRawV2Pool.Init()
    49  
    50  	testWriteArrayPool = newWriteBatchRawRequestElementArrayPool(smallPoolOptions, 0)
    51  	testWriteArrayPool.Init()
    52  	testWriteV2ArrayPool = newWriteBatchRawV2RequestElementArrayPool(smallPoolOptions, 0)
    53  	testWriteV2ArrayPool.Init()
    54  
    55  	testWriteTaggedBatchRawPool = newWriteTaggedBatchRawRequestPool(smallPoolOptions)
    56  	testWriteTaggedBatchRawPool.Init()
    57  	testWriteTaggedBatchRawV2Pool = newWriteTaggedBatchRawV2RequestPool(smallPoolOptions)
    58  	testWriteTaggedBatchRawV2Pool.Init()
    59  
    60  	testWriteTaggedArrayPool = newWriteTaggedBatchRawRequestElementArrayPool(smallPoolOptions, 0)
    61  	testWriteTaggedArrayPool.Init()
    62  	testWriteTaggedV2ArrayPool = newWriteTaggedBatchRawV2RequestElementArrayPool(smallPoolOptions, 0)
    63  	testWriteTaggedV2ArrayPool.Init()
    64  
    65  	testFetchBatchRawV2Pool = newFetchBatchRawV2RequestPool(smallPoolOptions)
    66  	testFetchBatchRawV2Pool.Init()
    67  	testFetchBatchRawV2ArrayPool = newFetchBatchRawV2RequestElementArrayPool(smallPoolOptions, 0)
    68  	testFetchBatchRawV2ArrayPool.Init()
    69  }
    70  
    71  type hostQueueResult struct {
    72  	result interface{}
    73  	err    error
    74  }
    75  
    76  func newHostQueueTestOptions() Options {
    77  	return newSessionTestOptions().
    78  		SetHostQueueOpsFlushSize(4).
    79  		SetHostQueueOpsArrayPoolSize(4).
    80  		SetWriteBatchSize(4).
    81  		SetFetchBatchSize(4).
    82  		SetHostQueueOpsFlushInterval(0)
    83  }