Skip to content

Commit

Permalink
Proxy: acceptance test for proxy store with replica labels
Browse files Browse the repository at this point in the history
Signed-off-by: Michael Hoffmann <[email protected]>
  • Loading branch information
MichaHoffmann committed Apr 27, 2024
1 parent e6fc833 commit 044e5ed
Showing 1 changed file with 38 additions and 5 deletions.
43 changes: 38 additions & 5 deletions pkg/store/acceptance_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ func testStoreAPIsAcceptance(t *testing.T, startStore startStoreFn) {
},
labelValuesCalls: []labelValuesCallCase{
{start: timestamp.FromTime(minTime), end: timestamp.FromTime(maxTime), label: "foo", expectedValues: []string{"foovalue1"}},
{start: timestamp.FromTime(minTime), end: timestamp.FromTime(maxTime), label: "replica"},
},
},
{
Expand Down Expand Up @@ -738,7 +739,7 @@ func testStoreAPIsAcceptance(t *testing.T, startStore startStoreFn) {
})
}
for _, c := range tc.labelValuesCalls {
t.Run("label_name_values", func(t *testing.T) {
t.Run("label_values", func(t *testing.T) {
resp, err := store.LabelValues(context.Background(), &storepb.LabelValuesRequest{
Start: c.start,
End: c.end,
Expand All @@ -762,10 +763,11 @@ func testStoreAPIsAcceptance(t *testing.T, startStore startStoreFn) {
t.Run("series", func(t *testing.T) {
srv := newStoreSeriesServer(context.Background())
err := store.Series(&storepb.SeriesRequest{
MinTime: c.start,
MaxTime: c.end,
Matchers: c.matchers,
SkipChunks: c.skipChunks,
MinTime: c.start,
MaxTime: c.end,
Matchers: c.matchers,
SkipChunks: c.skipChunks,
WithoutReplicaLabels: []string{"replica"},
}, srv)
if c.expectErr != nil {
testutil.NotOk(t, err)
Expand Down Expand Up @@ -1017,3 +1019,34 @@ func TestProxyStore_Acceptance(t *testing.T) {

testStoreAPIsAcceptance(t, startStore)
}

func TestProxyStoreWithReplicas_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)

}

extLset1 := labels.NewBuilder(extLset).Set("replica", "r1").Labels()
extLset2 := labels.NewBuilder(extLset).Set("replica", "r2").Labels()

p1 := startNestedStore(tt, extLset1, appendFn)
p2 := startNestedStore(tt, extLset2, appendFn)

clients := []Client{
storetestutil.TestClient{StoreClient: storepb.ServerAsClient(p1), ExtLset: []labels.Labels{extLset1}},
storetestutil.TestClient{StoreClient: storepb.ServerAsClient(p2), ExtLset: []labels.Labels{extLset2}},
}

return NewProxyStore(nil, nil, func() []Client { return clients }, component.Query, labels.EmptyLabels(), 0*time.Second, RetrievalStrategy(EagerRetrieval))
}

testStoreAPIsAcceptance(t, startStore)
}

0 comments on commit 044e5ed

Please sign in to comment.