31
31
import org .elasticsearch .indices .IndicesService ;
32
32
import org .elasticsearch .plugins .Plugin ;
33
33
import org .elasticsearch .test .ESIntegTestCase ;
34
+ import org .elasticsearch .threadpool .ThreadPool ;
34
35
35
36
import java .util .Arrays ;
36
37
import java .util .Collection ;
46
47
import static org .elasticsearch .test .hamcrest .ElasticsearchAssertions .assertThrows ;
47
48
import static org .hamcrest .Matchers .containsString ;
48
49
import static org .hamcrest .Matchers .equalTo ;
50
+ import static org .hamcrest .Matchers .greaterThan ;
49
51
import static org .hamcrest .Matchers .nullValue ;
50
52
51
53
public class UpdateSettingsIT extends ESIntegTestCase {
@@ -125,6 +127,16 @@ public List<Setting<?>> getSettings() {
125
127
}
126
128
}
127
129
130
+ /**
131
+ * Needed by {@link UpdateSettingsIT#testEngineGCDeletesSetting()}
132
+ */
133
+ @ Override
134
+ protected Settings nodeSettings (int nodeOrdinal ) {
135
+ return Settings .builder ().put (super .nodeSettings (nodeOrdinal ))
136
+ .put ("thread_pool.estimated_time_interval" , 0 )
137
+ .build ();
138
+ }
139
+
128
140
public void testUpdateDependentClusterSettings () {
129
141
IllegalArgumentException iae = expectThrows (IllegalArgumentException .class , () ->
130
142
client ().admin ().cluster ().prepareUpdateSettings ().setPersistentSettings (Settings .builder ()
@@ -434,7 +446,7 @@ public void testOpenCloseUpdateSettings() throws Exception {
434
446
assertThat (getSettingsResponse .getSetting ("test" , "index.final" ), nullValue ());
435
447
}
436
448
437
- public void testEngineGCDeletesSetting () throws InterruptedException {
449
+ public void testEngineGCDeletesSetting () throws Exception {
438
450
createIndex ("test" );
439
451
client ().prepareIndex ("test" , "type" , "1" ).setSource ("f" , 1 ).get (); // set version to 1
440
452
client ().prepareDelete ("test" , "type" , "1" ).get (); // sets version to 2
@@ -443,11 +455,16 @@ public void testEngineGCDeletesSetting() throws InterruptedException {
443
455
client ().admin ().indices ().prepareUpdateSettings ("test" ).setSettings (Settings .builder ().put ("index.gc_deletes" , 0 )).get ();
444
456
445
457
client ().prepareDelete ("test" , "type" , "1" ).get (); // sets version to 4
446
- Thread .sleep (300 ); // wait for cache time to change TODO: this needs to be solved better. To be discussed.
447
- // delete is should not be in cache
448
- assertThrows (client ().prepareIndex ("test" , "type" , "1" ).setSource ("f" , 3 )
449
- .setVersion (4 ), VersionConflictEngineException .class );
450
458
459
+ // Make sure the time has advanced for InternalEngine#resolveDocVersion()
460
+ for (ThreadPool threadPool : internalCluster ().getInstances (ThreadPool .class )) {
461
+ long startTime = threadPool .relativeTimeInMillis ();
462
+ assertBusy (() -> assertThat (threadPool .relativeTimeInMillis (), greaterThan (startTime )));
463
+ }
464
+
465
+ // delete is should not be in cache
466
+ assertThrows (
467
+ client ().prepareIndex ("test" , "type" , "1" ).setSource ("f" , 3 ).setVersion (4 ), VersionConflictEngineException .class );
451
468
}
452
469
453
470
public void testUpdateSettingsWithBlocks () {
0 commit comments