ceph/teuthology/task/tasktest.py
Zack Cerza 8497437003 Remove unused imports
(cherry picked from commit 586817481119c4fc4a39f8804e7871a43491e01f)
2013-09-26 14:01:37 -05:00

47 lines
1.3 KiB
Python

import logging
import contextlib
import time
log = logging.getLogger(__name__)
@contextlib.contextmanager
def task(ctx, config):
"""
Task that just displays information when it is create and when it is
destroyed/cleaned up. This task was used to test parallel and
sequential task options.
example:
tasks:
- sequential:
- tasktest:
- id: 'foo'
- tasktest:
- id: 'bar'
- delay:5
- tasktest:
The above yaml will sequentially start a test task named foo and a test
task named bar. Bar will take 5 seconds to complete. After foo and bar
have finished, an unidentified tasktest task will run.
"""
try:
delay = config.get('delay', 0)
id = config.get('id', 'UNKNOWN')
except AttributeError:
delay = 0
id = 'UNKNOWN'
try:
log.info('**************************************************')
log.info('Started task test -- %s' % id)
log.info('**************************************************')
time.sleep(delay)
yield
finally:
log.info('**************************************************')
log.info('Task test is being cleaned up -- %s' % id)
log.info('**************************************************')