chore(bench_test): skip tests if new engine does not support feature (#18488)

pull/18491/head
Ashwanth 6 months ago committed by GitHub
parent fcbd0dcfcb
commit 05d569cb4e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 51
      pkg/logql/bench/bench_test.go

@ -21,6 +21,7 @@ import (
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"github.com/grafana/loki/v3/pkg/engine"
"github.com/grafana/loki/v3/pkg/logproto"
"github.com/grafana/loki/v3/pkg/logql"
"github.com/grafana/loki/v3/pkg/logqlmodel"
@ -164,18 +165,6 @@ func TestStorageEquality(t *testing.T) {
)
require.NoError(t, err)
expected, err := baseStore.Engine.Query(params).Exec(ctx)
require.NoError(t, err)
t.Logf(`Summary stats: store=%s lines_processed=%d, entries_returned=%d, bytes_processed=%s, execution_time_in_secs=%d, bytes_processed_per_sec=%s`,
baseStore.Name,
expected.Statistics.Summary.TotalLinesProcessed,
expected.Statistics.Summary.TotalEntriesReturned,
humanize.Bytes(uint64(expected.Statistics.Summary.TotalBytesProcessed)),
uint64(expected.Statistics.Summary.ExecTime),
humanize.Bytes(uint64(expected.Statistics.Summary.BytesProcessedPerSecond)),
)
// Find matching test case in other stores and then compare results.
idx := slices.IndexFunc(store.Cases, func(tc TestCase) bool {
return tc == baseCase
@ -186,21 +175,31 @@ func TestStorageEquality(t *testing.T) {
}
actual, err := store.Engine.Query(params).Exec(ctx)
if err != nil && errors.Is(err, errStoreUnimplemented) {
t.Logf("Store %s does not implement test case %s", store.Name, baseCase.Name())
return
} else if assert.NoError(t, err) {
t.Logf(`Summary stats: store=%s lines_processed=%d, entries_returned=%d, bytes_processed=%s, execution_time_in_secs=%d, bytes_processed_per_sec=%s`,
store.Name,
actual.Statistics.Summary.TotalLinesProcessed,
actual.Statistics.Summary.TotalEntriesReturned,
humanize.Bytes(uint64(actual.Statistics.Summary.TotalBytesProcessed)),
uint64(actual.Statistics.Summary.ExecTime),
humanize.Bytes(uint64(actual.Statistics.Summary.BytesProcessedPerSecond)),
)
assert.Equal(t, expected.Data, actual.Data, "store %q results do not match base store %q", store.Name, baseStore.Name)
if err != nil && errors.Is(err, engine.ErrNotSupported) {
t.Skipf("Store %s does not support features used in test case %s", store.Name, baseCase.Name())
}
require.NoError(t, err)
t.Logf(`Summary stats: store=%s lines_processed=%d, entries_returned=%d, bytes_processed=%s, execution_time_in_secs=%d, bytes_processed_per_sec=%s`,
store.Name,
actual.Statistics.Summary.TotalLinesProcessed,
actual.Statistics.Summary.TotalEntriesReturned,
humanize.Bytes(uint64(actual.Statistics.Summary.TotalBytesProcessed)),
uint64(actual.Statistics.Summary.ExecTime),
humanize.Bytes(uint64(actual.Statistics.Summary.BytesProcessedPerSecond)),
)
expected, err := baseStore.Engine.Query(params).Exec(ctx)
require.NoError(t, err)
t.Logf(`Summary stats: store=%s lines_processed=%d, entries_returned=%d, bytes_processed=%s, execution_time_in_secs=%d, bytes_processed_per_sec=%s`,
baseStore.Name,
expected.Statistics.Summary.TotalLinesProcessed,
expected.Statistics.Summary.TotalEntriesReturned,
humanize.Bytes(uint64(expected.Statistics.Summary.TotalBytesProcessed)),
uint64(expected.Statistics.Summary.ExecTime),
humanize.Bytes(uint64(expected.Statistics.Summary.BytesProcessedPerSecond)),
)
assert.Equal(t, expected.Data, actual.Data, "store %q results do not match base store %q", store.Name, baseStore.Name)
})
}
}

Loading…
Cancel
Save