From 6907d06104bbfbaf7b01867b22ba459879113735 Mon Sep 17 00:00:00 2001 From: Yannick Welsch Date: Fri, 21 Jun 2019 18:25:05 +0200 Subject: [PATCH] test adjustment --- .../coordination/VotingOnlyNodePluginTests.java | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/x-pack/plugin/voting-only-node/src/test/java/org/elasticsearch/cluster/coordination/VotingOnlyNodePluginTests.java b/x-pack/plugin/voting-only-node/src/test/java/org/elasticsearch/cluster/coordination/VotingOnlyNodePluginTests.java index 903606606e6f8..4ef2081b990fd 100644 --- a/x-pack/plugin/voting-only-node/src/test/java/org/elasticsearch/cluster/coordination/VotingOnlyNodePluginTests.java +++ b/x-pack/plugin/voting-only-node/src/test/java/org/elasticsearch/cluster/coordination/VotingOnlyNodePluginTests.java @@ -87,19 +87,18 @@ public void testVotingOnlyNodesCannotBeMasterWithoutFullMasterNodes() throws Exc assertBusy(() -> assertThat( client().admin().cluster().prepareState().get().getState().getLastCommittedConfiguration().getNodeIds().size(), equalTo(3))); + final String oldMasterId = client().admin().cluster().prepareState().get().getState().nodes().getMasterNodeId(); internalCluster().stopCurrentMasterNode(); - try { - assertThat(client().admin().cluster().prepareState().setMasterNodeTimeout("100ms") - .execute().actionGet().getState().nodes().getMasterNodeId(), nullValue()); - fail("should not be able to find master"); - } catch (MasterNotDiscoveredException e) { - // all is well, no master elected - } + expectThrows(MasterNotDiscoveredException.class, () -> + assertThat(client().admin().cluster().prepareState().setMasterNodeTimeout("100ms").execute().actionGet() + .getState().nodes().getMasterNodeId(), nullValue())); // start a fresh full master node, which will be brought into the cluster as master by the voting-only nodes final String newMaster = internalCluster().startNode(); assertEquals(newMaster, internalCluster().getMasterName()); + final String newMasterId = client().admin().cluster().prepareState().get().getState().nodes().getMasterNodeId(); + assertNotEquals(oldMasterId, newMasterId); } }