Skip to content

Commit 79e4375

Browse files
DaveCTurneroriginal-brownbear
authored andcommitted
Add missing wait to testAutomaticReleaseOfIndexBlock (#45342)
Today the test waits for one of the shards to be blocked, but this does not mean that the block has been applied on all nodes, so a subsequent indexing operation may still go through. Fixes #45338
1 parent 3e621a8 commit 79e4375

File tree

1 file changed

+8
-11
lines changed

1 file changed

+8
-11
lines changed

server/src/test/java/org/elasticsearch/cluster/routing/allocation/decider/MockDiskUsagesIT.java

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
import org.elasticsearch.cluster.metadata.IndexMetaData;
3232
import org.elasticsearch.cluster.routing.RoutingNode;
3333
import org.elasticsearch.cluster.routing.allocation.DiskThresholdSettings;
34+
import org.elasticsearch.common.Priority;
3435
import org.elasticsearch.common.settings.Settings;
3536
import org.elasticsearch.common.unit.TimeValue;
3637
import org.elasticsearch.common.xcontent.XContentType;
@@ -41,15 +42,14 @@
4142
import java.util.Collection;
4243
import java.util.Collections;
4344
import java.util.HashMap;
44-
import java.util.Iterator;
4545
import java.util.List;
4646
import java.util.Map;
4747

48+
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertBlocked;
49+
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertSearchHits;
4850
import static org.hamcrest.Matchers.equalTo;
4951
import static org.hamcrest.Matchers.greaterThan;
5052
import static org.hamcrest.Matchers.greaterThanOrEqualTo;
51-
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertBlocked;
52-
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertSearchHits;
5353

5454
@ESIntegTestCase.ClusterScope(scope = ESIntegTestCase.Scope.TEST, numDataNodes = 0)
5555
public class MockDiskUsagesIT extends ESIntegTestCase {
@@ -143,7 +143,6 @@ public void testRerouteOccursOnDiskPassingHighWatermark() throws Exception {
143143
});
144144
}
145145

146-
@AwaitsFix(bugUrl = "https://github.com/elastic/elasticsearch/issues/45338")
147146
public void testAutomaticReleaseOfIndexBlock() throws Exception {
148147
List<String> nodes = internalCluster().startNodes(3);
149148

@@ -185,9 +184,7 @@ public void testAutomaticReleaseOfIndexBlock() throws Exception {
185184

186185
final List<String> realNodeNames = new ArrayList<>();
187186
ClusterStateResponse resp = client().admin().cluster().prepareState().get();
188-
Iterator<RoutingNode> iter = resp.getState().getRoutingNodes().iterator();
189-
while (iter.hasNext()) {
190-
RoutingNode node = iter.next();
187+
for (RoutingNode node : resp.getState().getRoutingNodes()) {
191188
realNodeNames.add(node.nodeId());
192189
logger.info("--> node {} has {} shards",
193190
node.nodeId(), resp.getState().getRoutingNodes().node(node.nodeId()).numberOfOwningShards());
@@ -203,10 +200,10 @@ public void testAutomaticReleaseOfIndexBlock() throws Exception {
203200
cis.setN3Usage(realNodeNames.get(2), new DiskUsage(nodes.get(2), "n3", "_na_", 100, 3));
204201

205202
// Wait until index "test" is blocked
206-
assertBusy(() -> {
207-
assertBlocked(client().prepareIndex().setIndex("test").setType("doc").setId("1").setSource("foo", "bar"),
208-
IndexMetaData.INDEX_READ_ONLY_ALLOW_DELETE_BLOCK);
209-
});
203+
assertBusy(() -> assertBlocked(client().prepareIndex().setIndex("test").setType("doc").setId("1").setSource("foo", "bar"),
204+
IndexMetaData.INDEX_READ_ONLY_ALLOW_DELETE_BLOCK));
205+
206+
assertFalse(client().admin().cluster().prepareHealth("test").setWaitForEvents(Priority.LANGUID).get().isTimedOut());
210207

211208
// Cannot add further documents
212209
assertBlocked(client().prepareIndex().setIndex("test").setType("doc").setId("2").setSource("foo", "bar"),

0 commit comments

Comments
 (0)