|
20 | 20 | package org.elasticsearch.gateway.fs;
|
21 | 21 |
|
22 | 22 | import com.carrotsearch.randomizedtesting.annotations.Nightly;
|
| 23 | +import com.google.common.base.Predicate; |
23 | 24 | import org.apache.lucene.util.LuceneTestCase.Slow;
|
24 | 25 | import org.apache.lucene.util.SetOnce;
|
25 | 26 | import org.elasticsearch.action.admin.cluster.health.ClusterHealthResponse;
|
|
45 | 46 |
|
46 | 47 | import static org.elasticsearch.client.Requests.*;
|
47 | 48 | import static org.elasticsearch.index.query.QueryBuilders.matchAllQuery;
|
| 49 | +import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked; |
48 | 50 | import static org.hamcrest.Matchers.*;
|
49 | 51 |
|
50 | 52 | /**
|
@@ -363,17 +365,21 @@ public void testIndexActions() throws Exception {
|
363 | 365 | assertThat(clusterHealth.isTimedOut(), equalTo(false));
|
364 | 366 | assertThat(clusterHealth.getStatus(), equalTo(ClusterHealthStatus.GREEN));
|
365 | 367 |
|
366 |
| - client().admin().indices().create(createIndexRequest("test")).actionGet(); |
| 368 | + assertAcked(client().admin().indices().create(createIndexRequest("test")).actionGet()); |
367 | 369 |
|
368 | 370 | cluster().stopRandomNode();
|
369 |
| - |
370 | 371 | cluster().startNode(nodeSettings(0));
|
371 |
| - Thread.sleep(500); |
372 |
| - try { |
373 |
| - client().admin().indices().create(createIndexRequest("test")).actionGet(); |
374 |
| - assert false : "index should exists"; |
375 |
| - } catch (IndexAlreadyExistsException e) { |
376 |
| - // all is well |
377 |
| - } |
| 372 | + assertTrue("index should exists", awaitBusy(new Predicate<Object>() { |
| 373 | + @Override |
| 374 | + public boolean apply(Object input) { |
| 375 | + try { |
| 376 | + client().admin().indices().create(createIndexRequest("test")).actionGet(); |
| 377 | + return false; |
| 378 | + } catch (IndexAlreadyExistsException e) { |
| 379 | + // all is well |
| 380 | + return true; |
| 381 | + } |
| 382 | + } |
| 383 | + })); |
378 | 384 | }
|
379 | 385 | }
|
0 commit comments