@@ -25,7 +25,6 @@ import (
2525 "github.com/google/go-cmp/cmp"
2626 "github.com/google/go-cmp/cmp/cmpopts"
2727 "google.golang.org/grpc/internal/backoff"
28- "google.golang.org/grpc/internal/testutils/stats"
2928)
3029
3130var (
@@ -120,7 +119,7 @@ func (s) TestLRU_BasicOperations(t *testing.T) {
120119
121120func (s ) TestDataCache_BasicOperations (t * testing.T ) {
122121 initCacheEntries ()
123- dc := newDataCache (5 , nil , & stats. NoopMetricsRecorder {}, "" )
122+ dc := newDataCache (5 , nil , "" )
124123 for i , k := range cacheKeys {
125124 dc .addEntry (k , cacheEntries [i ])
126125 }
@@ -134,7 +133,7 @@ func (s) TestDataCache_BasicOperations(t *testing.T) {
134133
135134func (s ) TestDataCache_AddForcesResize (t * testing.T ) {
136135 initCacheEntries ()
137- dc := newDataCache (1 , nil , & stats. NoopMetricsRecorder {}, "" )
136+ dc := newDataCache (1 , nil , "" )
138137
139138 // The first entry in cacheEntries has a minimum expiry time in the future.
140139 // This entry would stop the resize operation since we do not evict entries
@@ -163,7 +162,7 @@ func (s) TestDataCache_AddForcesResize(t *testing.T) {
163162
164163func (s ) TestDataCache_Resize (t * testing.T ) {
165164 initCacheEntries ()
166- dc := newDataCache (5 , nil , & stats. NoopMetricsRecorder {}, "" )
165+ dc := newDataCache (5 , nil , "" )
167166 for i , k := range cacheKeys {
168167 dc .addEntry (k , cacheEntries [i ])
169168 }
@@ -194,7 +193,7 @@ func (s) TestDataCache_Resize(t *testing.T) {
194193
195194func (s ) TestDataCache_EvictExpiredEntries (t * testing.T ) {
196195 initCacheEntries ()
197- dc := newDataCache (5 , nil , & stats. NoopMetricsRecorder {}, "" )
196+ dc := newDataCache (5 , nil , "" )
198197 for i , k := range cacheKeys {
199198 dc .addEntry (k , cacheEntries [i ])
200199 }
@@ -221,7 +220,7 @@ func (s) TestDataCache_ResetBackoffState(t *testing.T) {
221220 }
222221
223222 initCacheEntries ()
224- dc := newDataCache (5 , nil , & stats. NoopMetricsRecorder {}, "" )
223+ dc := newDataCache (5 , nil , "" )
225224 for i , k := range cacheKeys {
226225 dc .addEntry (k , cacheEntries [i ])
227226 }
@@ -242,61 +241,3 @@ func (s) TestDataCache_ResetBackoffState(t *testing.T) {
242241 t .Fatalf ("unexpected diff in backoffState for cache entry after dataCache.resetBackoffState(): %s" , diff )
243242 }
244243}
245-
246- func (s ) TestDataCache_Metrics (t * testing.T ) {
247- cacheEntriesMetricsTests := []* cacheEntry {
248- {size : 1 },
249- {size : 2 },
250- {size : 3 },
251- {size : 4 },
252- {size : 5 },
253- }
254- tmr := stats .NewTestMetricsRecorder ()
255- dc := newDataCache (50 , nil , tmr , "" )
256-
257- dc .updateRLSServerTarget ("rls-server-target" )
258- for i , k := range cacheKeys {
259- dc .addEntry (k , cacheEntriesMetricsTests [i ])
260- }
261-
262- const cacheEntriesKey = "grpc.lb.rls.cache_entries"
263- const cacheSizeKey = "grpc.lb.rls.cache_size"
264- // 5 total entries which add up to 15 size, so should record that.
265- if got , _ := tmr .Metric (cacheEntriesKey ); got != 5 {
266- t .Fatalf ("Unexpected data for metric %v, got: %v, want: %v" , cacheEntriesKey , got , 5 )
267- }
268- if got , _ := tmr .Metric (cacheSizeKey ); got != 15 {
269- t .Fatalf ("Unexpected data for metric %v, got: %v, want: %v" , cacheSizeKey , got , 15 )
270- }
271-
272- // Resize down the cache to 2 entries (deterministic as based of LRU).
273- dc .resize (9 )
274- if got , _ := tmr .Metric (cacheEntriesKey ); got != 2 {
275- t .Fatalf ("Unexpected data for metric %v, got: %v, want: %v" , cacheEntriesKey , got , 2 )
276- }
277- if got , _ := tmr .Metric (cacheSizeKey ); got != 9 {
278- t .Fatalf ("Unexpected data for metric %v, got: %v, want: %v" , cacheSizeKey , got , 9 )
279- }
280-
281- // Update an entry to have size 6. This should reflect in the size metrics,
282- // which will increase by 1 to 11, while the number of cache entries should
283- // stay same. This write is deterministic and writes to the last one.
284- dc .updateEntrySize (cacheEntriesMetricsTests [4 ], 6 )
285-
286- if got , _ := tmr .Metric (cacheEntriesKey ); got != 2 {
287- t .Fatalf ("Unexpected data for metric %v, got: %v, want: %v" , cacheEntriesKey , got , 2 )
288- }
289- if got , _ := tmr .Metric (cacheSizeKey ); got != 10 {
290- t .Fatalf ("Unexpected data for metric %v, got: %v, want: %v" , cacheSizeKey , got , 10 )
291- }
292-
293- // Delete this scaled up cache key. This should scale down the cache to 1
294- // entries, and remove 6 size so cache size should be 4.
295- dc .deleteAndCleanup (cacheKeys [4 ], cacheEntriesMetricsTests [4 ])
296- if got , _ := tmr .Metric (cacheEntriesKey ); got != 1 {
297- t .Fatalf ("Unexpected data for metric %v, got: %v, want: %v" , cacheEntriesKey , got , 1 )
298- }
299- if got , _ := tmr .Metric (cacheSizeKey ); got != 4 {
300- t .Fatalf ("Unexpected data for metric %v, got: %v, want: %v" , cacheSizeKey , got , 4 )
301- }
302- }
0 commit comments