32
32
import org .elasticsearch .cluster .service .ClusterService ;
33
33
import org .elasticsearch .common .Priority ;
34
34
import org .elasticsearch .common .settings .Settings ;
35
+ import org .elasticsearch .common .util .set .Sets ;
35
36
import org .elasticsearch .index .query .QueryBuilders ;
36
37
import org .elasticsearch .plugins .Plugin ;
37
38
import org .elasticsearch .test .ESIntegTestCase ;
43
44
import org .elasticsearch .test .junit .annotations .TestLogging ;
44
45
import org .elasticsearch .test .transport .MockTransportService ;
45
46
47
+ import java .util .ArrayList ;
46
48
import java .util .Arrays ;
47
49
import java .util .Collection ;
48
50
import java .util .Collections ;
49
51
import java .util .HashSet ;
52
+ import java .util .List ;
50
53
import java .util .Set ;
51
54
import java .util .concurrent .CountDownLatch ;
52
55
import java .util .concurrent .atomic .AtomicReference ;
@@ -124,6 +127,7 @@ public void testTwoNodesNoMasterBlock() throws Exception {
124
127
logger .info ("--> add voting config exclusion for non-master node, to be sure it's not elected" );
125
128
client ().execute (AddVotingConfigExclusionsAction .INSTANCE , new AddVotingConfigExclusionsRequest (new String []{otherNode })).get ();
126
129
logger .info ("--> stop master node, no master block should appear" );
130
+ Settings masterDataPathSettings = internalCluster ().dataPathSettings (masterNode );
127
131
internalCluster ().stopRandomNode (InternalTestCluster .nameFilter (masterNode ));
128
132
129
133
awaitBusy (() -> {
@@ -137,7 +141,7 @@ public void testTwoNodesNoMasterBlock() throws Exception {
137
141
assertThat (state .nodes ().getMasterNode (), equalTo (null ));
138
142
139
143
logger .info ("--> starting the previous master node again..." );
140
- node2Name = internalCluster ().startNode (settings );
144
+ node2Name = internalCluster ().startNode (Settings . builder (). put ( settings ). put ( masterDataPathSettings ). build () );
141
145
142
146
clusterHealthResponse = client ().admin ().cluster ().prepareHealth ().setWaitForEvents (Priority .LANGUID )
143
147
.setWaitForYellowStatus ().setWaitForNodes ("2" ).execute ().actionGet ();
@@ -169,6 +173,7 @@ public void testTwoNodesNoMasterBlock() throws Exception {
169
173
logger .info ("--> add voting config exclusion for master node, to be sure it's not elected" );
170
174
client ().execute (AddVotingConfigExclusionsAction .INSTANCE , new AddVotingConfigExclusionsRequest (new String []{masterNode })).get ();
171
175
logger .info ("--> stop non-master node, no master block should appear" );
176
+ Settings otherNodeDataPathSettings = internalCluster ().dataPathSettings (otherNode );
172
177
internalCluster ().stopRandomNode (InternalTestCluster .nameFilter (otherNode ));
173
178
174
179
assertBusy (() -> {
@@ -177,7 +182,7 @@ public void testTwoNodesNoMasterBlock() throws Exception {
177
182
});
178
183
179
184
logger .info ("--> starting the previous master node again..." );
180
- internalCluster ().startNode (settings );
185
+ internalCluster ().startNode (Settings . builder (). put ( settings ). put ( otherNodeDataPathSettings ). build () );
181
186
182
187
ensureGreen ();
183
188
clusterHealthResponse = client ().admin ().cluster ().prepareHealth ().setWaitForEvents (Priority .LANGUID )
@@ -251,6 +256,10 @@ public void testThreeNodesNoMasterBlock() throws Exception {
251
256
assertHitCount (client ().prepareSearch ().setSize (0 ).setQuery (QueryBuilders .matchAllQuery ()).execute ().actionGet (), 100 );
252
257
}
253
258
259
+ List <String > nonMasterNodes = new ArrayList <>(Sets .difference (Sets .newHashSet (internalCluster ().getNodeNames ()),
260
+ Collections .singleton (internalCluster ().getMasterName ())));
261
+ Settings nonMasterDataPathSettings1 = internalCluster ().dataPathSettings (nonMasterNodes .get (0 ));
262
+ Settings nonMasterDataPathSettings2 = internalCluster ().dataPathSettings (nonMasterNodes .get (1 ));
254
263
internalCluster ().stopRandomNonMasterNode ();
255
264
internalCluster ().stopRandomNonMasterNode ();
256
265
@@ -262,7 +271,7 @@ public void testThreeNodesNoMasterBlock() throws Exception {
262
271
});
263
272
264
273
logger .info ("--> start back the 2 nodes " );
265
- internalCluster ().startNodes (2 , settings );
274
+ internalCluster ().startNodes (nonMasterDataPathSettings1 , nonMasterDataPathSettings2 );
266
275
267
276
internalCluster ().validateClusterFormed ();
268
277
ensureGreen ();
0 commit comments