Skip to content

Commit

Permalink
ESQL: Fix logging test
Browse files Browse the repository at this point in the history
This fixes the logging tests when run against multiple nodes.

Closes elastic#108367
  • Loading branch information
nik9000 committed May 10, 2024
1 parent 04d3b99 commit 9132ade
Showing 1 changed file with 14 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -118,15 +118,16 @@ public void testDoNotLogWithInfo() throws IOException {
Map<String, String> colA = Map.of("name", "DO_NOT_LOG_ME", "type", "integer");
assertEquals(List.of(colA), result.get("columns"));
assertEquals(List.of(List.of(1)), result.get("values"));
try (InputStream log = cluster.getNodeLog(0, LogType.SERVER)) {
Streams.readAllLines(log, line -> { assertThat(line, not(containsString("DO_NOT_LOG_ME"))); });
for (int i = 0; i < cluster.getNumNodes(); i++) {
try (InputStream log = cluster.getNodeLog(i, LogType.SERVER)) {
Streams.readAllLines(log, line -> assertThat(line, not(containsString("DO_NOT_LOG_ME"))));
}
}
} finally {
setLoggingLevel(null);
}
}

@AwaitsFix(bugUrl = "https://github.com/elastic/elasticsearch/issues/108367")
public void testDoLogWithDebug() throws IOException {
try {
setLoggingLevel("DEBUG");
Expand All @@ -136,14 +137,16 @@ public void testDoLogWithDebug() throws IOException {
Map<String, String> colA = Map.of("name", "DO_LOG_ME", "type", "integer");
assertEquals(List.of(colA), result.get("columns"));
assertEquals(List.of(List.of(1)), result.get("values"));
try (InputStream log = cluster.getNodeLog(0, LogType.SERVER)) {
boolean[] found = new boolean[] { false };
Streams.readAllLines(log, line -> {
if (line.contains("DO_LOG_ME")) {
found[0] = true;
}
});
assertThat(found[0], equalTo(true));
boolean[] found = new boolean[] { false };
for (int i = 0; i < cluster.getNumNodes(); i++) {
try (InputStream log = cluster.getNodeLog(0, LogType.SERVER)) {
Streams.readAllLines(log, line -> {
if (line.contains("DO_LOG_ME")) {
found[0] = true;
}
});
assertThat(found[0], equalTo(true));
}
}
} finally {
setLoggingLevel(null);
Expand Down

0 comments on commit 9132ade

Please sign in to comment.