def call_main(args): # Get output directory. try: if args.output_dir is not None: runtime.set_output_dir(args.output_dir) except ValueError as e: print str(e) raise # Set up logging. setup_logging(runtime.get_output_dir(), args.log_level, args.console_level) logger = logging.getLogger("zopkio") logger.info("Starting zopkio") try: utils.check_file_with_exception(args.testfile) utils.check_testfile_dir_structure(args.testfile) machines = utils.make_machine_mapping(args.machine_list) config_overrides = utils.parse_config_list(args.config_overrides) except ValueError as e: logger.error(str(e)) print("Error in processing command line arguments:\n {0}".format( traceback.format_exc())) raise runtime.set_machines(machines) if args.user is not None: user = args.user else: user = getpass.getuser() if args.nopassword: password = "" else: password = getpass.getpass() runtime.set_user(user, password) try: testmodule = utils.load_module(args.testfile) ztestsuites = [ getattr(testmodule, attr) for attr in dir(testmodule) if isinstance(getattr(testmodule, attr), ZTestSuite) ] if len( ztestsuites ) > 0: #TODO(jehrlich) intelligently handle multiple test suites test_runner = TestRunner(ztestsuite=ztestsuites[0], testlist=args.test_list, config_overrides=config_overrides) else: test_runner = TestRunner(args.testfile, args.test_list, config_overrides) except BaseException as e: print("Error setting up testrunner:\n%s" % traceback.format_exc()) raise ValueError(e.message) test_runner.run() logger.info("Exiting zopkio") return test_runner.success_count(), test_runner.fail_count()
def call_main(args): # Get output directory. try: if args.output_dir is not None: runtime.set_output_dir(args.output_dir) except ValueError as e: print str(e) raise # Set up logging. setup_logging(runtime.get_output_dir(), args.log_level, args.console_level) logger = logging.getLogger("zopkio") logger.info("Starting zopkio") try: utils.check_file_with_exception(args.testfile) utils.check_testfile_dir_structure(args.testfile) machines = utils.make_machine_mapping(args.machine_list) config_overrides = utils.parse_config_list(args.config_overrides) except ValueError as e: logger.error(str(e)) print("Error in processing command line arguments:\n {0}".format(traceback.format_exc())) raise runtime.set_machines(machines) if args.user is not None: user = args.user else: user = getpass.getuser() if args.nopassword: password = "" else: password = getpass.getpass() runtime.set_user(user, password) try: testmodule = utils.load_module(args.testfile) ztestsuites = [getattr(testmodule, attr) for attr in dir(testmodule) if isinstance(getattr(testmodule, attr), ZTestSuite)] if len(ztestsuites) > 0: #TODO(jehrlich) intelligently handle multiple test suites test_runner = TestRunner(ztestsuite=ztestsuites[0], testlist=args.test_list, config_overrides=config_overrides) else: test_runner = TestRunner(args.testfile, args.test_list, config_overrides) except BaseException as e: print("Error setting up testrunner:\n%s" % traceback.format_exc()) raise ValueError(e.message) test_runner.run() logger.info("Exiting zopkio") return test_runner.success_count(), test_runner.fail_count()
def _parse_input(testfile): """ Extract the dictionary from the input file """ ext = os.path.splitext(testfile)[-1].lower() if ext == ".py": test_dic = utils.load_module(testfile).test elif ext == ".json": json_data = open(testfile).read() test_dic = json.loads(json_data) else: logger.critical(testfile + " is not supported; currently only supports python and json files") raise ValueError("currently only supports python and json files") # checking test_dic to see if it has valid keys and values if not len(test_dic.keys()) == 4: logger.critical("input requires four fields: deployment_code, test_code, perf_code, configs_directory") raise ValueError("input requires four fields: deployment_code, test_code, perf_code, configs_directory") old_valid_key_list = ["deployment_code", "test_code", "perf_code", "configs_directory"] new_valid_key_list = ["deployment_code", "test_code", "dynamic_configuration_code", "configs_directory"] if not set(old_valid_key_list) == set(test_dic.keys()) and not set(new_valid_key_list) == set(test_dic.keys()): logger.critical("input requires four fields: deployment_code, test_code, dynamic_configuration_code, configs_directory") raise ValueError("input requires four fields: deployment_code, test_code, dynamic_configuration_code, configs_directory") filename = test_dic["deployment_code"] utils.check_file_with_exception(filename) filenames = test_dic["test_code"] for filename in filenames: utils.check_file_with_exception(filename) if "dynamic_configuration_code" in test_dic: filename = test_dic["dynamic_configuration_code"] else: filename = test_dic["perf_code"] utils.check_file_with_exception(filename) dirname = test_dic["configs_directory"] utils.check_dir_with_exception(dirname) return test_dic
def main(): """ Parse command line arguments and then run the test suite """ parser = argparse.ArgumentParser(description='A distributed test framework') parser.add_argument('testfile', help='The file that is used to determine the test suite run') parser.add_argument('--test-only', nargs='*', dest='test_list', help='run only the named tests to help debug broken tests') parser.add_argument('--machine-list', nargs='*', dest='machine_list', help='''mapping of logical host names to physical names allowing the same test suite to run on different hardware, each argument is a pair of logical name and physical name separated by a =''') parser.add_argument('--config-overrides', nargs='*', dest='config_overrides', help='''config overrides at execution time, each argument is a config with its value separated by a =. This has the highest priority of all configs''') parser.add_argument('-d', '--output-dir', dest='output_dir', help='''Directory to write output files and logs. Defaults to the current directory.''') parser.add_argument("--log-level", dest="log_level", help="Log level (default INFO)", default="INFO") parser.add_argument("--console-log-level", dest="console_level", help="Console Log level (default ERROR)", default="ERROR") parser.add_argument("--nopassword", action='store_true', dest="nopassword", help="Disable password prompt") parser.add_argument("--user", dest="user", help="user to run the test as (defaults to current user)") args = parser.parse_args() # Get output directory. try: if args.output_dir is not None: runtime.set_output_dir(args.output_dir) except ValueError as e: print str(e) sys.exit(1) # Set up logging. setup_logging(runtime.get_output_dir(), args.log_level, args.console_level) logger = logging.getLogger("zopkio") logger.info("Starting zopkio") try: utils.check_file_with_exception(args.testfile) utils.check_testfile_dir_structure(args.testfile) machines = utils.make_machine_mapping(args.machine_list) config_overrides = utils.parse_config_list(args.config_overrides) except ValueError as e: logger.error(str(e)) print("Error in processing command line arguments:\n {0}".format(traceback.format_exc())) sys.exit(1) runtime.set_machines(machines) if args.user is not None: user = args.user else: user = getpass.getuser() if args.nopassword: password = "" else: password = getpass.getpass() runtime.set_user(user, password) try: testmodule = utils.load_module(args.testfile) ztestsuites = [getattr(testmodule, attr) for attr in dir(testmodule) if isinstance(getattr(testmodule, attr), ZTestSuite)] if len(ztestsuites) > 0: #TODO(jehrlich) intelligently handle multiple test suites test_runner = TestRunner(ztestsuite=ztestsuites[0], testlist=args.test_list, config_overrides=config_overrides) else: test_runner = TestRunner(args.testfile, args.test_list, config_overrides) except BaseException as e: print("Error setting up testrunner:\n%s" % traceback.format_exc()) sys.exit(1) test_runner.run() logger.info("Exiting zopkio")
def main(): """ Parse command line arguments and then run the test suite """ parser = argparse.ArgumentParser( description='A distributed test framework') parser.add_argument( 'testfile', help='The file that is used to determine the test suite run') parser.add_argument( '--test-only', nargs='*', dest='test_list', help='run only the named tests to help debug broken tests') parser.add_argument( '--machine-list', nargs='*', dest='machine_list', help='''mapping of logical host names to physical names allowing the same test suite to run on different hardware, each argument is a pair of logical name and physical name separated by a =''') parser.add_argument( '--config-overrides', nargs='*', dest='config_overrides', help= '''config overrides at execution time, each argument is a config with its value separated by a =. This has the highest priority of all configs''') parser.add_argument( '-d', '--output-dir', dest='output_dir', help='''Directory to write output files and logs. Defaults to the current directory.''') parser.add_argument("--log-level", dest="log_level", help="Log level (default INFO)", default="INFO") parser.add_argument("--console-log-level", dest="console_level", help="Console Log level (default ERROR)", default="ERROR") parser.add_argument("--nopassword", action='store_true', dest="nopassword", help="Disable password prompt") args = parser.parse_args() # Get output directory. try: if args.output_dir is not None: runtime.set_output_dir(args.output_dir) except ValueError as e: print str(e) sys.exit(1) # Set up logging. runtime.set_init_time(time.time()) setup_logging(runtime.get_output_dir(), args.log_level, args.console_level) logger = logging.getLogger("zopkio") logger.info("Starting zopkio") try: utils.check_file_with_exception(args.testfile) machines = utils.make_machine_mapping(args.machine_list) config_overrides = utils.parse_config_list(args.config_overrides) except ValueError as e: print("Error in processing command line arguments:\n %s".format( traceback.format_exc())) sys.exit(1) runtime.set_machines(machines) user = getpass.getuser() if args.nopassword: password = "" else: password = getpass.getpass() runtime.set_user(user, password) try: test_runner = TestRunner(args.testfile, args.test_list, config_overrides) except BaseException as e: print("Error setting up testrunner:\n%s" % traceback.format_exc()) sys.exit(1) test_runner.run() logger.info("Exiting zopkio")
def main(): """ Parse command line arguments and then run the test suite """ parser = argparse.ArgumentParser(description='A distributed test framework') parser.add_argument('testfile', help='The file that is used to determine the test suite run') parser.add_argument('--test-only', nargs='*', dest='test_list', help='run only the named tests to help debug broken tests') parser.add_argument('--machine-list', nargs='*', dest='machine_list', help='''mapping of logical host names to physical names allowing the same test suite to run on different hardware, each argument is a pair of logical name and physical name separated by a =''') parser.add_argument('--config-overrides', nargs='*', dest='config_overrides', help='''config overrides at execution time, each argument is a config with its value separated by a =. This has the highest priority of all configs''') parser.add_argument('-d', '--output-dir', dest='output_dir', help='''Directory to write output files and logs. Defaults to the current directory.''') args = parser.parse_args() # Get output directory. try: if args.output_dir is not None: runtime.set_output_dir(args.output_dir) except ValueError as e: print str(e) sys.exit(1) # Set up logging. runtime.set_init_time(time.time()) setup_logging(runtime.get_output_dir()) logger = logging.getLogger("zopkio") logger.info("Starting zopkio") try: utils.check_file_with_exception(args.testfile) machines = utils.make_machine_mapping(args.machine_list) config_overrides = utils.parse_config_list(args.config_overrides) except ValueError as e: print("Error in processing command line arguments:\n %s" % traceback.format_exc()) sys.exit(1) runtime.set_machines(machines) user = getpass.getuser() password = getpass.getpass() runtime.set_user(user, password) try: test_runner = TestRunner(args.testfile, args.test_list, config_overrides) except BaseException as e: print("Error setting up testrunner:\n%s" % traceback.format_exc()) sys.exit(1) test_runner.run() logger.info("Exiting zopkio")
def main(): """ Parse command line arguments and then run the test suite """ parser = argparse.ArgumentParser( description='A distributed test framework') parser.add_argument( 'testfile', help='The file that is used to determine the test suite run') parser.add_argument( '--test-only', nargs='*', dest='test_list', help='run only the named tests to help debug broken tests') parser.add_argument( '--machine-list', nargs='*', dest='machine_list', help='''mapping of logical host names to physical names allowing the same test suite to run on different hardware, each argument is a pair of logical name and physical name separated by a =''') parser.add_argument( '--config-overrides', nargs='*', dest='config_overrides', help= '''config overrides at execution time, each argument is a config with its value separated by a =. This has the highest priority of all configs''') parser.add_argument( '-d', '--output-dir', dest='output_dir', help='''Directory to write output files and logs. Defaults to the current directory.''') parser.add_argument("--log-level", dest="log_level", help="Log level (default INFO)", default="INFO") parser.add_argument("--console-log-level", dest="console_level", help="Console Log level (default ERROR)", default="ERROR") parser.add_argument("--nopassword", action='store_true', dest="nopassword", help="Disable password prompt") parser.add_argument( "--user", dest="user", help="user to run the test as (defaults to current user)") parser.add_argument( "--reporter", dest="reporter", help="reporter type that will be use to generate report)") args = parser.parse_args() # Get output directory. try: if args.output_dir is not None: runtime.set_output_dir(args.output_dir) except ValueError as e: print str(e) sys.exit(1) # Set up logging. setup_logging(runtime.get_output_dir(), args.log_level, args.console_level) logger = logging.getLogger("zopkio") logger.info("Starting zopkio") try: utils.check_file_with_exception(args.testfile) utils.check_testfile_dir_structure(args.testfile) machines = utils.make_machine_mapping(args.machine_list) config_overrides = utils.parse_config_list(args.config_overrides) except ValueError as e: logger.error(str(e)) print("Error in processing command line arguments:\n {0}".format( traceback.format_exc())) sys.exit(1) runtime.set_machines(machines) if args.user is not None: user = args.user else: user = getpass.getuser() if args.nopassword: password = "" else: password = getpass.getpass() runtime.set_user(user, password) try: testmodule = utils.load_module(args.testfile) ztestsuites = [ getattr(testmodule, attr) for attr in dir(testmodule) if isinstance(getattr(testmodule, attr), ZTestSuite) ] # reporter_type = runtime.get_active_config('zopkio_reporter') reporter_type = None if args.reporter is not None: reporter_type = args.reporter if len( ztestsuites ) > 0: #TODO(jehrlich) intelligently handle multiple test suites test_runner = TestRunner(ztestsuite=ztestsuites[0], testlist=args.test_list, config_overrides=config_overrides, reporter_type=reporter_type) else: test_runner = TestRunner(args.testfile, args.test_list, config_overrides, reporter_type=reporter_type) except BaseException as e: print("Error setting up testrunner:\n%s" % traceback.format_exc()) sys.exit(1) print "CONFIG_OVERRIDE: %s" % (config_overrides, ) test_runner.run() logger.info("Exiting zopkio")