|
41 | 41 | import java.util.Locale; |
42 | 42 | import java.util.Map; |
43 | 43 | import java.util.concurrent.Future; |
| 44 | +import java.util.concurrent.TimeUnit; |
44 | 45 | import java.util.function.Predicate; |
45 | 46 |
|
46 | 47 | import static com.carrotsearch.randomizedtesting.RandomizedTest.randomAsciiOfLength; |
|
50 | 51 | import static org.hamcrest.Matchers.equalTo; |
51 | 52 | import static org.hamcrest.Matchers.hasSize; |
52 | 53 | import static org.hamcrest.Matchers.is; |
| 54 | +import static org.hamcrest.Matchers.isIn; |
53 | 55 | import static org.hamcrest.Matchers.notNullValue; |
54 | 56 | import static org.hamcrest.Matchers.nullValue; |
55 | 57 |
|
@@ -205,7 +207,6 @@ private String getNodeId(Predicate<Version> versionPredicate) throws IOException |
205 | 207 | return null; |
206 | 208 | } |
207 | 209 |
|
208 | | - @AwaitsFix(bugUrl = "https://github.com/elastic/elasticsearch/issues/34950") |
209 | 210 | public void testRelocationWithConcurrentIndexing() throws Exception { |
210 | 211 | final String index = "relocation_with_concurrent_indexing"; |
211 | 212 | switch (CLUSTER_TYPE) { |
@@ -239,6 +240,15 @@ public void testRelocationWithConcurrentIndexing() throws Exception { |
239 | 240 | ensureNoInitializingShards(); // wait for all other shard activity to finish |
240 | 241 | updateIndexSettings(index, Settings.builder().put("index.routing.allocation.include._id", newNode)); |
241 | 242 | asyncIndexDocs(index, 10, 50).get(); |
| 243 | + // ensure the relocation from old node to new node has occurred; otherwise ensureGreen can |
| 244 | + // return true even though shards haven't moved to the new node yet (allocation was throttled). |
| 245 | + assertBusy(() -> { |
| 246 | + Map<String, ?> state = entityAsMap(client().performRequest(new Request("GET", "/_cluster/state"))); |
| 247 | + String xpath = "routing_table.indices." + index + ".shards.0.node"; |
| 248 | + @SuppressWarnings("unchecked") List<String> assignedNodes = (List<String>) XContentMapValues.extractValue(xpath, state); |
| 249 | + assertNotNull(state.toString(), assignedNodes); |
| 250 | + assertThat(state.toString(), newNode, isIn(assignedNodes)); |
| 251 | + }, 60, TimeUnit.SECONDS); |
242 | 252 | ensureGreen(index); |
243 | 253 | client().performRequest(new Request("POST", index + "/_refresh")); |
244 | 254 | assertCount(index, "_only_nodes:" + newNode, 60); |
|
0 commit comments