diff --git a/bobber/bobber.py b/bobber/bobber.py index 38ef00a..0d2fdbf 100644 --- a/bobber/bobber.py +++ b/bobber/bobber.py @@ -31,6 +31,41 @@ from typing import NoReturn +def test_qty_validation(test_qty: str) -> str: + """ + Verify all test quantity values are positive integers. + + Parameters + ---------- + test_qty : str + A ``string`` of the comma-separated test quantities from the user, + such as '1,2,3,...' + + Returns + ------- + str + Returns a ``string`` of the original test quantities list if all + test quantities are positive integers. + + Raises + ------ + ArgumentTypeError + Raises an ``ArgumentTypeError`` if any of the passed test quantities + are non-integers or negative intergers. + """ + test_qty_list = test_qty.split(',') + conversion_test_list = [] + for value in test_qty_list: + try: + conversion_test_list.append(int(value)) + except ValueError: + raise ArgumentTypeError('Test quantity element invalid') + + if int(value) <= 0: + raise ArgumentTypeError('Test quantity element is not positive') + return test_qty + + def unique_hosts(hosts: str) -> str: """ Verify all hosts are unique. @@ -158,6 +193,18 @@ def parse_args(version: str) -> Namespace: 'of a single system (so, 3 systems specified ' 'would result in tests for 1, 2, and 3 ' 'systems)', action='store_true') + commands_parent.add_argument('--test-qty', help='Comma-separated list of ' + 'host counts to test. For example, for a ' + 'list of 10 hosts specified via thse hosts ' + 'flag, to test only multiples of two, this ' + 'flag value should be 2,4,6,8,10. Note that ' + '--sweep should also be present, otherwise ' + 'only the maximum number of systems ' + 'specified by --hosts will be tested. If ' + 'this flag is unspecified, all node counts ' + 'from 1 to the maximum number of systems ' + 'specified by --hosts will be tested', + type=test_qty_validation) commands_parent.add_argument('--system', help='If system is specified, ' 'iops-threads, 125k-threads, bw-threads, ' 'gpus, batch size, and network interface ' diff --git a/bobber/lib/tests/run_tests.py b/bobber/lib/tests/run_tests.py index 992443b..c47c46f 100644 --- a/bobber/lib/tests/run_tests.py +++ b/bobber/lib/tests/run_tests.py @@ -340,12 +340,16 @@ def test_selector(args: Namespace, bobber_version: str) -> NoReturn: """ if args.sweep: hosts = [] + host_qtys_to_test = None + if args.test_qty: + host_qtys_to_test = args.test_qty.split(",") for host in args.hosts.split(','): hosts.append(host) - for iteration in range(1, args.iterations + 1): - host_string = ','.join(hosts) - kickoff_test(args, bobber_version, iteration, host_string) + if host_qtys_to_test is None or len(hosts) in host_qtys_to_test: + for iteration in range(1, args.iterations + 1): + host_string = ','.join(hosts) + kickoff_test(args, bobber_version, iteration, host_string) else: for iteration in range(1, args.iterations + 1): kickoff_test(args, bobber_version, iteration, args.hosts)