Updated self-test sections
* Improved abort handling * Always include report if state.tests['Disk Self-Test'] is enabled * Send abort command via smartctl if aborting self-test(s)
This commit is contained in:
parent
c09cd0c9c2
commit
9dc8329dec
2 changed files with 41 additions and 16 deletions
|
|
@ -152,6 +152,11 @@ class State():
|
||||||
self_tests_in_progress = False
|
self_tests_in_progress = False
|
||||||
for disk in self.disks:
|
for disk in self.disks:
|
||||||
disable_tests = False
|
disable_tests = False
|
||||||
|
|
||||||
|
# Skip already disabled devices
|
||||||
|
if all([test.disabled for test in disk.tests.values()]):
|
||||||
|
continue
|
||||||
|
|
||||||
try:
|
try:
|
||||||
disk.safety_checks()
|
disk.safety_checks()
|
||||||
except hw_obj.CriticalHardwareError:
|
except hw_obj.CriticalHardwareError:
|
||||||
|
|
@ -270,7 +275,7 @@ class State():
|
||||||
self.tests[name]['Objects'].append(test_obj)
|
self.tests[name]['Objects'].append(test_obj)
|
||||||
|
|
||||||
# Run safety checks
|
# Run safety checks
|
||||||
#self.disk_safety_checks(prep=True)
|
self.disk_safety_checks(prep=True)
|
||||||
|
|
||||||
def init_tmux(self):
|
def init_tmux(self):
|
||||||
"""Initialize tmux layout."""
|
"""Initialize tmux layout."""
|
||||||
|
|
@ -567,6 +572,28 @@ def check_mprime_results(test_obj, working_dir):
|
||||||
test_obj.report.append(std.color_string(' Unknown result', 'YELLOW'))
|
test_obj.report.append(std.color_string(' Unknown result', 'YELLOW'))
|
||||||
|
|
||||||
|
|
||||||
|
def check_self_test_results(test_obj, aborted=False):
|
||||||
|
"""Check SMART self-test results."""
|
||||||
|
test_obj.report.append(std.color_string('Self-Test', 'BLUE'))
|
||||||
|
if test_obj.disabled or test_obj.status == 'Denied':
|
||||||
|
test_obj.report.append(std.color_string(f' {test_obj.status}', 'RED'))
|
||||||
|
elif test_obj.status == 'N/A' or not test_obj.dev.attributes:
|
||||||
|
test_obj.report.append(std.color_string(f' {test_obj.status}', 'YELLOW'))
|
||||||
|
else:
|
||||||
|
# Not updating SMART data here to preserve the test status for the report
|
||||||
|
# For instance if the test was aborted the report should inlcude the last
|
||||||
|
# known progress instead of just "was aborted buy host"
|
||||||
|
test_details = test_obj.dev.get_smart_self_test_details()
|
||||||
|
test_result = test_details.get('status', {}).get('string', 'Unknown')
|
||||||
|
test_obj.report.append(f' {test_result}')
|
||||||
|
if aborted and not (test_obj.passed or test_obj.failed):
|
||||||
|
test_obj.report.append(std.color_string(' Aborted', 'YELLOW'))
|
||||||
|
test_obj.set_status('Aborted')
|
||||||
|
elif test_obj.status == 'TimedOut':
|
||||||
|
test_obj.report.append(std.color_string(' TimedOut', 'YELLOW'))
|
||||||
|
test_obj.set_status('TimedOut')
|
||||||
|
|
||||||
|
|
||||||
def cpu_mprime_test(state, test_objects):
|
def cpu_mprime_test(state, test_objects):
|
||||||
"""CPU & cooling check using Prime95."""
|
"""CPU & cooling check using Prime95."""
|
||||||
LOG.info('CPU Test (Prime95)')
|
LOG.info('CPU Test (Prime95)')
|
||||||
|
|
@ -654,14 +681,12 @@ def cpu_mprime_test(state, test_objects):
|
||||||
|
|
||||||
|
|
||||||
def disable_disk_tests(disk):
|
def disable_disk_tests(disk):
|
||||||
"""Disable remaining tests for disk."""
|
"""Disable all tests for disk."""
|
||||||
LOG.warning('Disabling further tests for: %s', disk.path)
|
LOG.warning('Disabling all tests for: %s', disk.path)
|
||||||
for name, test in disk.tests.items():
|
for name, test in disk.tests.items():
|
||||||
if name == 'Disk Attributes':
|
|
||||||
continue
|
|
||||||
if test.status in ('Pending', 'Working'):
|
if test.status in ('Pending', 'Working'):
|
||||||
test.set_status('Denied')
|
test.set_status('Denied')
|
||||||
test.disabled = True
|
test.disabled = True
|
||||||
|
|
||||||
|
|
||||||
def disk_attribute_check(state, test_objects):
|
def disk_attribute_check(state, test_objects):
|
||||||
|
|
@ -875,18 +900,13 @@ def disk_self_test(state, test_objects):
|
||||||
break
|
break
|
||||||
except KeyboardInterrupt:
|
except KeyboardInterrupt:
|
||||||
aborted = True
|
aborted = True
|
||||||
|
for test in test_objects:
|
||||||
|
test.dev.abort_self_test()
|
||||||
|
std.sleep(0.5)
|
||||||
|
|
||||||
# Save report(s)
|
# Save report(s)
|
||||||
for test in test_objects:
|
for test in test_objects:
|
||||||
if test.status != 'N/A':
|
check_self_test_results(test, aborted=aborted)
|
||||||
test_details = test.dev.get_smart_self_test_details()
|
|
||||||
test_result = test_details.get('status', {}).get('string', 'Unknown')
|
|
||||||
test.report.append(std.color_string('Self-Test', 'BLUE'))
|
|
||||||
test.report.append(f' {test_result}')
|
|
||||||
if aborted and not (test.passed or test.failed):
|
|
||||||
test.report.append(std.color_string(' Aborted', 'YELLOW'))
|
|
||||||
elif test.status == 'TimedOut':
|
|
||||||
test.report.append(std.color_string(' TimedOut', 'YELLOW'))
|
|
||||||
|
|
||||||
# Cleanup
|
# Cleanup
|
||||||
state.update_progress_pane()
|
state.update_progress_pane()
|
||||||
|
|
@ -995,7 +1015,7 @@ def disk_surface_scan(state, test_objects):
|
||||||
std.sleep(0.5)
|
std.sleep(0.5)
|
||||||
# Handle aborts
|
# Handle aborts
|
||||||
for test in test_objects:
|
for test in test_objects:
|
||||||
if not (test.passed or test.failed):
|
if not (test.disabled or test.passed or test.failed):
|
||||||
test.set_status('Aborted')
|
test.set_status('Aborted')
|
||||||
test.report.append(std.color_string(' Aborted', 'YELLOW'))
|
test.report.append(std.color_string(' Aborted', 'YELLOW'))
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -151,6 +151,11 @@ class Disk(BaseObj):
|
||||||
if not self.is_4k_aligned():
|
if not self.is_4k_aligned():
|
||||||
self.add_note('One or more partitions are not 4K aligned', 'YELLOW')
|
self.add_note('One or more partitions are not 4K aligned', 'YELLOW')
|
||||||
|
|
||||||
|
def abort_self_test(self):
|
||||||
|
"""Abort currently running non-captive self-test."""
|
||||||
|
cmd = ['sudo', 'smartctl', '--abort', self.path]
|
||||||
|
run_program(cmd, check=False)
|
||||||
|
|
||||||
def add_note(self, note, color=None):
|
def add_note(self, note, color=None):
|
||||||
"""Add note that will be included in the disk report."""
|
"""Add note that will be included in the disk report."""
|
||||||
if color:
|
if color:
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue