13
13
import org .opensearch .action .LatchedActionListener ;
14
14
import org .opensearch .action .admin .cluster .state .ClusterStateRequest ;
15
15
import org .opensearch .action .admin .cluster .state .ClusterStateResponse ;
16
- import org .opensearch .action .admin .indices .flush .FlushRequest ;
17
16
import org .opensearch .action .admin .indices .stats .IndicesStatsRequest ;
18
17
import org .opensearch .action .admin .indices .stats .IndicesStatsResponse ;
19
18
import org .opensearch .action .search .CreatePitAction ;
38
37
import org .opensearch .test .ParameterizedStaticSettingsOpenSearchIntegTestCase ;
39
38
import org .opensearch .threadpool .TestThreadPool ;
40
39
import org .opensearch .threadpool .ThreadPool ;
41
- import org .opensearch .transport .client .Requests ;
42
40
import org .junit .After ;
43
41
import org .junit .Assert ;
44
42
import org .junit .Before ;
@@ -83,6 +81,7 @@ public static Collection<Object[]> parameters() {
83
81
public void setupIndex () throws ExecutionException , InterruptedException {
84
82
createIndex ("index" , Settings .builder ().put ("index.number_of_shards" , 2 ).put ("index.number_of_replicas" , 0 ).build ());
85
83
client ().prepareIndex ("index" ).setId ("1" ).setSource ("field" , "value" ).setRefreshPolicy (IMMEDIATE ).execute ().get ();
84
+ flush (); // clear the translog to ensure accurate stats
86
85
ensureGreen ();
87
86
}
88
87
@@ -95,6 +94,7 @@ public void testPit() throws Exception {
95
94
CreatePitRequest request = new CreatePitRequest (TimeValue .timeValueDays (1 ), true );
96
95
request .setIndices (new String [] { "index" });
97
96
indexRandomForConcurrentSearch ("index" );
97
+ flush (); // clear the translog to ensure accurate stats
98
98
ActionFuture <CreatePitResponse > execute = client ().execute (CreatePitAction .INSTANCE , request );
99
99
CreatePitResponse pitResponse = execute .get ();
100
100
SearchResponse searchResponse = client ().prepareSearch ("index" )
@@ -366,9 +366,6 @@ public void onFailure(Exception e) {}
366
366
367
367
public void validatePitStats (String index , long expectedPitCurrent , long expectedOpenContexts ) throws ExecutionException ,
368
368
InterruptedException {
369
- // Clear the index transaction log
370
- FlushRequest flushRequest = Requests .flushRequest (index );
371
- client ().admin ().indices ().flush (flushRequest ).get ();
372
369
// Test stats
373
370
IndicesStatsRequest indicesStatsRequest = new IndicesStatsRequest ();
374
371
indicesStatsRequest .indices (index );
@@ -501,5 +498,4 @@ public void onFailure(Exception e) {}
501
498
ThreadPool .terminate (testThreadPool , 500 , TimeUnit .MILLISECONDS );
502
499
}
503
500
}
504
-
505
501
}
0 commit comments