Skip to content

Commit 2612168

Browse files
Totktonadaavtikhon
authored andcommitted
Handle lack of a last result file at a worker hang
When there is no output from workers during a long time (10 seconds by default or 60 seconds when --long argument is passed), test-run prints a warning and shows amount of lines in the temporary result file. It is useful to understand on which statement a test hungs. I reproduced the problem, when mangled tarantool to ignore SIGTERM and SIGINT signals and run a simple 'tarantool = core' test. The test successfully passes, but the worker stucks in waiting for stopping the tarantool server. This particular case should be resolved in PR #186, but just because the timeout for stopping the server is less than the warning delay. This assumption looks fragile, especially if we'll want to make some of those timeouts / delays configurable. Let's handle the situation when the file does not exist. Found while looking into https://github.com/tarantool/tarantool/issues/5573 Fixes #245
1 parent 9fa8e0e commit 2612168

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

listeners.py

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -282,23 +282,28 @@ def process_timeout(self, delta_seconds):
282282
return
283283

284284
is_warning = self.inactivity < self.kill_timeout
285+
color_schema = 'test_var' if is_warning else 'error'
285286

286287
color_stdout(
287288
"No output during {0.inactivity:.0f} seconds. "
288289
"Will abort after {0.kill_timeout:.0f} seconds without output. "
289290
"List of workers not reporting the status:\n".format(self),
290-
schema=('test_var' if is_warning else 'error'))
291+
schema=color_schema)
291292

292293
hung_tasks = [task for worker_id, task
293294
in self.worker_current_task.iteritems()
294295
if worker_id in worker_ids]
295296
for task in hung_tasks:
296-
with open(task.task_tmp_result, 'r') as f:
297-
lines = sum(1 for _ in f)
298-
color_stdout("- {0} [{1}, {2}] at {3}:{4}\n".format(
297+
result_file = task.task_tmp_result
298+
result_file_summary = '(no result file {})'.format(result_file)
299+
if os.path.exists(result_file):
300+
with open(result_file, 'r') as f:
301+
lines = sum(1 for _ in f)
302+
result_file_summary = 'at {}:{}'.format(result_file,
303+
lines)
304+
color_stdout('- {} [{}, {}] {}\n'.format(
299305
task.worker_name, task.task_name, task.task_param,
300-
task.task_tmp_result, lines),
301-
schema=('test_var' if is_warning else 'error'))
306+
result_file_summary), schema=color_schema)
302307

303308
self.warned_seconds_ago = 0.0
304309

0 commit comments

Comments
 (0)