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