From b3039967396e4eef47aa244f72e3e39d94cde762 Mon Sep 17 00:00:00 2001 From: Filip Petkovski Date: Wed, 3 May 2023 13:41:59 +0200 Subject: [PATCH] Add test case for proxy store Signed-off-by: Filip Petkovski --- pkg/store/proxy_test.go | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/pkg/store/proxy_test.go b/pkg/store/proxy_test.go index 8c5e749216..774f8ad194 100644 --- a/pkg/store/proxy_test.go +++ b/pkg/store/proxy_test.go @@ -32,6 +32,7 @@ import ( "github.com/efficientgo/core/testutil" "github.com/thanos-io/thanos/pkg/component" + "github.com/thanos-io/thanos/pkg/info/infopb" "github.com/thanos-io/thanos/pkg/store/labelpb" "github.com/thanos-io/thanos/pkg/store/storepb" storetestutil "github.com/thanos-io/thanos/pkg/store/storepb/testutil" @@ -78,6 +79,34 @@ func TestProxyStore_Info(t *testing.T) { testutil.Equals(t, int64(0), resp.MaxTime) } +func TestProxyStore_TSDBInfos(t *testing.T) { + stores := []Client{ + &storetestutil.TestClient{ + StoreTSDBInfos: nil, + }, + &storetestutil.TestClient{ + StoreTSDBInfos: []infopb.TSDBInfo{ + infopb.NewTSDBInfo(0, 10, []labelpb.ZLabel{{Name: "lbl", Value: "val1"}}), + }, + }, + &storetestutil.TestClient{ + StoreTSDBInfos: []infopb.TSDBInfo{ + infopb.NewTSDBInfo(0, 20, []labelpb.ZLabel{{Name: "lbl", Value: "val2"}}), + }, + }, + } + q := NewProxyStore(nil, nil, + func() []Client { return stores }, + component.Query, nil, 0*time.Second, EagerRetrieval, + ) + + expected := []infopb.TSDBInfo{ + infopb.NewTSDBInfo(0, 10, []labelpb.ZLabel{{Name: "lbl", Value: "val1"}}), + infopb.NewTSDBInfo(0, 20, []labelpb.ZLabel{{Name: "lbl", Value: "val2"}}), + } + testutil.Equals(t, expected, q.TSDBInfos()) +} + func TestProxyStore_Series(t *testing.T) { defer custom.TolerantVerifyLeak(t)