From 6b18338ccd5a88a066622b051e315a51600aec05 Mon Sep 17 00:00:00 2001 From: Michael Hoffmann Date: Mon, 22 Jan 2024 11:37:48 +0100 Subject: [PATCH] Store: acceptance test for proxy store (#7084) * Add basic acceptance tests for proxy store * Fix bug where invalid requests got ignored because of partial response strategy Signed-off-by: Michael Hoffmann --- pkg/store/acceptance_test.go | 28 ++++++++++++++++++++++++++++ pkg/store/proxy.go | 3 +++ 2 files changed, 31 insertions(+) diff --git a/pkg/store/acceptance_test.go b/pkg/store/acceptance_test.go index 34abc649ab..069d732555 100644 --- a/pkg/store/acceptance_test.go +++ b/pkg/store/acceptance_test.go @@ -33,6 +33,7 @@ import ( "github.com/thanos-io/thanos/pkg/store/labelpb" "github.com/thanos-io/thanos/pkg/store/storepb" "github.com/thanos-io/thanos/pkg/store/storepb/prompb" + storetestutil "github.com/thanos-io/thanos/pkg/store/storepb/testutil" "github.com/thanos-io/thanos/pkg/testutil/custom" "github.com/thanos-io/thanos/pkg/testutil/e2eutil" ) @@ -965,3 +966,30 @@ func TestTSDBStore_Acceptance(t *testing.T) { testStoreAPIsAcceptance(t, startStore) testStoreAPIsSeriesSplitSamplesIntoChunksWithMaxSizeOf120(t, startStore) } + +func TestProxyStore_Acceptance(t *testing.T) { + t.Cleanup(func() { custom.TolerantVerifyLeak(t) }) + + startStore := func(tt *testing.T, extLset labels.Labels, appendFn func(app storage.Appender)) storepb.StoreServer { + startNestedStore := func(tt *testing.T, extLset labels.Labels, appendFn func(app storage.Appender)) storepb.StoreServer { + db, err := e2eutil.NewTSDB() + testutil.Ok(tt, err) + tt.Cleanup(func() { testutil.Ok(tt, db.Close()) }) + appendFn(db.Appender(context.Background())) + + return NewTSDBStore(nil, db, component.Rule, extLset) + } + + p1 := startNestedStore(tt, extLset, appendFn) + p2 := startNestedStore(tt, extLset, appendFn) + + clients := []Client{ + storetestutil.TestClient{StoreClient: storepb.ServerAsClient(p1, 0)}, + storetestutil.TestClient{StoreClient: storepb.ServerAsClient(p2, 0)}, + } + + return NewProxyStore(nil, nil, func() []Client { return clients }, component.Query, nil, 0*time.Second, RetrievalStrategy(EagerRetrieval)) + } + + testStoreAPIsAcceptance(t, startStore) +} diff --git a/pkg/store/proxy.go b/pkg/store/proxy.go index ce4d391bf3..96a67f9b75 100644 --- a/pkg/store/proxy.go +++ b/pkg/store/proxy.go @@ -540,6 +540,9 @@ func (s *ProxyStore) LabelValues(ctx context.Context, r *storepb.LabelValuesRequ g, gctx = errgroup.WithContext(ctx) storeDebugMsgs []string ) + if r.Label == "" { + return nil, status.Error(codes.InvalidArgument, "label name parameter cannot be empty") + } // We may arrive here either via the promql engine // or as a result of a grpc call in layered queries