@@ -148,16 +148,20 @@ func Test_MultiLevelCache(t *testing.T) {
148148				cache .FetchMultiPostings (ctx , bID , []labels.Label {l1 , l2 })
149149			},
150150		},
151- 		"[FetchMultiPostings] should fallback only the missing keys on l1" : {
151+ 		"[FetchMultiPostings] should fallback and backfill  only the missing keys on l1" : {
152152			m1ExpectedCalls : map [string ][][]interface {}{
153153				"FetchMultiPostings" : {{bID , []labels.Label {l1 , l2 }}},
154+ 				"StorePostings" :      {{bID , l2 , v }},
154155			},
155156			m2ExpectedCalls : map [string ][][]interface {}{
156157				"FetchMultiPostings" : {{bID , []labels.Label {l2 }}},
157158			},
158159			m1MockedCalls : map [string ][]interface {}{
159160				"FetchMultiPostings" : {map [labels.Label ][]byte {l1 : make ([]byte , 1 )}, []labels.Label {l2 }},
160161			},
162+ 			m2MockedCalls : map [string ][]interface {}{
163+ 				"FetchMultiPostings" : {map [labels.Label ][]byte {l2 : v }, []labels.Label {}},
164+ 			},
161165			call : func (cache  storecache.IndexCache ) {
162166				cache .FetchMultiPostings (ctx , bID , []labels.Label {l1 , l2 })
163167			},
@@ -185,15 +189,19 @@ func Test_MultiLevelCache(t *testing.T) {
185189				cache .FetchMultiSeries (ctx , bID , []storage.SeriesRef {1 , 2 })
186190			},
187191		},
188- 		"[FetchMultiSeries] should fallback only the missing keys on l1" : {
192+ 		"[FetchMultiSeries] should fallback and backfill  only the missing keys on l1" : {
189193			m1ExpectedCalls : map [string ][][]interface {}{
190194				"FetchMultiSeries" : {{bID , []storage.SeriesRef {1 , 2 }}},
195+ 				"StoreSeries" :      {{bID , storage .SeriesRef (2 ), v }},
191196			},
192197			m2ExpectedCalls : map [string ][][]interface {}{
193198				"FetchMultiSeries" : {{bID , []storage.SeriesRef {2 }}},
194199			},
195200			m1MockedCalls : map [string ][]interface {}{
196- 				"FetchMultiSeries" : {map [storage.SeriesRef ][]byte {1 : make ([]byte , 1 )}, []storage.SeriesRef {2 }},
201+ 				"FetchMultiSeries" : {map [storage.SeriesRef ][]byte {1 : v }, []storage.SeriesRef {2 }},
202+ 			},
203+ 			m2MockedCalls : map [string ][]interface {}{
204+ 				"FetchMultiSeries" : {map [storage.SeriesRef ][]byte {2 : v }, []storage.SeriesRef {2 }},
197205			},
198206			call : func (cache  storecache.IndexCache ) {
199207				cache .FetchMultiSeries (ctx , bID , []storage.SeriesRef {1 , 2 })
@@ -211,13 +219,17 @@ func Test_MultiLevelCache(t *testing.T) {
211219				cache .FetchMultiSeries (ctx , bID , []storage.SeriesRef {1 , 2 })
212220			},
213221		},
214- 		"[FetchExpandedPostings] Should fallback when miss" : {
222+ 		"[FetchExpandedPostings] Should fallback and backfill  when miss" : {
215223			m1ExpectedCalls : map [string ][][]interface {}{
224+ 				"StoreExpandedPostings" : {{bID , []* labels.Matcher {matcher }, v }},
216225				"FetchExpandedPostings" : {{bID , []* labels.Matcher {matcher }}},
217226			},
218227			m2ExpectedCalls : map [string ][][]interface {}{
219228				"FetchExpandedPostings" : {{bID , []* labels.Matcher {matcher }}},
220229			},
230+ 			m2MockedCalls : map [string ][]interface {}{
231+ 				"FetchExpandedPostings" : {v , true },
232+ 			},
221233			call : func (cache  storecache.IndexCache ) {
222234				cache .FetchExpandedPostings (ctx , bID , []* labels.Matcher {matcher })
223235			},
0 commit comments