14
14
import java .util .Map ;
15
15
import java .util .concurrent .Callable ;
16
16
import java .util .concurrent .TimeUnit ;
17
+ import org .javatuples .Octet ;
17
18
import org .javatuples .Septet ;
18
19
import org .jetbrains .annotations .NotNull ;
19
20
import org .springframework .cache .CacheManager ;
@@ -33,8 +34,8 @@ public class CacheEvictionServiceTest {
33
34
34
35
int cacheKeyCount ;
35
36
// We cant use the spring Caffeine cache Manager in metadata-io due to a java 11 dependency --
36
- // this is not a problem
37
- // with the gms, but an issue with just the metadata-io jar and the associated unit tests.
37
+ // this is not a problem with the gms, but an issue with just the metadata-io jar and the
38
+ // associated unit tests.
38
39
final Map <String , Cache > nativeCacheMapForCaffeine = new HashMap <>();
39
40
40
41
final String UNSUPPORTED_CACHE_NAME = "SampleUnsupportedCacheName" ;
@@ -53,6 +54,8 @@ void setupCacheManagers() {
53
54
nativeCacheMapForCaffeine .put (
54
55
ENTITY_SEARCH_SERVICE_SEARCH_CACHE_NAME , caffeine .build ());
55
56
nativeCacheMapForCaffeine .put (UNSUPPORTED_CACHE_NAME , caffeine .build ());
57
+ nativeCacheMapForCaffeine .put (
58
+ ENTITY_SEARCH_SERVICE_SCROLL_CACHE_NAME , caffeine .build ());
56
59
}
57
60
58
61
@ Override
@@ -119,7 +122,7 @@ void setupCacheManager() {
119
122
Map <
120
123
@ NotNull Septet <Object , List <String >, String , String , Object , Object , Object >,
121
124
@ NotNull String >
122
- cacheData =
125
+ searchCacheData =
123
126
Map .of (
124
127
Septet .with (
125
128
null , // opContext
@@ -181,15 +184,49 @@ void setupCacheManager() {
181
184
Cache cache =
182
185
(Cache ) cacheManager .getCache (ENTITY_SEARCH_SERVICE_SEARCH_CACHE_NAME ).getNativeCache ();
183
186
cache .invalidateAll ();
184
- for (Map .Entry entry : cacheData .entrySet ()) {
187
+ for (Map .Entry entry : searchCacheData .entrySet ()) {
185
188
cache .put (entry .getKey (), entry .getValue ());
186
189
}
187
190
188
- cacheKeyCount = cacheData .size ();
191
+ Map <
192
+ @ NotNull Octet <
193
+ Object , List <String >, String , String , Object , String , List <String >, Integer >,
194
+ @ NotNull String >
195
+ scrollCacheData =
196
+ Map .of (
197
+ Octet .with (
198
+ null , // opContext
199
+ Arrays .asList ("container" , "dataset" ), // entity matches but no urn in filter.
200
+ "*" , // query
201
+ "{\" or\" :[{\" and\" :[{\" condition\" :\" EQUAL\" ,\" negated\" :false,\" field\" :\" _entityType\" ,\" value\" :\" \" ,\" values\" :[\" CONTAINER\" ]}]}]}" ,
202
+ // filters
203
+ null , // sort criteria
204
+ "scrollid" ,
205
+ Arrays .asList ("some facet json" ),
206
+ 1 /* querySize*/ ),
207
+ "allcontainers" ,
208
+ Octet .with (
209
+ null , // opContext
210
+ Arrays .asList ("container" , "dataset" ), // entity matches but no urn in filter.
211
+ "*" , // query
212
+ null , // filters
213
+ null , // sort criteria
214
+ "scrollid" ,
215
+ Arrays .asList ("some facet json" ),
216
+ 1 /* querySize*/ ),
217
+ "allcontainers-null-filter" );
218
+
219
+ cacheKeyCount = searchCacheData .size ();
220
+
221
+ cache = (Cache ) cacheManager .getCache (ENTITY_SEARCH_SERVICE_SCROLL_CACHE_NAME ).getNativeCache ();
222
+ cache .invalidateAll ();
223
+ for (Map .Entry entry : scrollCacheData .entrySet ()) {
224
+ cache .put (entry .getKey (), entry .getValue ());
225
+ }
189
226
190
227
cache = (Cache ) cacheManager .getCache (UNSUPPORTED_CACHE_NAME ).getNativeCache ();
191
228
cache .invalidateAll ();
192
- for (Map .Entry entry : cacheData .entrySet ()) {
229
+ for (Map .Entry entry : searchCacheData .entrySet ()) {
193
230
cache .put (
194
231
entry .getKey (),
195
232
entry .getValue ()); // oK to have the same values, this shouldn't even be looked up.
@@ -303,10 +340,12 @@ void testInvalidCache() {
303
340
void testDisabledFlags () throws URISyntaxException {
304
341
CacheEvictionService service = new CacheEvictionService (null , true , false );
305
342
service .invalidateAll (); // should be no op though
306
- evictionService .evict (List .of (Urn .createFromString ("urn:li:container:bar" )));
343
+ service .invalidate ("anycache" ); // should be no op
344
+ service .evict (List .of (Urn .createFromString ("urn:li:container:bar" )));
307
345
308
346
service = new CacheEvictionService (null , false , true );
309
347
service .invalidateAll (); // should be no op though
310
- evictionService .evict (List .of (Urn .createFromString ("urn:li:container:bar" )));
348
+ service .invalidate ("anycache" ); // should be no op
349
+ service .evict (List .of (Urn .createFromString ("urn:li:container:bar" )));
311
350
}
312
351
}
0 commit comments