Like Prometheus, but for logs.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 
loki/pkg/querier/queryrange/shard_resolver_test.go

72 lines
1.1 KiB

package queryrange
import (
"fmt"
"testing"
"github.com/grafana/loki/pkg/storage/stores/index/stats"
"github.com/stretchr/testify/require"
)
func TestGuessShardFactor(t *testing.T) {
for _, tc := range []struct {
stats stats.Stats
maxShards int
exp int
}{
{
// no data == no sharding
exp: 0,
},
{
exp: 4,
stats: stats.Stats{
Bytes: maxBytesPerShard * 4,
},
},
{
// round up shard factor
exp: 16,
stats: stats.Stats{
Bytes: maxBytesPerShard * 15,
},
},
{
exp: 2,
stats: stats.Stats{
Bytes: maxBytesPerShard + 1,
},
},
{
exp: 0,
stats: stats.Stats{
Bytes: maxBytesPerShard,
},
},
{
maxShards: 8,
exp: 4,
stats: stats.Stats{
Bytes: maxBytesPerShard * 4,
},
},
{
maxShards: 2,
exp: 2,
stats: stats.Stats{
Bytes: maxBytesPerShard * 4,
},
},
{
maxShards: 1,
exp: 0,
stats: stats.Stats{
Bytes: maxBytesPerShard * 4,
},
},
} {
t.Run(fmt.Sprintf("%+v", tc.stats), func(t *testing.T) {
require.Equal(t, tc.exp, guessShardFactor(tc.stats, tc.maxShards))
})
}
}