Skip to content

Commit

Permalink
[FLINK-18343][e2e] Set Flink rootLogger to DEBUG
Browse files Browse the repository at this point in the history
  • Loading branch information
zentol committed Jun 19, 2020
1 parent febe8e3 commit f8b0bff
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import org.apache.flink.configuration.UnmodifiableConfiguration;
import org.apache.flink.tests.util.AutoClosableProcess;
import org.apache.flink.tests.util.TestUtils;
import org.apache.flink.tests.util.util.FileUtils;
import org.apache.flink.util.ExceptionUtils;

import org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.JsonNode;
Expand All @@ -34,6 +35,7 @@
import okhttp3.Response;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.slf4j.event.Level;

import java.io.BufferedReader;
import java.io.FileInputStream;
Expand Down Expand Up @@ -66,6 +68,8 @@ final class FlinkDistribution {

private static final ObjectMapper OBJECT_MAPPER = new ObjectMapper();

private static final Pattern ROOT_LOGGER_PATTERN = Pattern.compile("(rootLogger.level =).*");

private final Path opt;
private final Path lib;
private final Path conf;
Expand Down Expand Up @@ -96,6 +100,13 @@ public void startTaskManager() throws IOException {
AutoClosableProcess.runBlocking(bin.resolve("taskmanager.sh").toAbsolutePath().toString(), "start");
}

public void setRootLogLevel(Level logLevel) throws IOException {
FileUtils.replace(
conf.resolve("log4j.properties"),
ROOT_LOGGER_PATTERN,
matcher -> matcher.group(1) + " " + logLevel.name());
}

public void startFlinkCluster() throws IOException {
LOG.info("Starting Flink cluster.");
AutoClosableProcess.runBlocking(bin.resolve("start-cluster.sh").toAbsolutePath().toString());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
import org.junit.rules.TemporaryFolder;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.slf4j.event.Level;

import javax.annotation.Nullable;

Expand Down Expand Up @@ -80,6 +81,7 @@ public void before() throws Exception {
TestUtils.copyDirectory(distributionDirectory, tmp);

distribution = new FlinkDistribution(tmp);
distribution.setRootLogLevel(Level.DEBUG);
for (JarOperation jarOperation : setup.getJarOperations()) {
distribution.performJarOperation(jarOperation);
}
Expand Down

0 comments on commit f8b0bff

Please sign in to comment.