|
@@ -180,57 +180,6 @@ public class TransportAddVotingConfigExclusionsActionTests extends ESTestCase {
|
|
|
containsInAnyOrder(otherNode1Exclusion, otherNode2Exclusion));
|
|
|
}
|
|
|
|
|
|
- public void testWithdrawsVotesFromNodesMatchingWildcard() throws InterruptedException {
|
|
|
- final CountDownLatch countDownLatch = new CountDownLatch(2);
|
|
|
-
|
|
|
- clusterStateObserver.waitForNextChange(new AdjustConfigurationForExclusions(countDownLatch));
|
|
|
- transportService.sendRequest(localNode, AddVotingConfigExclusionsAction.NAME, makeRequestWithNodeDescriptions("other*"),
|
|
|
- expectSuccess(r -> {
|
|
|
- assertNotNull(r);
|
|
|
- countDownLatch.countDown();
|
|
|
- })
|
|
|
- );
|
|
|
-
|
|
|
- assertTrue(countDownLatch.await(30, TimeUnit.SECONDS));
|
|
|
- assertThat(clusterService.getClusterApplierService().state().getVotingConfigExclusions(),
|
|
|
- containsInAnyOrder(otherNode1Exclusion, otherNode2Exclusion));
|
|
|
- assertWarnings(AddVotingConfigExclusionsRequest.DEPRECATION_MESSAGE);
|
|
|
- }
|
|
|
-
|
|
|
- public void testWithdrawsVotesFromAllMasterEligibleNodes() throws InterruptedException {
|
|
|
- final CountDownLatch countDownLatch = new CountDownLatch(2);
|
|
|
-
|
|
|
- clusterStateObserver.waitForNextChange(new AdjustConfigurationForExclusions(countDownLatch));
|
|
|
- transportService.sendRequest(localNode, AddVotingConfigExclusionsAction.NAME, makeRequestWithNodeDescriptions("_all"),
|
|
|
- expectSuccess(r -> {
|
|
|
- assertNotNull(r);
|
|
|
- countDownLatch.countDown();
|
|
|
- })
|
|
|
- );
|
|
|
-
|
|
|
- assertTrue(countDownLatch.await(30, TimeUnit.SECONDS));
|
|
|
- assertThat(clusterService.getClusterApplierService().state().getVotingConfigExclusions(),
|
|
|
- containsInAnyOrder(localNodeExclusion, otherNode1Exclusion, otherNode2Exclusion));
|
|
|
- assertWarnings(AddVotingConfigExclusionsRequest.DEPRECATION_MESSAGE);
|
|
|
- }
|
|
|
-
|
|
|
- public void testWithdrawsVoteFromLocalNode() throws InterruptedException {
|
|
|
- final CountDownLatch countDownLatch = new CountDownLatch(2);
|
|
|
-
|
|
|
- clusterStateObserver.waitForNextChange(new AdjustConfigurationForExclusions(countDownLatch));
|
|
|
- transportService.sendRequest(localNode, AddVotingConfigExclusionsAction.NAME, makeRequestWithNodeDescriptions("_local"),
|
|
|
- expectSuccess(r -> {
|
|
|
- assertNotNull(r);
|
|
|
- countDownLatch.countDown();
|
|
|
- })
|
|
|
- );
|
|
|
-
|
|
|
- assertTrue(countDownLatch.await(30, TimeUnit.SECONDS));
|
|
|
- assertThat(clusterService.getClusterApplierService().state().getVotingConfigExclusions(),
|
|
|
- contains(localNodeExclusion));
|
|
|
- assertWarnings(AddVotingConfigExclusionsRequest.DEPRECATION_MESSAGE);
|
|
|
- }
|
|
|
-
|
|
|
public void testReturnsImmediatelyIfVoteAlreadyWithdrawn() throws InterruptedException {
|
|
|
final ClusterState state = clusterService.state();
|
|
|
setState(clusterService, builder(state)
|
|
@@ -255,55 +204,14 @@ public class TransportAddVotingConfigExclusionsActionTests extends ESTestCase {
|
|
|
contains(otherNode1Exclusion));
|
|
|
}
|
|
|
|
|
|
- public void testReturnsErrorIfNoMatchingNodeDescriptions() throws InterruptedException {
|
|
|
- final CountDownLatch countDownLatch = new CountDownLatch(1);
|
|
|
- final SetOnce<TransportException> exceptionHolder = new SetOnce<>();
|
|
|
-
|
|
|
- transportService.sendRequest(localNode, AddVotingConfigExclusionsAction.NAME, makeRequestWithNodeDescriptions("not-a-node"),
|
|
|
- expectError(e -> {
|
|
|
- exceptionHolder.set(e);
|
|
|
- countDownLatch.countDown();
|
|
|
- })
|
|
|
- );
|
|
|
-
|
|
|
- assertTrue(countDownLatch.await(30, TimeUnit.SECONDS));
|
|
|
- final Throwable rootCause = exceptionHolder.get().getRootCause();
|
|
|
- assertThat(rootCause, instanceOf(IllegalArgumentException.class));
|
|
|
- assertThat(rootCause.getMessage(),
|
|
|
- equalTo("add voting config exclusions request for [not-a-node] matched no master-eligible nodes"));
|
|
|
- assertWarnings(AddVotingConfigExclusionsRequest.DEPRECATION_MESSAGE);
|
|
|
- }
|
|
|
-
|
|
|
- public void testOnlyMatchesMasterEligibleNodes() throws InterruptedException {
|
|
|
- final CountDownLatch countDownLatch = new CountDownLatch(1);
|
|
|
- final SetOnce<TransportException> exceptionHolder = new SetOnce<>();
|
|
|
-
|
|
|
- transportService.sendRequest(localNode, AddVotingConfigExclusionsAction.NAME,
|
|
|
- makeRequestWithNodeDescriptions("_all", "master:false"),
|
|
|
- expectError(e -> {
|
|
|
- exceptionHolder.set(e);
|
|
|
- countDownLatch.countDown();
|
|
|
- })
|
|
|
- );
|
|
|
-
|
|
|
- assertTrue(countDownLatch.await(30, TimeUnit.SECONDS));
|
|
|
- final Throwable rootCause = exceptionHolder.get().getRootCause();
|
|
|
- assertThat(rootCause, instanceOf(IllegalArgumentException.class));
|
|
|
- assertThat(rootCause.getMessage(),
|
|
|
- equalTo("add voting config exclusions request for [_all, master:false] matched no master-eligible nodes"));
|
|
|
- assertWarnings(AddVotingConfigExclusionsRequest.DEPRECATION_MESSAGE);
|
|
|
- }
|
|
|
-
|
|
|
public void testExcludeAbsentNodesByNodeIds() throws InterruptedException {
|
|
|
final CountDownLatch countDownLatch = new CountDownLatch(2);
|
|
|
|
|
|
clusterStateObserver.waitForNextChange(new AdjustConfigurationForExclusions(countDownLatch));
|
|
|
transportService.sendRequest(localNode, AddVotingConfigExclusionsAction.NAME,
|
|
|
- new AddVotingConfigExclusionsRequest(Strings.EMPTY_ARRAY, new String[]{"absent_id"},
|
|
|
- Strings.EMPTY_ARRAY, TimeValue.timeValueSeconds(30)),
|
|
|
- expectSuccess(e -> {
|
|
|
- countDownLatch.countDown();
|
|
|
- })
|
|
|
+ new AddVotingConfigExclusionsRequest(new String[]{"absent_id"},
|
|
|
+ Strings.EMPTY_ARRAY, TimeValue.timeValueSeconds(30)),
|
|
|
+ expectSuccess(e -> countDownLatch.countDown())
|
|
|
);
|
|
|
|
|
|
assertTrue(countDownLatch.await(30, TimeUnit.SECONDS));
|
|
@@ -316,8 +224,8 @@ public class TransportAddVotingConfigExclusionsActionTests extends ESTestCase {
|
|
|
|
|
|
clusterStateObserver.waitForNextChange(new AdjustConfigurationForExclusions(countDownLatch));
|
|
|
transportService.sendRequest(localNode, AddVotingConfigExclusionsAction.NAME,
|
|
|
- new AddVotingConfigExclusionsRequest(Strings.EMPTY_ARRAY, new String[]{"other1", "other2"},
|
|
|
- Strings.EMPTY_ARRAY, TimeValue.timeValueSeconds(30)),
|
|
|
+ new AddVotingConfigExclusionsRequest(new String[]{"other1", "other2"},
|
|
|
+ Strings.EMPTY_ARRAY, TimeValue.timeValueSeconds(30)),
|
|
|
expectSuccess(r -> {
|
|
|
assertNotNull(r);
|
|
|
countDownLatch.countDown();
|
|
@@ -334,14 +242,12 @@ public class TransportAddVotingConfigExclusionsActionTests extends ESTestCase {
|
|
|
|
|
|
clusterStateObserver.waitForNextChange(new AdjustConfigurationForExclusions(countDownLatch));
|
|
|
transportService.sendRequest(localNode, AddVotingConfigExclusionsAction.NAME, new AddVotingConfigExclusionsRequest("absent_node"),
|
|
|
- expectSuccess(e -> {
|
|
|
- countDownLatch.countDown();
|
|
|
- })
|
|
|
+ expectSuccess(e -> countDownLatch.countDown())
|
|
|
);
|
|
|
|
|
|
assertTrue(countDownLatch.await(30, TimeUnit.SECONDS));
|
|
|
assertEquals(Set.of(new VotingConfigExclusion(VotingConfigExclusion.MISSING_VALUE_MARKER, "absent_node")),
|
|
|
- clusterService.getClusterApplierService().state().getVotingConfigExclusions());
|
|
|
+ clusterService.getClusterApplierService().state().getVotingConfigExclusions());
|
|
|
}
|
|
|
|
|
|
public void testExcludeExistingNodesByNodeNames() throws InterruptedException {
|
|
@@ -382,7 +288,7 @@ public class TransportAddVotingConfigExclusionsActionTests extends ESTestCase {
|
|
|
|
|
|
assertTrue(countDownLatch.await(30, TimeUnit.SECONDS));
|
|
|
assertThat(clusterService.getClusterApplierService().state().getVotingConfigExclusions(),
|
|
|
- contains(otherNode1Exclusion));
|
|
|
+ contains(otherNode1Exclusion));
|
|
|
}
|
|
|
|
|
|
public void testExcludeByNodeIdSucceedsEvenIfAllExclusionsAlreadyAdded() throws InterruptedException {
|
|
@@ -398,8 +304,8 @@ public class TransportAddVotingConfigExclusionsActionTests extends ESTestCase {
|
|
|
final CountDownLatch countDownLatch = new CountDownLatch(1);
|
|
|
|
|
|
transportService.sendRequest(localNode, AddVotingConfigExclusionsAction.NAME,
|
|
|
- new AddVotingConfigExclusionsRequest(Strings.EMPTY_ARRAY, new String[]{"other1"},
|
|
|
- Strings.EMPTY_ARRAY, TimeValue.timeValueSeconds(30)),
|
|
|
+ new AddVotingConfigExclusionsRequest(new String[]{"other1"},
|
|
|
+ Strings.EMPTY_ARRAY, TimeValue.timeValueSeconds(30)),
|
|
|
expectSuccess(r -> {
|
|
|
assertNotNull(r);
|
|
|
countDownLatch.countDown();
|
|
@@ -473,7 +379,8 @@ public class TransportAddVotingConfigExclusionsActionTests extends ESTestCase {
|
|
|
final CountDownLatch countDownLatch = new CountDownLatch(1);
|
|
|
final SetOnce<TransportException> exceptionHolder = new SetOnce<>();
|
|
|
|
|
|
- transportService.sendRequest(localNode, AddVotingConfigExclusionsAction.NAME, makeRequestWithNodeDescriptions("other*"),
|
|
|
+ transportService.sendRequest(localNode, AddVotingConfigExclusionsAction.NAME,
|
|
|
+ new AddVotingConfigExclusionsRequest("other1", "other2"),
|
|
|
expectError(e -> {
|
|
|
exceptionHolder.set(e);
|
|
|
countDownLatch.countDown();
|
|
@@ -483,10 +390,9 @@ public class TransportAddVotingConfigExclusionsActionTests extends ESTestCase {
|
|
|
assertTrue(countDownLatch.await(30, TimeUnit.SECONDS));
|
|
|
final Throwable rootCause = exceptionHolder.get().getRootCause();
|
|
|
assertThat(rootCause, instanceOf(IllegalArgumentException.class));
|
|
|
- assertThat(rootCause.getMessage(), equalTo("add voting config exclusions request for [other*] would add [" + newCount +
|
|
|
- "] exclusions to the existing [" + existingCount +
|
|
|
+ assertThat(rootCause.getMessage(), equalTo("add voting config exclusions request for nodes named [other1, other2] would add ["
|
|
|
+ + newCount + "] exclusions to the existing [" + existingCount +
|
|
|
"] which would exceed the maximum of [" + actualMaximum + "] set by [cluster.max_voting_config_exclusions]"));
|
|
|
- assertWarnings(AddVotingConfigExclusionsRequest.DEPRECATION_MESSAGE);
|
|
|
}
|
|
|
|
|
|
public void testTimesOut() throws InterruptedException {
|
|
@@ -494,8 +400,7 @@ public class TransportAddVotingConfigExclusionsActionTests extends ESTestCase {
|
|
|
final SetOnce<TransportException> exceptionHolder = new SetOnce<>();
|
|
|
|
|
|
transportService.sendRequest(localNode, AddVotingConfigExclusionsAction.NAME,
|
|
|
- new AddVotingConfigExclusionsRequest(new String[]{"other1"}, Strings.EMPTY_ARRAY, Strings.EMPTY_ARRAY,
|
|
|
- TimeValue.timeValueMillis(100)),
|
|
|
+ new AddVotingConfigExclusionsRequest(Strings.EMPTY_ARRAY, new String[]{"other1"}, TimeValue.timeValueMillis(100)),
|
|
|
expectError(e -> {
|
|
|
exceptionHolder.set(e);
|
|
|
countDownLatch.countDown();
|
|
@@ -504,10 +409,8 @@ public class TransportAddVotingConfigExclusionsActionTests extends ESTestCase {
|
|
|
|
|
|
assertTrue(countDownLatch.await(30, TimeUnit.SECONDS));
|
|
|
final Throwable rootCause = exceptionHolder.get().getRootCause();
|
|
|
- assertThat(rootCause,instanceOf(ElasticsearchTimeoutException.class));
|
|
|
+ assertThat(rootCause, instanceOf(ElasticsearchTimeoutException.class));
|
|
|
assertThat(rootCause.getMessage(), startsWith("timed out waiting for voting config exclusions [{other1}"));
|
|
|
- assertWarnings(AddVotingConfigExclusionsRequest.DEPRECATION_MESSAGE);
|
|
|
-
|
|
|
}
|
|
|
|
|
|
private TransportResponseHandler<AddVotingConfigExclusionsResponse> expectSuccess(
|
|
@@ -598,9 +501,4 @@ public class TransportAddVotingConfigExclusionsActionTests extends ESTestCase {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- private AddVotingConfigExclusionsRequest makeRequestWithNodeDescriptions(String... nodeDescriptions) {
|
|
|
- return new AddVotingConfigExclusionsRequest(nodeDescriptions, Strings.EMPTY_ARRAY,
|
|
|
- Strings.EMPTY_ARRAY, TimeValue.timeValueSeconds(30));
|
|
|
- }
|
|
|
-
|
|
|
}
|