|
18 | 18 | */ |
19 | 19 | package org.elasticsearch.cluster.coordination; |
20 | 20 |
|
| 21 | +import org.elasticsearch.ElasticsearchException; |
21 | 22 | import org.elasticsearch.Version; |
22 | 23 | import org.elasticsearch.cluster.node.DiscoveryNode; |
23 | 24 | import org.elasticsearch.cluster.node.DiscoveryNode.Role; |
|
30 | 31 |
|
31 | 32 | import java.util.Collections; |
32 | 33 | import java.util.concurrent.atomic.AtomicBoolean; |
| 34 | +import java.util.concurrent.atomic.AtomicLong; |
33 | 35 | import java.util.concurrent.atomic.AtomicReference; |
34 | 36 | import java.util.function.Supplier; |
35 | 37 | import java.util.stream.Collectors; |
@@ -217,18 +219,23 @@ public void testDoesNotBootstrapsIfZen1NodesDiscovered() { |
217 | 219 | deterministicTaskQueue.runAllTasks(); |
218 | 220 | } |
219 | 221 |
|
220 | | - public void testDoesNotRetryBootstrappingOnException() { |
221 | | - final AtomicBoolean bootstrappingAttempted = new AtomicBoolean(); |
| 222 | + public void testRetriesBootstrappingOnException() { |
| 223 | + |
| 224 | + final AtomicLong bootstrappingAttempts = new AtomicLong(); |
222 | 225 | ClusterBootstrapService clusterBootstrapService = new ClusterBootstrapService(Settings.builder().putList( |
223 | 226 | INITIAL_MASTER_NODES_SETTING.getKey(), localNode.getName(), otherNode1.getName(), otherNode2.getName()).build(), |
224 | 227 | transportService, () -> Stream.of(otherNode1, otherNode2).collect(Collectors.toList()), vc -> { |
225 | | - assertTrue(bootstrappingAttempted.compareAndSet(false, true)); |
| 228 | + bootstrappingAttempts.incrementAndGet(); |
| 229 | + if (bootstrappingAttempts.get() < 5L) { |
| 230 | + throw new ElasticsearchException("test"); |
| 231 | + } |
226 | 232 | }); |
227 | 233 |
|
228 | 234 | transportService.start(); |
229 | 235 | clusterBootstrapService.onFoundPeersUpdated(); |
230 | 236 | deterministicTaskQueue.runAllTasks(); |
231 | | - assertTrue(bootstrappingAttempted.get()); |
| 237 | + assertThat(bootstrappingAttempts.get(), greaterThanOrEqualTo(5L)); |
| 238 | + assertThat(deterministicTaskQueue.getCurrentTimeMillis(), greaterThanOrEqualTo(40000L)); |
232 | 239 | } |
233 | 240 |
|
234 | 241 | public void testDoesNotBootstrapIfRequirementNotMet() { |
|
0 commit comments