Skip to content

Commit

Permalink
tests: update munet 0.14.13
Browse files Browse the repository at this point in the history
- Improve remote CLI operation [improves xdist mode]

Signed-off-by: Christian Hopps <[email protected]>
  • Loading branch information
choppsv1 committed Sep 14, 2024
1 parent bac68ab commit 45e42c1
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion tests/topotests/munet/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -756,6 +756,8 @@ async def remote_cli(unet, prompt, title, background):
unet.cli_sockpath = sockpath
logging.info("server created on :\n%s\n", sockpath)

wait_tmux = bool(os.getenv("TMUX", "")) and not sys.stdin.isatty()

# Open a new window with a new CLI
python_path = await unet.async_get_exec_path(["python3", "python"])
us = os.path.realpath(__file__)
Expand All @@ -765,7 +767,25 @@ async def remote_cli(unet, prompt, title, background):
if prompt:
cmd += f" --prompt='{prompt}'"
cmd += " " + unet.cli_sockpath
unet.run_in_window(cmd, title=title, background=False)

channel = None
if wait_tmux:
from .base import Commander # pylint: disable=import-outside-toplevel

channel = "{}-{}".format(os.getpid(), Commander.tmux_wait_gen)
logger.info("XXX channel is %s", channel)
# If we don't have a tty to pause on pause for tmux windows to exit
if channel is not None:
Commander.tmux_wait_gen += 1

unet.run_in_window(cmd, title=title, background=False, wait_for=channel)

if wait_tmux and channel:
from .base import commander # pylint: disable=import-outside-toplevel

await commander.async_cmd_raises(
[commander.get_exec_path("tmux"), "wait", channel]
)
except Exception as error:
logging.error("cli server: unexpected exception: %s", error)

Expand Down

0 comments on commit 45e42c1

Please sign in to comment.