mirror of
https://github.com/httprunner/httprunner.git
synced 2026-06-06 08:19:45 +08:00
change: add argument to specify yaml/json testcase file for locusts
This commit is contained in:
@@ -16,6 +16,8 @@ def init_parser_locusts(subparsers):
|
|||||||
sub_parser_locusts.add_argument(
|
sub_parser_locusts.add_argument(
|
||||||
'--locust-help', action='store_true', default=False,
|
'--locust-help', action='store_true', default=False,
|
||||||
help="Show locust help.")
|
help="Show locust help.")
|
||||||
|
sub_parser_locusts.add_argument('test_file', nargs='?',
|
||||||
|
help="Specify YAML/JSON testcase file.")
|
||||||
sub_parser_locusts.add_argument(
|
sub_parser_locusts.add_argument(
|
||||||
"--master", action='store_true', default=False, help="Start locust master.")
|
"--master", action='store_true', default=False, help="Start locust master.")
|
||||||
sub_parser_locusts.add_argument(
|
sub_parser_locusts.add_argument(
|
||||||
@@ -57,16 +59,14 @@ def main_locusts(args, extra_args):
|
|||||||
logger.remove()
|
logger.remove()
|
||||||
logger.add(sys.stdout, level=loglevel)
|
logger.add(sys.stdout, level=loglevel)
|
||||||
|
|
||||||
# convert httprunner yaml/json case to locustfile.py
|
if not args.test_file:
|
||||||
try:
|
logger.error("Testcase file is not specified, exit.")
|
||||||
testcase_index = get_arg_index("-f", "--locustfile")
|
|
||||||
assert testcase_index and testcase_index < len(sys.argv)
|
|
||||||
testcase_file_path = sys.argv[testcase_index]
|
|
||||||
sys.argv[testcase_index] = parse_locustfile(testcase_file_path)
|
|
||||||
except AssertionError:
|
|
||||||
print("Testcase file is not specified, exit.")
|
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
|
# convert httprunner yaml/json case to locustfile.py
|
||||||
|
locustfile_path = parse_locustfile(args.test_file)
|
||||||
|
sys.argv.extend(["-f", locustfile_path])
|
||||||
|
|
||||||
manager = multiprocessing.Manager()
|
manager = multiprocessing.Manager()
|
||||||
try:
|
try:
|
||||||
if args.quickstart:
|
if args.quickstart:
|
||||||
|
|||||||
Reference in New Issue
Block a user