Add an option to keep machines locked if a test fails.

This commit is contained in:
Josh Durgin 2011-07-11 15:48:42 -07:00
parent c47dc179e7
commit 28f19a4104
2 changed files with 13 additions and 3 deletions

View File

@ -60,6 +60,12 @@ def parse_args():
default=False,
help='block until locking machines succeeds (use with --lock)',
)
parser.add_argument(
'--keep-locked-on-error',
action='store_true',
default=False,
help='unlock machines only if the test succeeds (use with --lock)',
)
args = parser.parse_args()
return args
@ -84,6 +90,9 @@ def main():
if ctx.block:
assert ctx.lock, \
'the --block option is only supported with the --lock option'
if ctx.keep_locked_on_error:
assert ctx.lock, \
'the --keep_locked_on_error option is only supported with the --lock option'
from teuthology.misc import read_config
read_config(ctx)

View File

@ -70,9 +70,10 @@ def lock_machines(ctx, config):
try:
yield
finally:
log.info('Unlocking machines...')
for machine in ctx.config['targets']:
lock.unlock(ctx, machine, ctx.owner)
if ctx.summary['success'] or not ctx.keep_locked_on_error:
log.info('Unlocking machines...')
for machine in ctx.config['targets']:
lock.unlock(ctx, machine, ctx.owner)
def check_lock(ctx, config):
log.info('Checking locks...')