Skip to content

Commit e092bd4

Browse files
author
Sergei Voronezhskii
committed
Add new config param 'show_reproduce_content'
By default this param is True, if the test fails then the contents of reproduce file are displayed. If the parameter is False, do not show the contents of reproduce file. For example, the 'sql-tap' tests run each case in a separate tarantool instance, so reproduce is not necessary for problem investigation. Used in 'suite.ini'. Closes #113
1 parent cc0de90 commit e092bd4

File tree

4 files changed

+44
-21
lines changed

4 files changed

+44
-21
lines changed

lib/test_suite.py

Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,9 @@ def __init__(self, suite_path, args):
9999
self.ini[i] = map(lambda x: os.path.join(suite_path, x),
100100
dict.fromkeys(self.ini[i].split()) if i in self.ini else dict())
101101

102+
self.ini.update(
103+
dict(show_reproduce_content=self.show_reproduce_content()))
104+
102105
def find_tests(self):
103106
if self.ini['core'] == 'tarantool':
104107
TarantoolServer.find_tests(self, self.suite_path)
@@ -205,12 +208,23 @@ def run_test(self, test, server, inspector):
205208
return short_status
206209

207210
def is_parallel(self):
208-
val = self.ini.get('is_parallel', 'False').lower()
209-
if val == 'true':
210-
val = True
211-
elif val == 'false':
212-
val = False
213-
else:
214-
raise ConfigurationError()
215-
pass
216-
return val
211+
val = self.ini.get('is_parallel', 'false')
212+
if isinstance(val, bool):
213+
return val
214+
# If value is not boolean it come from ini file, need to
215+
# convert string 'True' or 'False' into boolean representation
216+
if val.lower() not in ['true', 'false']:
217+
raise ConfigurationError('is_parallel', val, "'True' or 'False'")
218+
return val.lower() == 'true'
219+
220+
def show_reproduce_content(self):
221+
val = self.ini.get('show_reproduce_content', 'true')
222+
if isinstance(val, bool):
223+
return val
224+
# If value is not boolean it come from ini file, need to
225+
# convert string 'True' or 'False' into boolean representation
226+
if val.lower() not in ['true', 'false']:
227+
raise ConfigurationError('show_reproduce_content',
228+
val,
229+
"'True' or 'False'")
230+
return val.lower() == 'true'

lib/worker.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ def get_task_groups():
7878
'gen_worker': gen_worker,
7979
'task_ids': task_ids,
8080
'is_parallel': suite.is_parallel(),
81+
'show_reproduce_content': suite.show_reproduce_content()
8182
}
8283
return res
8384

@@ -131,12 +132,14 @@ class WorkerTaskResult(BaseWorkerMessage):
131132
worker. The short_status (string) field intended to give short note whether
132133
the task processed successfully or not, but with little more flexibility
133134
than binary True/False. The task_id (any hashable object) field hold ID of
134-
the processed task.
135+
the processed task. The show_reproduce_content configuration form suite.ini
135136
"""
136-
def __init__(self, worker_id, worker_name, task_id, short_status):
137+
def __init__(self, worker_id, worker_name, task_id,
138+
short_status, show_reproduce_content):
137139
super(WorkerTaskResult, self).__init__(worker_id, worker_name)
138140
self.short_status = short_status
139141
self.task_id = task_id
142+
self.show_reproduce_content = show_reproduce_content
140143

141144

142145
class WorkerOutput(BaseWorkerMessage):
@@ -198,7 +201,8 @@ def current_task(self, task_id):
198201
task_name, task_param, task_result_filepath)
199202

200203
def wrap_result(self, task_id, short_status):
201-
return WorkerTaskResult(self.id, self.name, task_id, short_status)
204+
return WorkerTaskResult(self.id, self.name, task_id, short_status,
205+
self.suite.show_reproduce_content())
202206

203207
def sigterm_handler(self, signum, frame):
204208
self.sigterm_received = True

listeners.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,9 @@ def process_result(self, obj):
4040
self.stats[obj.short_status] += 1
4141

4242
if obj.short_status == 'fail':
43-
self.failed_tasks.append((obj.task_id, obj.worker_name))
43+
self.failed_tasks.append((obj.task_id,
44+
obj.worker_name,
45+
obj.show_reproduce_content))
4446

4547
def print_statistics(self):
4648
"""Returns are there failed tasks."""
@@ -53,15 +55,16 @@ def print_statistics(self):
5355
return False
5456

5557
color_stdout('Failed tasks:\n', schema='test_var')
56-
for task_id, worker_name in self.failed_tasks:
58+
for task_id, worker_name, show_reproduce_content in self.failed_tasks:
5759
logfile = self.get_logfile(worker_name)
58-
reproduce_file_path = get_reproduce_file(worker_name)
5960
color_stdout('- %s' % yaml.safe_dump(task_id), schema='test_var')
6061
color_stdout('# logfile: %s\n' % logfile)
62+
reproduce_file_path = get_reproduce_file(worker_name)
6163
color_stdout('# reproduce file: %s\n' % reproduce_file_path)
62-
color_stdout("---\n", schema='separator')
63-
lib.utils.print_tail_n(reproduce_file_path)
64-
color_stdout("...\n", schema='separator')
64+
if show_reproduce_content:
65+
color_stdout("---\n", schema='separator')
66+
lib.utils.print_tail_n(reproduce_file_path)
67+
color_stdout("...\n", schema='separator')
6568

6669
return True
6770

test-run.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,7 @@ def main_loop_consistent(failed_test_ids):
151151
color_stdout('-' * 75, "\n", schema='separator')
152152

153153
task_ids = task_group['task_ids']
154+
show_reproduce_content = task_group['show_reproduce_content']
154155
if not task_ids:
155156
continue
156157
worker_id = 1
@@ -162,9 +163,10 @@ def main_loop_consistent(failed_test_ids):
162163
lib.worker.get_reproduce_file(worker.name)
163164
color_stdout('Reproduce file %s\n' %
164165
reproduce_file_path, schema='error')
165-
color_stdout("---\n", schema='separator')
166-
lib.utils.print_tail_n(reproduce_file_path)
167-
color_stdout("...\n", schema='separator')
166+
if show_reproduce_content:
167+
color_stdout("---\n", schema='separator')
168+
lib.utils.print_tail_n(reproduce_file_path)
169+
color_stdout("...\n", schema='separator')
168170
failed_test_ids.append(task_id)
169171
if not lib.Options().args.is_force:
170172
worker.stop_server(cleanup=False)

0 commit comments

Comments
 (0)