|
|
@@ -54,6 +54,7 @@ import java.util.Set;
|
|
|
import java.util.concurrent.atomic.AtomicBoolean;
|
|
|
import java.util.concurrent.atomic.AtomicReference;
|
|
|
import java.util.function.Function;
|
|
|
+import java.util.function.UnaryOperator;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
import static java.util.Collections.emptyMap;
|
|
|
@@ -1602,6 +1603,13 @@ public class CoordinatorTests extends AbstractCoordinatorTestCase {
|
|
|
value = "org.elasticsearch.cluster.coordination.ClusterFormationFailureHelper:WARN"
|
|
|
)
|
|
|
public void testLogsWarningPeriodicallyIfClusterNotFormed() {
|
|
|
+ testLogsWarningPeriodicallyIfClusterNotFormed(
|
|
|
+ "master not discovered or elected yet, an election requires at least 2 nodes with ids from [",
|
|
|
+ nodeId -> "*have only discovered non-quorum *" + nodeId + "*discovery will continue*"
|
|
|
+ );
|
|
|
+ }
|
|
|
+
|
|
|
+ protected void testLogsWarningPeriodicallyIfClusterNotFormed(String expectedMessageStart, UnaryOperator<String> discoveryMessageFn) {
|
|
|
final long warningDelayMillis;
|
|
|
final Settings settings;
|
|
|
if (randomBoolean()) {
|
|
|
@@ -1645,10 +1653,7 @@ public class CoordinatorTests extends AbstractCoordinatorTestCase {
|
|
|
@Override
|
|
|
public void match(LogEvent event) {
|
|
|
final String message = event.getMessage().getFormattedMessage();
|
|
|
- assertThat(
|
|
|
- message,
|
|
|
- startsWith("master not discovered or elected yet, an election requires at least 2 nodes with ids from [")
|
|
|
- );
|
|
|
+ assertThat(message, startsWith(expectedMessageStart));
|
|
|
|
|
|
final List<ClusterNode> matchingNodes = cluster.clusterNodes.stream()
|
|
|
.filter(
|
|
|
@@ -1659,13 +1664,7 @@ public class CoordinatorTests extends AbstractCoordinatorTestCase {
|
|
|
.toList();
|
|
|
assertThat(matchingNodes, hasSize(1));
|
|
|
|
|
|
- assertTrue(
|
|
|
- message,
|
|
|
- Regex.simpleMatch(
|
|
|
- "*have only discovered non-quorum *" + matchingNodes.get(0).toString() + "*discovery will continue*",
|
|
|
- message
|
|
|
- )
|
|
|
- );
|
|
|
+ assertTrue(message, Regex.simpleMatch(discoveryMessageFn.apply(matchingNodes.get(0).toString()), message));
|
|
|
|
|
|
nodesLogged.add(matchingNodes.get(0).getLocalNode());
|
|
|
}
|