mirror of https://github.com/grafana/loki
ingester.index-shards config (#4111)
* consistent shard mapping test & better error msg * ingester.index-shards config * loki fails to start if the ingester & schema factors arent compatible. * lint * docs * update changelogpull/4122/head
parent
45693b7941
commit
92a4e57448
@ -0,0 +1,90 @@ |
||||
package loki |
||||
|
||||
import ( |
||||
"flag" |
||||
"testing" |
||||
"time" |
||||
|
||||
"github.com/grafana/loki/pkg/ingester" |
||||
"github.com/grafana/loki/pkg/storage" |
||||
"github.com/grafana/loki/pkg/storage/chunk" |
||||
|
||||
"github.com/prometheus/common/model" |
||||
"github.com/stretchr/testify/require" |
||||
) |
||||
|
||||
func TestCrossComponentValidation(t *testing.T) { |
||||
for _, tc := range []struct { |
||||
desc string |
||||
base *Config |
||||
err bool |
||||
}{ |
||||
{ |
||||
desc: "correct shards", |
||||
base: &Config{ |
||||
Ingester: ingester.Config{ |
||||
IndexShards: 32, |
||||
}, |
||||
SchemaConfig: storage.SchemaConfig{ |
||||
SchemaConfig: chunk.SchemaConfig{ |
||||
Configs: []chunk.PeriodConfig{ |
||||
{ |
||||
// zero should not error
|
||||
RowShards: 0, |
||||
Schema: "v6", |
||||
From: chunk.DayTime{ |
||||
Time: model.Now().Add(-48 * time.Hour), |
||||
}, |
||||
}, |
||||
{ |
||||
RowShards: 16, |
||||
Schema: "v11", |
||||
From: chunk.DayTime{ |
||||
Time: model.Now(), |
||||
}, |
||||
}, |
||||
}, |
||||
}, |
||||
}, |
||||
}, |
||||
err: false, |
||||
}, |
||||
{ |
||||
desc: "correct shards", |
||||
base: &Config{ |
||||
Ingester: ingester.Config{ |
||||
IndexShards: 32, |
||||
}, |
||||
SchemaConfig: storage.SchemaConfig{ |
||||
SchemaConfig: chunk.SchemaConfig{ |
||||
Configs: []chunk.PeriodConfig{ |
||||
{ |
||||
RowShards: 16, |
||||
Schema: "v11", |
||||
From: chunk.DayTime{ |
||||
Time: model.Now().Add(-48 * time.Hour), |
||||
}, |
||||
}, |
||||
{ |
||||
RowShards: 17, |
||||
Schema: "v11", |
||||
From: chunk.DayTime{ |
||||
Time: model.Now(), |
||||
}, |
||||
}, |
||||
}, |
||||
}, |
||||
}, |
||||
}, |
||||
err: true, |
||||
}, |
||||
} { |
||||
tc.base.RegisterFlags(flag.NewFlagSet(tc.desc, 0)) |
||||
err := tc.base.Validate() |
||||
if tc.err { |
||||
require.NotNil(t, err) |
||||
} else { |
||||
require.Nil(t, err) |
||||
} |
||||
} |
||||
} |
Loading…
Reference in new issue