Skip to content

Commit

Permalink
chore: Add test case for partitionTasksByBlock()
Browse files Browse the repository at this point in the history
Signed-off-by: Christian Haudum <[email protected]>
  • Loading branch information
chaudum committed Jun 26, 2024
1 parent 3ad7ab0 commit aafea97
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 1 deletion.
2 changes: 1 addition & 1 deletion pkg/bloomgateway/multiplexing.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ func (t Task) Copy(series []*logproto.GroupedChunkRefs) Task {
interval: t.interval,
table: t.table,
ctx: t.ctx,
done: make(chan struct{}),
done: t.done,
}
}

Expand Down
29 changes: 29 additions & 0 deletions pkg/bloomgateway/util_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,35 @@ func TestPartitionTasksByBlock(t *testing.T) {
results := partitionTasksByBlock(tasks, bounds)
require.Len(t, results, 0)
})

t.Run("overlapping and unsorted block ranges", func(t *testing.T) {
bounds := []bloomshipper.BlockRef{
mkBlockRef(5, 14),
mkBlockRef(0, 9),
mkBlockRef(10, 19),
}

tasks := []Task{
{
series: []*logproto.GroupedChunkRefs{
{Fingerprint: 6},
},
},
{
series: []*logproto.GroupedChunkRefs{
{Fingerprint: 12},
},
},
}

expected := []blockWithTasks{
{ref: bounds[0], tasks: tasks}, // both tasks
{ref: bounds[1], tasks: tasks[:1]}, // first task
{ref: bounds[2], tasks: tasks[1:]}, // second task
}
results := partitionTasksByBlock(tasks, bounds)
require.Equal(t, expected, results)
})
}

func TestPartitionRequest(t *testing.T) {
Expand Down

0 comments on commit aafea97

Please sign in to comment.