def main_locust(): """ Performance test with locust: parse command line options and run commands. """ logger.setup_logger("INFO") sys.argv[0] = 'locust' if len(sys.argv) == 1: sys.argv.extend(["-h"]) if sys.argv[1] in ["-h", "--help", "-V", "--version"]: locusts.main() sys.exit(0) try: testcase_index = sys.argv.index('-f') + 1 assert testcase_index < len(sys.argv) except (ValueError, AssertionError): logger.log_error("Testcase file is not specified, exit.") sys.exit(1) testcase_file_path = sys.argv[testcase_index] sys.argv[testcase_index] = locusts.parse_locustfile(testcase_file_path) if "--processes" in sys.argv: """ locusts -f locustfile.py --processes 4 """ if "--no-web" in sys.argv: logger.log_error( "conflict parameter args: --processes & --no-web. \nexit.") sys.exit(1) processes_index = sys.argv.index('--processes') processes_count_index = processes_index + 1 if processes_count_index >= len(sys.argv): """ do not specify processes count explicitly locusts -f locustfile.py --processes """ processes_count = multiprocessing.cpu_count() logger.log_warning( "processes count not specified, use {} by default.".format( processes_count)) else: try: """ locusts -f locustfile.py --processes 4 """ processes_count = int(sys.argv[processes_count_index]) sys.argv.pop(processes_count_index) except ValueError: """ locusts -f locustfile.py --processes -P 8888 """ processes_count = multiprocessing.cpu_count() logger.log_warning( "processes count not specified, use {} by default.".format( processes_count)) sys.argv.pop(processes_index) locusts.run_locusts_with_processes(sys.argv, processes_count) else: locusts.main()
def remote_main_run(): parser = argparse.ArgumentParser( description="Tools for web ui test. Base on rtsf.") parser.add_argument('case_file', help="yaml testcase file") parser.add_argument('--log-level', default='INFO', help="Specify logging level, default is INFO.") parser.add_argument('--log-file', help="Write logs to specified file path.") parser.add_argument('--package', help="app package name under test.") parser.add_argument('--activity', help="app activity name.") parser.add_argument('--apk', help="apk file path.") parser.add_argument( '--aapt', default='aapt', help= "set the `aapt` path if ANDROID_HOME not configured. default: aapt ") parser.add_argument('--ip', default="localhost", help="remote hub ip. default: localhost") parser.add_argument('--port', type=int, default=4444, help="remote hub port. default: 4444") color_print("appuidriver {}".format(__version__), "GREEN") args = parser.parse_args() logger.setup_logger(args.log_level, args.log_file) result1 = True if args.apk else False result2 = True if args.package and args.activity else False if result1 or result2: RemoteDriver._apk_abs_path = args.apk RemoteDriver._app_package = args.package RemoteDriver._app_activity = args.activity RemoteDriver._aapt_exe_path = args.aapt RemoteDriver._remote_ip = args.ip RemoteDriver._remote_port = args.port runner = TestRunner(runner=RemoteDriver).run(args.case_file) html_report = runner.gen_html_report() color_print("report: {}".format(html_report)) else: print("The parameter must include either an apk or package&activity.") return
def remote_main_run(): parser = argparse.ArgumentParser(description="Tools for web ui test. Base on rtsf.") parser.add_argument( '--log-level', default='INFO', help="Specify logging level, default is INFO.") parser.add_argument( '--log-file', help="Write logs to specified file path.") parser.add_argument( '--browser', default="chrome", help="set browser, only chrome or firefox. default: chrome") parser.add_argument( '--download-path',default=None, help="set the path where to save download file from browser. default: None") parser.add_argument( '--marionette', action='store_true', default=False, help="use firefox driver `geckodriver.exe` if True. default: False") parser.add_argument( '--ip', default="localhost", help="remote hub ip. default: localhost") parser.add_argument( '--port', type=int, default=4444, help="remote hub port. default: 4444") parser.add_argument( 'case_file', help="yaml testcase file") color_print("webuidriver {}".format(__version__), "GREEN") args = parser.parse_args() logger.setup_logger(args.log_level, args.log_file) RemoteDriver._browser = args.browser RemoteDriver._download_path = args.download_path RemoteDriver._marionette = args.marionette RemoteDriver._remote_ip = args.ip RemoteDriver._remote_port = args.port runner = TestRunner(runner = RemoteDriver).run(args.case_file) html_report = runner.gen_html_report() color_print("report: {}".format(html_report))
def main_hrun(): """ parse command line options and run commands.""" parser = argparse.ArgumentParser( description="Tools for http(s) test. Base on rtsf.") parser.add_argument('--log-level', default='INFO', help="Specify logging level, default is INFO.") parser.add_argument('--log-file', help="Write logs to specified file path.") parser.add_argument('case_file', help="yaml testcase file") color_print("httpdriver {}".format(__version__), "GREEN") args = parser.parse_args() logger.setup_logger(args.log_level, args.log_file) runner = TestRunner(runner=HttpDriver).run(args.case_file) html_report = runner.gen_html_report() color_print("report: {}".format(html_report))