diff --git a/docs/changelog.rst b/docs/changelog.rst index a6908741..dde53b23 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -26,6 +26,7 @@ In progress (unreleased) * :gh:issue:`1423` tests: Group and unify naming of connection benchmarks * :gh:issue:`1424` tests: Parameterize connection benchmarks * :gh:issue:`1424` tests: Standardise output of connection benchmarks +* :gh:issue:`1424` tests: Parameterize throughput benchmark v0.3.37 (2026-01-08) diff --git a/tests/bench/throughput.py b/tests/bench/throughput.py index 7d67d158..d5019c95 100644 --- a/tests/bench/throughput.py +++ b/tests/bench/throughput.py @@ -1,5 +1,8 @@ -# Verify throughput over sudo and SSH at various compression levels. +''' +Measure file service throughput over local, sudo, and (un)compressed SSH. +''' +import getpass import os import tempfile @@ -43,6 +46,23 @@ def run_test(router, fp, s, context): @mitogen.main() def main(router): + import optparse + parser = optparse.OptionParser(description=__doc__) + + parser.add_option( + '--ssh-python', metavar='CMD', default='python3', + help='Remote python path (default %default)') + parser.add_option( + '--ssh-user', metavar='S', default=getpass.getuser(), + help='Remote username (default %default)') + + parser.add_option( + '--sudo-user', metavar='S', default='root', + help='Sudo username (default %default)') + + parser.add_option('--debug', action='store_true') + opts, args = parser.parse_args() + ansible_mitogen.affinity.policy.assign_muxprocess() bigfile = tempfile.NamedTemporaryFile() @@ -53,19 +73,29 @@ def main(router): file_service.register(bigfile.name) pool.add(file_service) try: - context = router.local() + context = router.local(debug=opts.debug) run_test(router, bigfile, 'local()', context) context.shutdown(wait=True) - context = router.sudo() + context = router.sudo(username=opts.sudo_user, debug=opts.debug) run_test(router, bigfile, 'sudo()', context) context.shutdown(wait=True) - context = router.ssh(hostname='localhost', compression=False) + context = router.ssh( + hostname=args[0], + python_path=opts.ssh_python, + username=opts.ssh_user, + compression=False, debug=opts.debug, + ) run_test(router, bigfile, 'ssh(compression=False)', context) context.shutdown(wait=True) - context = router.ssh(hostname='localhost', compression=True) + context = router.ssh( + hostname=args[0], + python_path=opts.ssh_python, + username=opts.ssh_user, + compression=True, debug=opts.debug, + ) run_test(router, bigfile, 'ssh(compression=True)', context) context.shutdown(wait=True) finally: