From 6b02197ca12cb72d0425966e0b60ff58fc9c1a87 Mon Sep 17 00:00:00 2001 From: Yannick Welsch Date: Tue, 11 Jul 2017 11:46:17 +0200 Subject: [PATCH] [TEST] Ensure stable cluster before disabling licensing in testEnableDisableBehaviour If the cluster is still making cluster state updates while disabling the license, cluster state updates might not go through, triggering an assertion failure at the end of the test that checks if all cluster states have been applied. relates elastic/x-pack-elasticsearch#1627 Original commit: elastic/x-pack-elasticsearch@e11863fd029c0b1e7f73c5566e03f8c316d9dedc --- .../test/java/org/elasticsearch/license/LicensingTests.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/plugin/src/test/java/org/elasticsearch/license/LicensingTests.java b/plugin/src/test/java/org/elasticsearch/license/LicensingTests.java index 0255cf5498e..d3ff87ca36a 100644 --- a/plugin/src/test/java/org/elasticsearch/license/LicensingTests.java +++ b/plugin/src/test/java/org/elasticsearch/license/LicensingTests.java @@ -32,6 +32,7 @@ import org.elasticsearch.client.ResponseException; import org.elasticsearch.client.transport.NoNodeAvailableException; import org.elasticsearch.client.transport.TransportClient; import org.elasticsearch.cluster.metadata.MappingMetaData; +import org.elasticsearch.cluster.routing.ShardRoutingState; import org.elasticsearch.common.bytes.BytesArray; import org.elasticsearch.common.network.NetworkModule; import org.elasticsearch.common.settings.SecureString; @@ -159,6 +160,9 @@ public class LicensingTests extends SecurityIntegTestCase { assertEquals(DocWriteResponse.Result.CREATED, indexResponse.getResult()); refresh(); + // wait for all replicas to be started (to make sure that there are no more cluster state updates when we disable licensing) + assertBusy(() -> assertTrue(client().admin().cluster().prepareState().get().getState().routingTable() + .shardsWithState(ShardRoutingState.INITIALIZING).isEmpty())); Client client = internalCluster().transportClient();