7
7
package org .elasticsearch .xpack .searchablesnapshots .cache ;
8
8
9
9
import org .apache .lucene .document .Document ;
10
- import org .apache .lucene .util .LuceneTestCase ;
11
10
import org .elasticsearch .cluster .metadata .IndexMetadata ;
12
11
import org .elasticsearch .cluster .node .DiscoveryNode ;
13
12
import org .elasticsearch .cluster .node .DiscoveryNodes ;
14
13
import org .elasticsearch .common .settings .Settings ;
15
14
import org .elasticsearch .common .unit .ByteSizeUnit ;
16
15
import org .elasticsearch .common .unit .ByteSizeValue ;
16
+ import org .elasticsearch .common .unit .TimeValue ;
17
17
import org .elasticsearch .index .Index ;
18
18
import org .elasticsearch .index .IndexService ;
19
19
import org .elasticsearch .index .shard .ShardPath ;
39
39
import static org .hamcrest .Matchers .greaterThan ;
40
40
import static org .hamcrest .Matchers .notNullValue ;
41
41
42
- @ LuceneTestCase .AwaitsFix (bugUrl = "https://github.com/elastic/elasticsearch/issues/66278" )
43
42
public class SearchableSnapshotsPersistentCacheIntegTests extends BaseSearchableSnapshotsIntegTestCase {
44
43
45
44
@ Override
@@ -48,6 +47,8 @@ protected Settings nodeSettings(int nodeOrdinal) {
48
47
.put (super .nodeSettings (nodeOrdinal ))
49
48
// ensure the cache is definitely used
50
49
.put (CacheService .SNAPSHOT_CACHE_SIZE_SETTING .getKey (), new ByteSizeValue (1L , ByteSizeUnit .GB ))
50
+ // to make cache synchronization predictable
51
+ .put (CacheService .SNAPSHOT_CACHE_SYNC_INTERVAL_SETTING .getKey (), TimeValue .timeValueHours (1L ))
51
52
.build ();
52
53
}
53
54
@@ -141,19 +142,21 @@ public Settings onNodeStopped(String nodeName) {
141
142
}
142
143
});
143
144
144
- persistentCache = internalCluster ().getInstance (CacheService .class , dataNode ). getPersistentCache ( );
145
- assertThat ( persistentCache . getNumDocs (), equalTo (( long ) cacheFiles . size ()) );
145
+ cacheService = internalCluster ().getInstance (CacheService .class , dataNode );
146
+ persistentCache = cacheService . getPersistentCache ( );
146
147
ensureGreen (restoredIndexName );
147
148
148
149
cacheFiles .forEach (cacheFile -> assertTrue (cacheFile + " should have survived node restart" , Files .exists (cacheFile )));
150
+ assertThat ("Cache files should be repopulated in cache" , persistentCache .getNumDocs (), equalTo ((long ) cacheFiles .size ()));
149
151
150
152
assertAcked (client ().admin ().indices ().prepareDelete (restoredIndexName ));
151
153
152
- assertBusy (() -> cacheFiles .forEach (cacheFile -> assertFalse (cacheFile + " should have been cleaned up" , Files .exists (cacheFile ))));
153
- cacheService = internalCluster ().getInstance (CacheService .class , dataNode );
154
+ assertBusy (() -> {
155
+ cacheFiles .forEach (cacheFile -> assertFalse (cacheFile + " should have been cleaned up" , Files .exists (cacheFile )));
156
+ assertTrue (internalCluster ().getInstance (CacheService .class , dataNode ).getPersistentCache ().hasDeletions ());
157
+ });
154
158
cacheService .synchronizeCache ();
155
159
156
- persistentCache = cacheService .getPersistentCache ();
157
160
assertThat (persistentCache .getNumDocs (), equalTo (0L ));
158
161
}
159
162
}
0 commit comments