You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@flink.apache.org by di...@apache.org on 2021/09/13 03:17:42 UTC
[flink] 01/02: [FLINK-24137][python][tests] Upload logs for PyFlink
tests
This is an automated email from the ASF dual-hosted git repository.
dianfu pushed a commit to branch release-1.13
in repository https://gitbox.apache.org/repos/asf/flink.git
commit d8bb231b4ed7b4707547759f50be6738f3f18353
Author: Dian Fu <di...@apache.org>
AuthorDate: Tue Sep 7 20:59:47 2021 +0800
[FLINK-24137][python][tests] Upload logs for PyFlink tests
---
flink-python/pyflink/pyflink_gateway_server.py | 26 +++++++++++++++++++++-----
flink-python/tox.ini | 1 +
tools/ci/test_controller.sh | 3 ++-
3 files changed, 24 insertions(+), 6 deletions(-)
diff --git a/flink-python/pyflink/pyflink_gateway_server.py b/flink-python/pyflink/pyflink_gateway_server.py
index 640172f..f3e4ebe 100644
--- a/flink-python/pyflink/pyflink_gateway_server.py
+++ b/flink-python/pyflink/pyflink_gateway_server.py
@@ -64,23 +64,39 @@ def find_java_executable():
def construct_log_settings():
templates = [
"-Dlog.file=${flink_log_dir}/flink-${flink_ident_string}-python-${hostname}.log",
- "-Dlog4j.configuration=${flink_conf_dir}/log4j-cli.properties",
- "-Dlog4j.configurationFile=${flink_conf_dir}/log4j-cli.properties",
- "-Dlogback.configurationFile=${flink_conf_dir}/logback.xml"
+ "-Dlog4j.configuration=${log4j_properties}",
+ "-Dlog4j.configurationFile=${log4j_properties}",
+ "-Dlogback.configurationFile=${logback_xml}"
]
flink_home = _find_flink_home()
flink_conf_dir = os.path.join(flink_home, "conf")
- flink_log_dir = os.path.join(flink_home, "log")
+ if "FLINK_LOG_DIR" in os.environ:
+ flink_log_dir = os.environ["FLINK_LOG_DIR"]
+ else:
+ flink_log_dir = os.path.join(flink_home, "log")
+
+ if "LOG4J_PROPERTIES" in os.environ:
+ log4j_properties = os.environ["LOG4J_PROPERTIES"]
+ else:
+ log4j_properties = "%s/log4j-cli.properties" % flink_conf_dir
+
+ if "LOGBACK_XML" in os.environ:
+ logback_xml = os.environ["LOGBACK_XML"]
+ else:
+ logback_xml = "%s/logback.xml" % flink_conf_dir
+
if "FLINK_IDENT_STRING" in os.environ:
flink_ident_string = os.environ["FLINK_IDENT_STRING"]
else:
flink_ident_string = getpass.getuser()
+
hostname = socket.gethostname()
log_settings = []
for template in templates:
log_settings.append(Template(template).substitute(
- flink_conf_dir=flink_conf_dir,
+ log4j_properties=log4j_properties,
+ logback_xml=logback_xml,
flink_log_dir=flink_log_dir,
flink_ident_string=flink_ident_string,
hostname=hostname))
diff --git a/flink-python/tox.ini b/flink-python/tox.ini
index ce7d02c..bf0b0d2 100644
--- a/flink-python/tox.ini
+++ b/flink-python/tox.ini
@@ -33,6 +33,7 @@ deps =
grpcio>=1.17.0,<=1.26.0
grpcio-tools>=1.3.5,<=1.14.2
apache-flink-libraries
+passenv = *
commands =
python --version
# python test
diff --git a/tools/ci/test_controller.sh b/tools/ci/test_controller.sh
index 470f5d3..c0fa5ad 100755
--- a/tools/ci/test_controller.sh
+++ b/tools/ci/test_controller.sh
@@ -77,7 +77,7 @@ source "${HERE}/watchdog.sh"
# Step 1: Rebuild jars and install Flink to local maven repository
# =============================================================================
-LOG4J_PROPERTIES=${HERE}/log4j.properties
+export LOG4J_PROPERTIES=${HERE}/log4j.properties
MVN_LOGGING_OPTIONS="-Dlog.dir=${DEBUG_FILES_OUTPUT_DIR} -Dlog4j.configurationFile=file://$LOG4J_PROPERTIES"
MVN_COMMON_OPTIONS="-Dflink.forkCount=2 -Dflink.forkCountTestPackage=2 -Dfast -Pskip-webui-build $MVN_LOGGING_OPTIONS"
@@ -101,6 +101,7 @@ fi
# =============================================================================
if [ $STAGE == $STAGE_PYTHON ]; then
+ sed -i "s/\(^appender\.file\.fileName = \).*$/\1\$\{sys:log\.file\}/g" ${HERE}/log4j.properties
run_with_watchdog "./flink-python/dev/lint-python.sh" $CALLBACK_ON_TIMEOUT
EXIT_CODE=$?
else