@@ -148,16 +148,20 @@ func Test_MultiLevelCache(t *testing.T) {
148
148
cache .FetchMultiPostings (ctx , bID , []labels.Label {l1 , l2 })
149
149
},
150
150
},
151
- "[FetchMultiPostings] should fallback only the missing keys on l1" : {
151
+ "[FetchMultiPostings] should fallback and backfill only the missing keys on l1" : {
152
152
m1ExpectedCalls : map [string ][][]interface {}{
153
153
"FetchMultiPostings" : {{bID , []labels.Label {l1 , l2 }}},
154
+ "StorePostings" : {{bID , l2 , v }},
154
155
},
155
156
m2ExpectedCalls : map [string ][][]interface {}{
156
157
"FetchMultiPostings" : {{bID , []labels.Label {l2 }}},
157
158
},
158
159
m1MockedCalls : map [string ][]interface {}{
159
160
"FetchMultiPostings" : {map [labels.Label ][]byte {l1 : make ([]byte , 1 )}, []labels.Label {l2 }},
160
161
},
162
+ m2MockedCalls : map [string ][]interface {}{
163
+ "FetchMultiPostings" : {map [labels.Label ][]byte {l2 : v }, []labels.Label {}},
164
+ },
161
165
call : func (cache storecache.IndexCache ) {
162
166
cache .FetchMultiPostings (ctx , bID , []labels.Label {l1 , l2 })
163
167
},
@@ -185,15 +189,19 @@ func Test_MultiLevelCache(t *testing.T) {
185
189
cache .FetchMultiSeries (ctx , bID , []storage.SeriesRef {1 , 2 })
186
190
},
187
191
},
188
- "[FetchMultiSeries] should fallback only the missing keys on l1" : {
192
+ "[FetchMultiSeries] should fallback and backfill only the missing keys on l1" : {
189
193
m1ExpectedCalls : map [string ][][]interface {}{
190
194
"FetchMultiSeries" : {{bID , []storage.SeriesRef {1 , 2 }}},
195
+ "StoreSeries" : {{bID , storage .SeriesRef (2 ), v }},
191
196
},
192
197
m2ExpectedCalls : map [string ][][]interface {}{
193
198
"FetchMultiSeries" : {{bID , []storage.SeriesRef {2 }}},
194
199
},
195
200
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 }},
197
205
},
198
206
call : func (cache storecache.IndexCache ) {
199
207
cache .FetchMultiSeries (ctx , bID , []storage.SeriesRef {1 , 2 })
@@ -211,13 +219,17 @@ func Test_MultiLevelCache(t *testing.T) {
211
219
cache .FetchMultiSeries (ctx , bID , []storage.SeriesRef {1 , 2 })
212
220
},
213
221
},
214
- "[FetchExpandedPostings] Should fallback when miss" : {
222
+ "[FetchExpandedPostings] Should fallback and backfill when miss" : {
215
223
m1ExpectedCalls : map [string ][][]interface {}{
224
+ "StoreExpandedPostings" : {{bID , []* labels.Matcher {matcher }, v }},
216
225
"FetchExpandedPostings" : {{bID , []* labels.Matcher {matcher }}},
217
226
},
218
227
m2ExpectedCalls : map [string ][][]interface {}{
219
228
"FetchExpandedPostings" : {{bID , []* labels.Matcher {matcher }}},
220
229
},
230
+ m2MockedCalls : map [string ][]interface {}{
231
+ "FetchExpandedPostings" : {v , true },
232
+ },
221
233
call : func (cache storecache.IndexCache ) {
222
234
cache .FetchExpandedPostings (ctx , bID , []* labels.Matcher {matcher })
223
235
},
0 commit comments