summaryrefslogtreecommitdiffstats
path: root/tests/topotests/munet/__main__.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests/topotests/munet/__main__.py')
-rw-r--r--tests/topotests/munet/__main__.py63
1 files changed, 26 insertions, 37 deletions
diff --git a/tests/topotests/munet/__main__.py b/tests/topotests/munet/__main__.py
index 4419ab9..145eb26 100644
--- a/tests/topotests/munet/__main__.py
+++ b/tests/topotests/munet/__main__.py
@@ -16,8 +16,10 @@ import sys
from . import cli
from . import parser
+from .args import add_launch_args
from .base import get_event_loop
from .cleanup import cleanup_previous
+from .cleanup import is_running_in_rundir
from .compat import PytestConfig
@@ -106,66 +108,43 @@ def main(*args):
cap.add_argument(
"--project-root", help="directory to stop searching for kinds config at"
)
+
rap = ap.add_argument_group(title="Runtime", description="runtime related options")
+ add_launch_args(rap.add_argument)
+
+ # Move to munet.args?
rap.add_argument(
"-C",
"--cleanup",
action="store_true",
help="Remove the entire rundir (not just node subdirs) prior to running.",
)
- rap.add_argument(
- "--gdb", metavar="NODE-LIST", help="comma-sep list of hosts to run gdb on"
- )
- rap.add_argument(
- "--gdb-breakpoints",
- metavar="BREAKPOINT-LIST",
- help="comma-sep list of breakpoints to set",
- )
- rap.add_argument(
- "--host",
- action="store_true",
- help="no isolation for top namespace, bridges exposed to default namespace",
- )
- rap.add_argument(
- "--pcap",
- metavar="TARGET-LIST",
- help="comma-sep list of capture targets (NETWORK or NODE:IFNAME)",
- )
- rap.add_argument(
- "--shell", metavar="NODE-LIST", help="comma-sep list of nodes to open shells on"
- )
- rap.add_argument(
- "--stderr",
- metavar="NODE-LIST",
- help="comma-sep list of nodes to open windows viewing stderr",
- )
- rap.add_argument(
- "--stdout",
- metavar="NODE-LIST",
- help="comma-sep list of nodes to open windows viewing stdout",
- )
+ # Move to munet.args?
rap.add_argument(
"--topology-only",
action="store_true",
help="Do not run any node commands",
)
- rap.add_argument("--unshare-inline", action="store_true", help=argparse.SUPPRESS)
rap.add_argument(
"--validate-only",
action="store_true",
help="Validate the config against the schema definition",
)
+ rap.add_argument("--unshare-inline", action="store_true", help=argparse.SUPPRESS)
+
rap.add_argument("-v", "--verbose", action="store_true", help="be verbose")
rap.add_argument(
"-V", "--version", action="store_true", help="print the verison number and exit"
)
+
eap = ap.add_argument_group(title="Uncommon", description="uncommonly used options")
eap.add_argument("--log-config", help="logging config file (yaml, toml, json, ...)")
eap.add_argument(
- "--no-kill",
+ "--kill",
action="store_true",
- help="Do not kill previous running processes",
+ help="Kill previous running processes using same rundir and exit",
)
+ eap.add_argument("--no-kill", action="store_true", help=argparse.SUPPRESS)
eap.add_argument(
"--no-cli", action="store_true", help="Do not run the interactive CLI"
)
@@ -180,8 +159,18 @@ def main(*args):
sys.exit(0)
rundir = args.rundir if args.rundir else "/tmp/munet"
+ rundir = os.path.abspath(rundir)
args.rundir = rundir
+ if args.kill:
+ logging.info("Killing any previous run using rundir: {rundir}")
+ cleanup_previous(args.rundir)
+ elif is_running_in_rundir(args.rundir):
+ logging.fatal(
+ "Munet processes using rundir: %s, use `--kill` to cleanup first", rundir
+ )
+ return 1
+
if args.cleanup:
if os.path.exists(rundir):
if not os.path.exists(f"{rundir}/config.json"):
@@ -194,6 +183,9 @@ def main(*args):
else:
subprocess.run(["/usr/bin/rm", "-rf", rundir], check=True)
+ if args.kill:
+ return 0
+
subprocess.run(f"mkdir -p {rundir} && chmod 755 {rundir}", check=True, shell=True)
os.environ["MUNET_RUNDIR"] = rundir
@@ -208,9 +200,6 @@ def main(*args):
logger.critical("No nodes defined in config file")
return 1
- if not args.no_kill:
- cleanup_previous()
-
loop = None
status = 4
try: