From: Patrick Donnelly Date: Wed, 26 Mar 2025 01:53:08 +0000 (-0400) Subject: qa: add sequential_yield task X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=80836eed118dfa83d34585f227060bb488729e43;p=ceph-ci.git qa: add sequential_yield task This is identical to the sequential task except it yields after entering each sub-task. Signed-off-by: Patrick Donnelly --- diff --git a/qa/tasks/sequential_yield.py b/qa/tasks/sequential_yield.py new file mode 100644 index 00000000000..bc963c704dc --- /dev/null +++ b/qa/tasks/sequential_yield.py @@ -0,0 +1,61 @@ +""" +Task sequencer +""" +import contextlib +import sys +import logging + +from teuthology import run_tasks + +log = logging.getLogger(__name__) + + +@contextlib.contextmanager +def task(ctx, config): + """ + Sequentialize a group of tasks into one executable block + + example:: + + - sequential: + - tasktest: + - tasktest: + + You can also reference the job from elsewhere:: + + foo: + tasktest: + tasks: + - sequential: + - tasktest: + - foo + - tasktest: + + That is, if the entry is not a dict, we will look it up in the top-level + config. + + Sequential tasks and Parallel tasks can be nested. + + :param ctx: Context + :param config: Configuration + """ + stack = [] + try: + for entry in config: + if not isinstance(entry, dict): + entry = ctx.config.get(entry, {}) + ((taskname, confg),) = entry.items() + log.info('In sequential, running task %s...' % taskname) + mgr = run_tasks.run_one_task(taskname, ctx=ctx, config=confg) + if hasattr(mgr, '__enter__'): + mgr.__enter__() + stack.append(mgr) + yield # !! + finally: + try: + exc_info = sys.exc_info() + while stack: + mgr = stack.pop() + mgr.__exit__(*exc_info) + finally: + del exc_info