Skip to content

Commit c6cb7a3

Browse files
committed
Add ability to check failed tests w/ fragile list
Added ability to check failed tests w/ fragile list to be sure that the current fail equal to the issue mentioned in the fragile list. Part of issue tarantool/tarantool#5050
1 parent d16a312 commit c6cb7a3

File tree

4 files changed

+28
-9
lines changed

4 files changed

+28
-9
lines changed

dispatcher.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -356,6 +356,7 @@ def __init__(self, key, task_group, randomize):
356356
self.task_ids = task_group['task_ids']
357357
self.is_parallel = task_group['is_parallel']
358358
self.fragile_retries = int(task_group['fragile_retries'])
359+
self.fragile_checksums = task_group['fragile_checksums']
359360
if self.is_parallel:
360361
self.randomize = randomize
361362
if self.randomize:
@@ -385,7 +386,8 @@ def _run_worker(self, worker_id, tcp_port_range):
385386
os.environ['TEST_RUN_TCP_PORT_END'] = str(tcp_port_range[1])
386387
color_stdout.queue = self.result_queue
387388
worker = self.gen_worker(worker_id)
388-
worker.run_all(self.task_queue, self.result_queue, self.fragile_retries)
389+
worker.run_all(self.task_queue, self.result_queue, self.fragile_retries,
390+
self.fragile_checksums)
389391

390392
def add_worker(self, worker_id, tcp_port_range):
391393
# Note: each of our workers should consume only one None, but for the

lib/test.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import sys
99
import traceback
1010
from functools import partial
11+
from hashlib import md5
1112

1213
try:
1314
from cStringIO import StringIO
@@ -250,9 +251,12 @@ def run(self, server):
250251
color_stdout("[ updated ]\n", schema='test_new')
251252
else:
252253
has_result = os.path.exists(self.tmp_result)
254+
result_checksum = ''
253255
if has_result:
254256
shutil.copy(self.tmp_result, self.reject)
255-
short_status = 'fail'
257+
with open(self.tmp_result, mode='rb') as result_file:
258+
result_checksum = md5(result_file.read()).hexdigest()
259+
short_status = 'fail:' + result_checksum
256260
color_stdout("[ fail ]\n", schema='test_fail')
257261

258262
where = ""

lib/test_suite.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,14 @@ def fragile_tests(self):
174174
res.append(test)
175175
return res
176176

177+
def fragile_checksums(self):
178+
res = []
179+
for fragile in self.ini['fragile']:
180+
checksum = re.split(r'md5sum:', fragile)
181+
if not checksum[0]:
182+
res.append(checksum[1])
183+
return res
184+
177185
def gen_server(self):
178186
try:
179187
return Server(self.ini, test_suite=self)

lib/worker.py

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import copy
33
import functools
44
import os
5+
import re
56
import signal
67
import traceback
78
import yaml
@@ -83,6 +84,7 @@ def get_task_groups():
8384
'task_ids': stable_task_ids,
8485
'is_parallel': suite.is_parallel(),
8586
'fragile_retries': 0,
87+
'fragile_checksums': suite.fragile_checksums(),
8688
'show_reproduce_content': suite.show_reproduce_content(),
8789
}
8890
if fragile_task_ids:
@@ -91,6 +93,7 @@ def get_task_groups():
9193
'task_ids': fragile_task_ids,
9294
'is_parallel': False,
9395
'fragile_retries': suite.fragile_retries(),
96+
'fragile_checksums': suite.fragile_checksums(),
9497
'show_reproduce_content': suite.show_reproduce_content(),
9598
}
9699
return res
@@ -315,7 +318,7 @@ def run_task(self, task_id):
315318
raise
316319
return short_status
317320

318-
def run_loop(self, task_queue, result_queue, fragile_retries):
321+
def run_loop(self, task_queue, result_queue, fragile_retries, fragile_checksums):
319322
""" called from 'run_all' """
320323
while True:
321324
task_id = self.task_get(task_queue)
@@ -332,15 +335,17 @@ def run_loop(self, task_queue, result_queue, fragile_retries):
332335
# 'fragile_retries' value comes from the suite configuration
333336
retries_left = fragile_retries
334337
while short_status != 'pass' and retries_left >= 0:
335-
if short_status == 'fail':
338+
if re.match(r'^fail:.*', short_status):
336339
color_stdout(
337340
'Test "%s", conf: "%s"\n'
338-
'\tfrom "fragile" list failed - rerunning ...\n'
339-
% (task_id[0], task_id[1]) , schema='error')
341+
'\tfrom "fragile" list failed, result file checksum "%s" rerunning ...\n'
342+
% (task_id[0], task_id[1], short_status), schema='error')
340343
short_status = self.run_task(task_id)
344+
fail_checksum = re.split(r'fail:', short_status)
345+
if fragile_checksums and not fail_checksum[1] in fragile_checksums:
346+
break
341347
retries_left = retries_left - 1
342348

343-
344349
result_queue.put(self.wrap_result(task_id, short_status))
345350
if not lib.Options().args.is_force and short_status == 'fail':
346351
color_stdout(
@@ -354,14 +359,14 @@ def run_loop(self, task_queue, result_queue, fragile_retries):
354359
raise VoluntaryStopException()
355360
self.task_done(task_queue)
356361

357-
def run_all(self, task_queue, result_queue, fragile_retries):
362+
def run_all(self, task_queue, result_queue, fragile_retries, fragile_checksums):
358363
if not self.initialized:
359364
self.flush_all_tasks(task_queue, result_queue)
360365
result_queue.put(self.done_marker())
361366
return
362367

363368
try:
364-
self.run_loop(task_queue, result_queue, fragile_retries)
369+
self.run_loop(task_queue, result_queue, fragile_retries, fragile_checksums)
365370
except (KeyboardInterrupt, Exception) as e:
366371
if not isinstance(e, KeyboardInterrupt) and \
367372
not isinstance(e, VoluntaryStopException):

0 commit comments

Comments
 (0)