Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SPARK-36965][PYTHON] Extend python test runner by logging out the temp output files #34233

Closed
Closed
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 9 additions & 2 deletions python/run-tests.py
Expand Up @@ -48,6 +48,11 @@ def print_red(text):
print('\033[31m' + text + '\033[0m')


def get_valid_filename(s):
attilapiros marked this conversation as resolved.
Show resolved Hide resolved
s = s.strip().replace(' ', '_').replace(os.sep, '_')
return re.sub(r'(?u)[^-\w.]', '', s)


SKIPPED_TESTS = None
LOG_FILE = os.path.join(SPARK_HOME, "python/unit-tests.log")
FAILURE_REPORTING_LOCK = Lock()
Expand Down Expand Up @@ -98,10 +103,12 @@ def run_individual_python_test(target_dir, test_name, pyspark_python):
]
env["PYSPARK_SUBMIT_ARGS"] = " ".join(spark_args)

LOGGER.info("Starting test(%s): %s", pyspark_python, test_name)
output_prefix = get_valid_filename(pyspark_python + "__" + test_name + "__").lstrip("_")
per_test_output = tempfile.NamedTemporaryFile(prefix=output_prefix, suffix=".log")
LOGGER.info(
"Starting test(%s): %s (temp output: %s)", pyspark_python, test_name, per_test_output.name)
attilapiros marked this conversation as resolved.
Show resolved Hide resolved
start_time = time.time()
try:
per_test_output = tempfile.TemporaryFile()
retcode = subprocess.Popen(
[os.path.join(SPARK_HOME, "bin/pyspark")] + test_name.split(),
stderr=per_test_output, stdout=per_test_output, env=env).wait()
Expand Down