introduce "cmdeploy bench"

This commit is contained in:
holger krekel 2023-12-10 12:10:36 +01:00
parent d730af2e69
commit a6d24b3af7
2 changed files with 20 additions and 11 deletions

View File

@ -72,8 +72,8 @@ def get_parser():
help="fully qualified DNS domain name for your chatmail instance", help="fully qualified DNS domain name for your chatmail instance",
) )
install_parser = add_subcommand(subparsers, run_cmd) run_parser = add_subcommand(subparsers, run_cmd)
install_parser.add_argument( run_parser.add_argument(
"--dry-run", "--dry-run",
dest="dry_run", dest="dry_run",
action="store_true", action="store_true",
@ -84,6 +84,8 @@ def get_parser():
add_subcommand(subparsers, test_cmd) add_subcommand(subparsers, test_cmd)
add_subcommand(subparsers, bench_cmd)
add_subcommand(subparsers, dns_cmd) add_subcommand(subparsers, dns_cmd)
return parser return parser
@ -133,6 +135,13 @@ def test_cmd(args, out, config):
) )
def bench_cmd(args, out, config):
"""Run benchmarks against an online chatmail instance."""
pytest_path = shutil.which("pytest")
benchmark = "tests/online/benchmark.py"
subprocess.check_call([pytest_path, benchmark, "-vrx"])
def read_dkim_entries(entry): def read_dkim_entries(entry):
lines = [] lines = []
for line in entry.split("\n"): for line in entry.split("\n"):
@ -179,18 +188,22 @@ def main(args=None):
if not hasattr(args, "func"): if not hasattr(args, "func"):
return parser.parse_args(["-h"]) return parser.parse_args(["-h"])
out = Out() out = Out()
kwargs = {}
if args.func.__name__ != "init_cmd": if args.func.__name__ != "init_cmd":
if not args.inipath.exists(): if not args.inipath.exists():
out.red(f"expecting {args.inipath} to exist, run init first?") out.red(f"expecting {args.inipath} to exist, run init first?")
raise SystemExit(1) raise SystemExit(1)
try: try:
config = read_config(args.inipath) kwargs["config"] = read_config(args.inipath)
except Exception as ex: except Exception as ex:
out.red(ex) out.red(ex)
raise SystemExit(2) raise SystemExit(1)
args.func(args, out, config)
else: try:
args.func(args, out) args.func(args, out, **kwargs)
except KeyboardInterrupt:
out.red("KeyboardInterrupt")
sys.exit(130)
if __name__ == "__main__": if __name__ == "__main__":

View File

@ -1,4 +0,0 @@
#!/bin/bash
set -e
venv/bin/pytest tests/online/benchmark.py -vrx