Skip to content

Commit

Permalink
Show overall progress while running
Browse files Browse the repository at this point in the history
Fixes #361
  • Loading branch information
Totktonada committed May 5, 2023
1 parent affa13f commit 8304557
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 2 deletions.
4 changes: 3 additions & 1 deletion dispatcher.py
Expand Up @@ -92,6 +92,7 @@ def __init__(self, task_groups, max_workers_cnt, randomize):
self.task_queue_disps[key] = task_queue_disp
self.result_queues.append(task_queue_disp.result_queue)
self.task_queues.append(task_queue_disp.task_queue)
self.total_tasks_cnt = tasks_cnt

self.report_timeout = 0.1

Expand Down Expand Up @@ -133,7 +134,8 @@ def init_listeners(self):
watch_fail = not Options().args.is_force

log_output_watcher = LogOutputWatcher()
self.statistics = StatisticsWatcher(log_output_watcher.get_logfile)
self.statistics = StatisticsWatcher(log_output_watcher.get_logfile,
self.total_tasks_cnt)
self.artifacts = ArtifactsWatcher(log_output_watcher.get_logfile)
output_watcher = OutputWatcher()
self.listeners = [self.statistics, log_output_watcher, output_watcher, self.artifacts]
Expand Down
6 changes: 6 additions & 0 deletions lib/colorer.py
Expand Up @@ -104,6 +104,9 @@ class SchemaAscetic(CSchema):
'test_disa': {'fgcolor': 'grey'},
'error': {'fgcolor': 'red'},
'info': {'fgcolor': 'yellow'},
'good_status': {'fgcolor': 'black', 'bgcolor': 'lgreen', 'bold': True},
'tentative_status': {'fgcolor': 'black', 'bgcolor': 'yellow', 'bold': True},
'bad_status': {'fgcolor': 'white', 'bgcolor': 'red', 'bold': True},
'test_var': {'fgcolor': 'yellow'},
'test-run command': {'fgcolor': 'green'},
'tarantool command': {'fgcolor': 'blue'},
Expand All @@ -126,6 +129,9 @@ class SchemaPretty(CSchema):
'ts_text': {'fgcolor': 'lmagenta'},
'path': {'fgcolor': 'green', 'bold': True},
'info': {'fgcolor': 'yellow', 'bold': True},
'good_status': {'fgcolor': 'black', 'bgcolor': 'lgreen', 'bold': True},
'tentative_status': {'fgcolor': 'black', 'bgcolor': 'yellow', 'bold': True},
'bad_status': {'fgcolor': 'white', 'bgcolor': 'red', 'bold': True},
'separator': {'fgcolor': 'blue'},
't_name': {'fgcolor': 'lblue'},
'serv_text': {'fgcolor': 'lmagenta'},
Expand Down
29 changes: 28 additions & 1 deletion listeners.py
Expand Up @@ -34,7 +34,7 @@ def process_timeout(self, delta_seconds):


class StatisticsWatcher(BaseWatcher):
def __init__(self, get_logfile):
def __init__(self, get_logfile, total_tasks_cnt):
self.stats = dict()
self.field_size = 60
self._sampler = sampler
Expand All @@ -43,9 +43,12 @@ def __init__(self, get_logfile):
self.flaked_tasks = []
self.get_logfile = get_logfile
self.long_tasks = set()
self.total_tasks_cnt = total_tasks_cnt
self.finished_tasks_cnt = 0

def process_result(self, obj):
if isinstance(obj, WorkerTaskResult):
self.finished_tasks_cnt += 1
if obj.is_long:
self.long_tasks.add(obj.task_id)

Expand All @@ -59,9 +62,11 @@ def process_result(self, obj):
obj.show_reproduce_content))

self.duration_stats[obj.task_id] = obj.duration
self.print_status_line()

if isinstance(obj, WorkerFlakedTask):
self.flaked_tasks.append((obj.task_id, obj.worker_name, False))
self.print_status_line()

def get_long_mark(self, task):
return '(long)' if task in self.long_tasks else ''
Expand Down Expand Up @@ -197,6 +202,28 @@ def print_statistics(self):

return True, bool(self.flaked_tasks)

def print_status_line(self):
if not color_stdout.is_term:
return

lstats = ['{}: {}'.format(k, v) for k, v in self.stats.items()]
report = '[{}/{}] [{}]'.format(
self.finished_tasks_cnt,
self.total_tasks_cnt,
', '.join(sorted(lstats)))
if self.flaked_tasks:
report += ' [flaky: {}]'.format(len(self.flaked_tasks))

if self.stats.get('fail', 0) > 0:
color_schema = 'bad_status'
elif self.flaked_tasks:
color_schema = 'tentative_status'
else:
color_schema = 'good_status'

color_stdout(report, schema=color_schema)
color_stdout('\b' * len(report))


class ArtifactsWatcher(BaseWatcher):
"""ArtifactsWatcher listener collects list of all workers with failed
Expand Down

0 comments on commit 8304557

Please sign in to comment.