|
23 | 23 | import org.elasticsearch.action.admin.cluster.node.info.NodesInfoResponse;
|
24 | 24 | import org.elasticsearch.action.admin.cluster.settings.ClusterUpdateSettingsResponse;
|
25 | 25 | import org.elasticsearch.action.admin.indices.close.CloseIndexResponse;
|
| 26 | +import org.elasticsearch.action.admin.indices.create.CreateIndexResponse; |
26 | 27 | import org.elasticsearch.action.admin.indices.open.OpenIndexResponse;
|
27 | 28 | import org.elasticsearch.client.Client;
|
28 | 29 | import org.elasticsearch.cluster.ClusterState;
|
|
33 | 34 | import org.elasticsearch.cluster.routing.allocation.decider.ThrottlingAllocationDecider;
|
34 | 35 | import org.elasticsearch.common.settings.Settings;
|
35 | 36 | import org.elasticsearch.discovery.DiscoverySettings;
|
| 37 | +import org.elasticsearch.discovery.zen.PublishClusterStateAction; |
| 38 | +import org.elasticsearch.plugins.Plugin; |
36 | 39 | import org.elasticsearch.test.ESIntegTestCase;
|
37 | 40 | import org.elasticsearch.test.ESIntegTestCase.ClusterScope;
|
| 41 | +import org.elasticsearch.test.transport.MockTransportService; |
| 42 | +import org.elasticsearch.transport.TransportService; |
| 43 | + |
| 44 | +import java.util.Arrays; |
| 45 | +import java.util.Collection; |
| 46 | +import java.util.stream.Stream; |
38 | 47 |
|
39 | 48 | import static org.elasticsearch.test.ESIntegTestCase.Scope.TEST;
|
40 | 49 | import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked;
|
|
43 | 52 | @ClusterScope(scope = TEST, minNumDataNodes = 2)
|
44 | 53 | public class AckClusterUpdateSettingsIT extends ESIntegTestCase {
|
45 | 54 |
|
| 55 | + @Override |
| 56 | + protected Collection<Class<? extends Plugin>> nodePlugins() { |
| 57 | + return Arrays.asList(MockTransportService.TestPlugin.class); |
| 58 | + } |
| 59 | + |
46 | 60 | @Override
|
47 | 61 | protected Settings nodeSettings(int nodeOrdinal) {
|
48 | 62 | return Settings.builder()
|
@@ -156,4 +170,32 @@ public void testOpenIndexNoAcknowledgement() {
|
156 | 170 | assertThat(openIndexResponse.isAcknowledged(), equalTo(false));
|
157 | 171 | ensureGreen("test"); // make sure that recovery from disk has completed, so that check index doesn't fail.
|
158 | 172 | }
|
| 173 | + |
| 174 | + public void testAckingFailsIfNotPublishedToAllNodes() { |
| 175 | + String masterNode = internalCluster().getMasterName(); |
| 176 | + String nonMasterNode = Stream.of(internalCluster().getNodeNames()) |
| 177 | + .filter(node -> node.equals(masterNode) == false).findFirst().get(); |
| 178 | + |
| 179 | + MockTransportService masterTransportService = |
| 180 | + (MockTransportService) internalCluster().getInstance(TransportService.class, masterNode); |
| 181 | + MockTransportService nonMasterTransportService = |
| 182 | + (MockTransportService) internalCluster().getInstance(TransportService.class, nonMasterNode); |
| 183 | + |
| 184 | + logger.info("blocking cluster state publishing from master [{}] to non master [{}]", masterNode, nonMasterNode); |
| 185 | + if (randomBoolean() && internalCluster().numMasterNodes() != 2) { |
| 186 | + masterTransportService.addFailToSendNoConnectRule(nonMasterTransportService, PublishClusterStateAction.SEND_ACTION_NAME); |
| 187 | + } else { |
| 188 | + masterTransportService.addFailToSendNoConnectRule(nonMasterTransportService, PublishClusterStateAction.COMMIT_ACTION_NAME); |
| 189 | + } |
| 190 | + |
| 191 | + CreateIndexResponse response = client().admin().indices().prepareCreate("test").get(); |
| 192 | + assertFalse(response.isAcknowledged()); |
| 193 | + |
| 194 | + logger.info("waiting for cluster to reform"); |
| 195 | + masterTransportService.clearRule(nonMasterTransportService); |
| 196 | + |
| 197 | + ensureStableCluster(internalCluster().size()); |
| 198 | + |
| 199 | + assertAcked(client().admin().indices().prepareDelete("test")); |
| 200 | + } |
159 | 201 | }
|
0 commit comments