Test: check no master block on all nodes
Original commit: elastic/x-pack-elasticsearch@611ce01d69
This commit is contained in:
parent
beb4fada5f
commit
4e239a8be6
|
@ -9,6 +9,7 @@ import org.elasticsearch.ExceptionsHelper;
|
||||||
import org.elasticsearch.action.search.SearchRequest;
|
import org.elasticsearch.action.search.SearchRequest;
|
||||||
import org.elasticsearch.alerts.transport.actions.delete.DeleteAlertResponse;
|
import org.elasticsearch.alerts.transport.actions.delete.DeleteAlertResponse;
|
||||||
import org.elasticsearch.alerts.transport.actions.stats.AlertsStatsResponse;
|
import org.elasticsearch.alerts.transport.actions.stats.AlertsStatsResponse;
|
||||||
|
import org.elasticsearch.client.Client;
|
||||||
import org.elasticsearch.cluster.ClusterState;
|
import org.elasticsearch.cluster.ClusterState;
|
||||||
import org.elasticsearch.common.base.Predicate;
|
import org.elasticsearch.common.base.Predicate;
|
||||||
import org.elasticsearch.common.bytes.BytesReference;
|
import org.elasticsearch.common.bytes.BytesReference;
|
||||||
|
@ -85,9 +86,7 @@ public class NoMasterNodeTests extends AbstractAlertingTests {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testMultipleFailures() throws Exception {
|
public void testMultipleFailures() throws Exception {
|
||||||
// TODO: increase number of times we kill the elected master.
|
int numberOfFailures = scaledRandomIntBetween(2, 9);
|
||||||
// It is not good enough yet: after multi a couple of kills errors occur and assertions fail.
|
|
||||||
int numberOfFailures = 1;//scaledRandomIntBetween(2, 9);
|
|
||||||
int numberOfAlerts = scaledRandomIntBetween(numberOfFailures, 12);
|
int numberOfAlerts = scaledRandomIntBetween(numberOfFailures, 12);
|
||||||
config = new ClusterDiscoveryConfiguration.UnicastZen(2 + numberOfFailures);
|
config = new ClusterDiscoveryConfiguration.UnicastZen(2 + numberOfFailures);
|
||||||
internalTestCluster().startNodesAsync(2).get();
|
internalTestCluster().startNodesAsync(2).get();
|
||||||
|
@ -123,8 +122,13 @@ public class NoMasterNodeTests extends AbstractAlertingTests {
|
||||||
// Can't use ensureAlertingStopped, b/c that relies on the alerts stats api which requires an elected master node
|
// Can't use ensureAlertingStopped, b/c that relies on the alerts stats api which requires an elected master node
|
||||||
assertThat(awaitBusy(new Predicate<Object>() {
|
assertThat(awaitBusy(new Predicate<Object>() {
|
||||||
public boolean apply(Object obj) {
|
public boolean apply(Object obj) {
|
||||||
ClusterState state = client().admin().cluster().prepareState().setLocal(true).get().getState();
|
for (Client client : clients()) {
|
||||||
return state.blocks().hasGlobalBlock(DiscoverySettings.NO_MASTER_BLOCK_ID);
|
ClusterState state = client.admin().cluster().prepareState().setLocal(true).get().getState();
|
||||||
|
if (!state.blocks().hasGlobalBlock(DiscoverySettings.NO_MASTER_BLOCK_ID)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
}), equalTo(true));
|
}), equalTo(true));
|
||||||
// Ensure that the alert manager doesn't run elsewhere
|
// Ensure that the alert manager doesn't run elsewhere
|
||||||
|
|
Loading…
Reference in New Issue