mirror of
https://github.com/prometheus/prometheus.git
synced 2026-03-27 16:31:38 +01:00
promqltest: scope ST/XOR2 storage options to package-internal tests
newTestStorage was enabling ST storage and XOR2 encoding globally, which broke unrelated tests (e.g. TestStreamReadEndpoint) in other packages that call RunBuiltinTests. Instead, keep newTestStorage as a simple teststorage.New wrapper and introduce a testStorageOptions package variable. An init() in the internal test file sets it to enable ST and XOR2, so the options only apply when the promqltest package itself is under test. Coded with Claude Sonnet 4.6. Signed-off-by: György Krajcsovits <gyorgy.krajcsovits@grafana.com>
This commit is contained in:
parent
b2ff1e5a5f
commit
d5dd9044bb
@ -39,7 +39,6 @@ import (
|
||||
"github.com/prometheus/prometheus/promql/parser"
|
||||
"github.com/prometheus/prometheus/promql/parser/posrange"
|
||||
"github.com/prometheus/prometheus/storage"
|
||||
"github.com/prometheus/prometheus/tsdb"
|
||||
"github.com/prometheus/prometheus/util/almost"
|
||||
"github.com/prometheus/prometheus/util/annotations"
|
||||
"github.com/prometheus/prometheus/util/convertnhcb"
|
||||
@ -254,11 +253,14 @@ func newTest(t testing.TB, input string, testingMode bool, newStorage func(testi
|
||||
return test, err
|
||||
}
|
||||
|
||||
// testStorageOptions holds additional tsdb.Options applied by newTestStorage.
|
||||
// It is populated via init() in test files so that options only take effect
|
||||
// when the promqltest package itself is under test, not when callers such as
|
||||
// promql_test.go invoke RunBuiltinTests.
|
||||
var testStorageOptions []teststorage.Option
|
||||
|
||||
func newTestStorage(t testing.TB) storage.Storage {
|
||||
return teststorage.New(t, func(opts *tsdb.Options) {
|
||||
opts.EnableSTStorage = true
|
||||
opts.EnableXOR2Encoding = true
|
||||
})
|
||||
return teststorage.New(t, testStorageOptions...)
|
||||
}
|
||||
|
||||
//go:embed testdata
|
||||
|
||||
@ -24,9 +24,20 @@ import (
|
||||
"github.com/prometheus/prometheus/model/labels"
|
||||
"github.com/prometheus/prometheus/promql"
|
||||
"github.com/prometheus/prometheus/promql/parser"
|
||||
"github.com/prometheus/prometheus/tsdb"
|
||||
"github.com/prometheus/prometheus/tsdb/chunkenc"
|
||||
"github.com/prometheus/prometheus/util/teststorage"
|
||||
)
|
||||
|
||||
func init() {
|
||||
testStorageOptions = []teststorage.Option{
|
||||
func(opts *tsdb.Options) {
|
||||
opts.EnableSTStorage = true
|
||||
opts.EnableXOR2Encoding = true
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func TestLazyLoader_WithSamplesTill(t *testing.T) {
|
||||
type testCase struct {
|
||||
ts time.Time
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user