Fix tests

This commit is contained in:
Tom Wilkie 2017-03-13 15:21:59 +00:00
parent b48799a01e
commit 77cce900b8
1 changed files with 9 additions and 6 deletions

View File

@ -99,7 +99,7 @@ func TestSampleDelivery(t *testing.T) {
m := NewQueueManager(QueueManagerConfig{ m := NewQueueManager(QueueManagerConfig{
Client: c, Client: c,
Shards: 1, MaxShards: 1,
}) })
// These should be received by the client. // These should be received by the client.
@ -185,8 +185,10 @@ func (c *TestBlockingStorageClient) Name() string {
} }
func (t *QueueManager) queueLen() int { func (t *QueueManager) queueLen() int {
t.shardsMtx.Lock()
defer t.shardsMtx.Unlock()
queueLength := 0 queueLength := 0
for _, shard := range t.shards { for _, shard := range t.shards.queues {
queueLength += len(shard) queueLength += len(shard)
} }
return queueLength return queueLength
@ -197,7 +199,7 @@ func TestSpawnNotMoreThanMaxConcurrentSendsGoroutines(t *testing.T) {
// `MaxSamplesPerSend*Shards` samples should be consumed by the // `MaxSamplesPerSend*Shards` samples should be consumed by the
// per-shard goroutines, and then another `MaxSamplesPerSend` // per-shard goroutines, and then another `MaxSamplesPerSend`
// should be left on the queue. // should be left on the queue.
n := defaultMaxSamplesPerSend*defaultShards + defaultMaxSamplesPerSend n := defaultMaxSamplesPerSend*1 + defaultMaxSamplesPerSend
samples := make(model.Samples, 0, n) samples := make(model.Samples, 0, n)
for i := 0; i < n; i++ { for i := 0; i < n; i++ {
@ -214,6 +216,7 @@ func TestSpawnNotMoreThanMaxConcurrentSendsGoroutines(t *testing.T) {
m := NewQueueManager(QueueManagerConfig{ m := NewQueueManager(QueueManagerConfig{
Client: c, Client: c,
QueueCapacity: n, QueueCapacity: n,
MaxShards: 1,
}) })
m.Start() m.Start()
@ -250,7 +253,7 @@ func TestSpawnNotMoreThanMaxConcurrentSendsGoroutines(t *testing.T) {
} }
numCalls := c.NumCalls() numCalls := c.NumCalls()
if numCalls != uint64(defaultShards) { if numCalls != uint64(1) {
t.Errorf("Saw %d concurrent sends, expected %d", numCalls, defaultShards) t.Errorf("Saw %d concurrent sends, expected 1", numCalls)
} }
} }