Skip to content

Commit 6598e1f

Browse files
committed
Test one- and two-node clusters
1 parent 696235b commit 6598e1f

File tree

1 file changed

+24
-4
lines changed

1 file changed

+24
-4
lines changed

server/src/internalClusterTest/java/org/elasticsearch/reservedstate/service/FileSettingsServiceIT.java

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,15 +35,16 @@
3535
import java.nio.file.Files;
3636
import java.nio.file.Path;
3737
import java.nio.file.StandardCopyOption;
38-
import java.util.List;
3938
import java.util.concurrent.CountDownLatch;
4039
import java.util.concurrent.ExecutionException;
4140
import java.util.concurrent.TimeUnit;
4241
import java.util.concurrent.atomic.AtomicLong;
42+
import java.util.stream.Stream;
4343

4444
import static org.elasticsearch.health.HealthStatus.YELLOW;
4545
import static org.elasticsearch.indices.recovery.RecoverySettings.INDICES_RECOVERY_MAX_BYTES_PER_SEC_SETTING;
4646
import static org.elasticsearch.node.Node.INITIAL_STATE_TIMEOUT_SETTING;
47+
import static org.elasticsearch.test.NodeRoles.dataNode;
4748
import static org.elasticsearch.test.NodeRoles.dataOnlyNode;
4849
import static org.elasticsearch.test.NodeRoles.masterNode;
4950
import static org.hamcrest.Matchers.allOf;
@@ -502,7 +503,19 @@ public void testSettingsAppliedOnMasterReElection() throws Exception {
502503
assertClusterStateSaveOK(savedClusterState.v1(), savedClusterState.v2(), "43mb");
503504
}
504505

505-
public void testHealthIndicator() throws Exception {
506+
public void testHealthIndicatorWithSingleNode() throws Exception {
507+
internalCluster().setBootstrapMasterNodeIndex(0);
508+
logger.info("--> start the node");
509+
String nodeName = internalCluster().startNode((dataNode()));
510+
FileSettingsService masterFileSettingsService = internalCluster().getInstance(FileSettingsService.class, nodeName);
511+
assertBusy(() -> assertTrue(masterFileSettingsService.watching()));
512+
513+
ensureStableCluster(1);
514+
515+
testHealthIndicatorOnError(nodeName, nodeName);
516+
}
517+
518+
public void testHealthIndicatorWithSeparateHealthNode() throws Exception {
506519
internalCluster().setBootstrapMasterNodeIndex(0);
507520
logger.info("--> start a data node to act as the health node");
508521
String healthNode = internalCluster().startNode(
@@ -518,7 +531,14 @@ public void testHealthIndicator() throws Exception {
518531

519532
ensureStableCluster(2);
520533

521-
// Initially, all is well
534+
testHealthIndicatorOnError(masterNode, healthNode);
535+
}
536+
537+
/**
538+
* {@code masterNode} and {@code healthNode} can be the same node.
539+
*/
540+
private void testHealthIndicatorOnError(String masterNode, String healthNode) throws Exception {
541+
logger.info("--> ensure all is well before the error");
522542
assertBusy(() -> {
523543
FetchHealthInfoCacheAction.Response healthNodeResponse = client().execute(
524544
FetchHealthInfoCacheAction.INSTANCE,
@@ -545,7 +565,7 @@ public void testHealthIndicator() throws Exception {
545565
healthNodeResponse.getHealthInfo().fileSettingsHealthInfo().failureStreak()
546566
);
547567

548-
for (var node : List.of(masterNode, healthNode)) {
568+
for (var node : Stream.of(masterNode, healthNode).distinct().toList()) {
549569
GetHealthAction.Response getHealthResponse = client(node).execute(
550570
GetHealthAction.INSTANCE,
551571
new GetHealthAction.Request(false, 123)

0 commit comments

Comments
 (0)