diff --git a/tester.py b/tester.py index 3ef45cf970240d14fcc8b7b2a03a56ef1f07b403..06f154d0909b3e71786c0eac262dd051a3e8645d 100755 --- a/tester.py +++ b/tester.py @@ -10,6 +10,7 @@ import re import subprocess import sys import uuid +import glob import utils from utils import log @@ -39,6 +40,18 @@ def strip_colors(text): return re.sub(r'\033\[[\d;]+m', '', text) +def raid_idle(): + idle = True + devs = glob.glob('/sys/block/md*/md/sync_action') + for d in devs: + with open(d, 'r') as f: + sync_state = f.read() + if sync_state != "idle": + idle = False + print("State in %s is %s" % (d, sync_state)) + return idle + + class Tester(): USAGE = '''%s [-e] [-f] [-b] [-d] [-h] [msuser] -e: send email with report. @@ -101,7 +114,12 @@ class Tester(): tests = self.discover_tests(basic_only, msuser) if not tests: sys.exit(1) - exit_code = self.run_tests(tests, email, email_if_fail) + + if raid_idle(): + exit_code = self.run_tests(tests, email, email_if_fail) + else: + print('A RAID check or operation is in progress, aborting tests') + exit_code = 1 sys.exit(exit_code) def parse_file_header(self, path):