Skip to content

Commit

Permalink
Add ability to use fragile list in JSON format
Browse files Browse the repository at this point in the history
Added ability to use fragile list in JSON format from 'suite.ini'
files. For now it is possible to set fragile tests in both formats:

1) list of results files checksums in current text format:

  fragile = <basename of the test> ; gh-<issue> md5sum:<checksum>

2) list of results files checksums in newly used JSON format:

  fragile = {
    "retries": 10,
    "tests": {
        "bitset.test.lua": {
            "issues": [ "gh-4095" ],
            "checksums": [ "050af3a99561a724013995668a4bc71c", "f34be60193cfe9221d3fe50df657e9d3" ]
        }
    }}
  • Loading branch information
avtikhon committed Aug 13, 2020
1 parent cc4ada1 commit e40595e
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 10 deletions.
47 changes: 38 additions & 9 deletions lib/test_suite.py
Expand Up @@ -94,6 +94,7 @@ def __init__(self, suite_path, args):
self.ini = {}
self.suite_path = suite_path
self.ini["core"] = "tarantool"
self.ini["fragile_is_json"] = False

if not os.access(suite_path, os.F_OK):
raise RuntimeError("Suite %s doesn't exist" % repr(suite_path))
Expand Down Expand Up @@ -121,6 +122,14 @@ def __init__(self, suite_path, args):
lambda x: os.path.join(suite_path, x),
dict.fromkeys(self.ini[i].split())
if i in self.ini else dict())
for item in config.items("default"):
if item[0] == "fragile":
try:
self.ini['fragile'] = json.loads(item[1])
self.ini['fragile_is_json'] = True
except ValueError:
print "WARNING: suite '{}' uses old fragile format" . format(suite_path)
pass

self.parse_bool_opt('pretest_clean', False)
self.parse_bool_opt('use_unix_sockets', False)
Expand Down Expand Up @@ -167,29 +176,43 @@ def collect_tests(self):
self.tests_are_collected = True
return self.tests

def get_fragile_list(self):
if self.ini['fragile_is_json']:
return self.ini['fragile']['tests'].keys()
else:
return self.ini['fragile'].keys()

def stable_tests(self):
self.collect_tests()
res = []
for test in self.tests:
if os.path.basename(test.name) not in self.ini['fragile']:
if os.path.basename(test.name) not in self.get_fragile_list():
res.append(test)
return res

def fragile_tests(self):
self.collect_tests()
res = []
for test in self.tests:
if os.path.basename(test.name) in self.ini['fragile']:
if os.path.basename(test.name) in self.get_fragile_list():
res.append(test)
return res

def fragile_checksums(self):
res = []
for fragile in self.ini['fragile']:
checksum = re.split(r'md5sum:', fragile)
if not checksum[0]:
res.append(checksum[1])
return res
def get_fragile_checksums(self):
checksums = []
if self.ini['fragile_is_json']:
for test in self.get_fragile_list():
try:
for checksum in self.ini['fragile']['tests'][test]['checksums']:
checksums.append(checksum)
except Exception:
pass
else:
for fragile in self.ini['fragile']:
checksum = re.split(r'md5sum:', fragile)
if not checksum[0]:
checksums.append(checksum[1])
return checksums

def gen_server(self):
try:
Expand Down Expand Up @@ -272,6 +295,12 @@ def is_parallel(self):
return self.ini['is_parallel']

def fragile_retries(self):
if self.ini['fragile_is_json']:
try:
return self.ini['fragile']['retries']
except Exception:
pass

return self.ini['fragile_retries']

def show_reproduce_content(self):
Expand Down
2 changes: 1 addition & 1 deletion lib/worker.py
Expand Up @@ -317,7 +317,7 @@ def run_task(self, task_id):
return short_status

def run_loop(self, task_queue, result_queue, is_fragile):
fragile_checksums = self.suite.fragile_checksums()
fragile_checksums = self.suite.get_fragile_checksums()
""" called from 'run_all' """
while True:
task_id = self.task_get(task_queue)
Expand Down

0 comments on commit e40595e

Please sign in to comment.