Skip to content

Flip the ordering of schema, store and query so tests run faster #1344

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 24, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 31 additions & 29 deletions pkg/chunk/chunk_store_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ func TestChunkStore_Get(t *testing.T) {
barSampleStream2, err := createSampleStreamFrom(barChunk2)
require.NoError(t, err)

for _, tc := range []struct {
testCases := []struct {
query string
expect model.Matrix
}{
Expand Down Expand Up @@ -245,24 +245,25 @@ func TestChunkStore_Get(t *testing.T) {
`{__name__=~"bar", bar="baz",toms!="code"}`,
model.Matrix{barSampleStream1},
},
} {
for _, schema := range schemas {
for _, storeCase := range stores {
}
for _, schema := range schemas {
for _, storeCase := range stores {
storeCfg := storeCase.configFn()
store := newTestChunkStoreConfig(t, schema.name, storeCfg)
defer store.Stop()

if err := store.Put(ctx, []Chunk{
fooChunk1,
fooChunk2,
barChunk1,
barChunk2,
}); err != nil {
t.Fatal(err)
}

for _, tc := range testCases {
t.Run(fmt.Sprintf("%s / %s / %s", tc.query, schema.name, storeCase.name), func(t *testing.T) {
t.Log("========= Running query", tc.query, "with schema", schema.name)
storeCfg := storeCase.configFn()
store := newTestChunkStoreConfig(t, schema.name, storeCfg)
defer store.Stop()

if err := store.Put(ctx, []Chunk{
fooChunk1,
fooChunk2,
barChunk1,
barChunk2,
}); err != nil {
t.Fatal(err)
}

matchers, err := promql.ParseMetricSelector(tc.query)
if err != nil {
t.Fatal(err)
Expand Down Expand Up @@ -326,7 +327,7 @@ func TestChunkStore_getMetricNameChunks(t *testing.T) {
"toms": "code",
})

for _, tc := range []struct {
testCases := []struct {
query string
expect []Chunk
}{
Expand Down Expand Up @@ -366,19 +367,20 @@ func TestChunkStore_getMetricNameChunks(t *testing.T) {
`foo{toms="code", bar="baz"}`,
[]Chunk{chunk1},
},
} {
for _, schema := range schemas {
for _, storeCase := range stores {
t.Run(fmt.Sprintf("%s / %s / %s", tc.query, schema.name, storeCase.name), func(t *testing.T) {
t.Log("========= Running query", tc.query, "with schema", schema.name)
storeCfg := storeCase.configFn()
store := newTestChunkStoreConfig(t, schema.name, storeCfg)
defer store.Stop()
}
for _, schema := range schemas {
for _, storeCase := range stores {
storeCfg := storeCase.configFn()
store := newTestChunkStoreConfig(t, schema.name, storeCfg)
defer store.Stop()

if err := store.Put(ctx, []Chunk{chunk1, chunk2}); err != nil {
t.Fatal(err)
}
if err := store.Put(ctx, []Chunk{chunk1, chunk2}); err != nil {
t.Fatal(err)
}

for _, tc := range testCases {
t.Run(fmt.Sprintf("%s / %s / %s", tc.query, schema.name, storeCase.name), func(t *testing.T) {
t.Log("========= Running query", tc.query, "with schema", schema.name)
matchers, err := promql.ParseMetricSelector(tc.query)
if err != nil {
t.Fatal(err)
Expand Down