@@ -236,29 +236,31 @@ private void assertSearchableSnapshotStats(String indexName, boolean cacheEnable
236
236
for (SearchableSnapshotShardStats stats : statsResponse .getStats ()) {
237
237
final ShardRouting shardRouting = stats .getShardRouting ();
238
238
assertThat (stats .getShardRouting ().getIndexName (), equalTo (indexName ));
239
- assertThat ("Expecting stats to exist for at least 1 Lucene file" , stats .getStats ().size (), greaterThan (0 ));
240
- for (SearchableSnapshotShardStats .CacheIndexInputStats indexInputStats : stats .getStats ()) {
241
- final String fileName = indexInputStats .getFileName ();
242
- assertThat ("Unexpected open count for " + fileName + " of shard " + shardRouting ,
243
- indexInputStats .getOpenCount (), greaterThan (0L ));
244
- assertThat ("Unexpected close count for " + fileName + " of shard " + shardRouting ,
245
- indexInputStats .getCloseCount (), lessThanOrEqualTo (indexInputStats .getOpenCount ()));
246
- assertThat ("Unexpected file length for " + fileName + " of shard " + shardRouting ,
247
- indexInputStats .getFileLength (), greaterThan (0L ));
248
-
249
- if (cacheEnabled == false || nonCachedExtensions .contains (IndexFileNames .getExtension (fileName ))) {
250
- assertThat ("Expected at least 1 optimized or direct read for " + fileName + " of shard " + shardRouting ,
251
- Math .max (indexInputStats .getOptimizedBytesRead ().getCount (), indexInputStats .getDirectBytesRead ().getCount ()),
252
- greaterThan (0L ));
253
- assertThat ("Expected no cache read or write for " + fileName + " of shard " + shardRouting ,
254
- Math .max (indexInputStats .getCachedBytesRead ().getCount (), indexInputStats .getCachedBytesWritten ().getCount ()),
255
- equalTo (0L ));
256
- } else {
257
- assertThat ("Expected at least 1 cache read or write for " + fileName + " of shard " + shardRouting ,
258
- Math .max (indexInputStats .getCachedBytesRead ().getCount (), indexInputStats .getCachedBytesWritten ().getCount ()),
259
- greaterThan (0L ));
260
- assertThat ("Expected no optimized read for " + fileName + " of shard " + shardRouting ,
261
- indexInputStats .getOptimizedBytesRead ().getCount (), equalTo (0L ));
239
+ if (shardRouting .started ()) {
240
+ assertThat ("Expecting stats to exist for at least 1 Lucene file" , stats .getStats ().size (), greaterThan (0 ));
241
+ for (SearchableSnapshotShardStats .CacheIndexInputStats indexInputStats : stats .getStats ()) {
242
+ final String fileName = indexInputStats .getFileName ();
243
+ assertThat ("Unexpected open count for " + fileName + " of shard " + shardRouting ,
244
+ indexInputStats .getOpenCount (), greaterThan (0L ));
245
+ assertThat ("Unexpected close count for " + fileName + " of shard " + shardRouting ,
246
+ indexInputStats .getCloseCount (), lessThanOrEqualTo (indexInputStats .getOpenCount ()));
247
+ assertThat ("Unexpected file length for " + fileName + " of shard " + shardRouting ,
248
+ indexInputStats .getFileLength (), greaterThan (0L ));
249
+
250
+ if (cacheEnabled == false || nonCachedExtensions .contains (IndexFileNames .getExtension (fileName ))) {
251
+ assertThat ("Expected at least 1 optimized or direct read for " + fileName + " of shard " + shardRouting ,
252
+ Math .max (indexInputStats .getOptimizedBytesRead ().getCount (), indexInputStats .getDirectBytesRead ().getCount ()),
253
+ greaterThan (0L ));
254
+ assertThat ("Expected no cache read or write for " + fileName + " of shard " + shardRouting ,
255
+ Math .max (indexInputStats .getCachedBytesRead ().getCount (), indexInputStats .getCachedBytesWritten ().getCount ()),
256
+ equalTo (0L ));
257
+ } else {
258
+ assertThat ("Expected at least 1 cache read or write for " + fileName + " of shard " + shardRouting ,
259
+ Math .max (indexInputStats .getCachedBytesRead ().getCount (), indexInputStats .getCachedBytesWritten ().getCount ()),
260
+ greaterThan (0L ));
261
+ assertThat ("Expected no optimized read for " + fileName + " of shard " + shardRouting ,
262
+ indexInputStats .getOptimizedBytesRead ().getCount (), equalTo (0L ));
263
+ }
262
264
}
263
265
}
264
266
}
0 commit comments