def main(): """Ducktape entry point. This contains top level logic for ducktape command-line program which does the following: Discover tests Initialize cluster for distributed services Run tests Report a summary of all results """ args = parse_args() # Make .ducktape directory where metadata such as the last used session_id is stored if not os.path.isdir(ConsoleConfig.METADATA_DIR): os.makedirs(ConsoleConfig.METADATA_DIR) # Generate a shared 'global' identifier for this test run and create the directory # in which all test results will be stored session_id = generate_session_id(ConsoleConfig.SESSION_ID_FILE) results_dir = generate_results_dir(session_id) setup_results_directory(results_dir, session_id) session_context = SessionContext(session_id, results_dir, cluster=None, args=args) # Discover and load tests to be run extend_import_paths(args.test_path) loader = TestLoader(session_context) try: test_classes = loader.discover(args.test_path) except LoaderException as e: print "Failed while trying to discover tests: {}".format(e) sys.exit(1) if args.collect_only: print test_classes sys.exit(0) # Initializing the cluster is slow, so do so only if # tests are sure to be run session_context.cluster = VagrantCluster() # Run the tests runner = SerialTestRunner(session_context, test_classes) test_results = runner.run_all_tests() # Report results # TODO command-line hook for type of reporter reporter = SimpleStdoutReporter(test_results) reporter.report() reporter = SimpleFileReporter(test_results) reporter.report() # Generate HTML reporter reporter = HTMLReporter(test_results) reporter.report() if not test_results.get_aggregate_success(): sys.exit(1)
def main(): """Ducktape entry point. This contains top level logic for ducktape command-line program which does the following: Discover tests Initialize cluster for distributed services Run tests Report a summary of all results """ args_dict = parse_args(sys.argv[1:]) parameters = None if args_dict["parameters"]: try: parameters = json.loads(args_dict["parameters"]) except ValueError as e: print "parameters are not valid json: " + str(e.message) sys.exit(1) args_dict["globals"] = get_user_defined_globals(args_dict.get("globals")) # Make .ducktape directory where metadata such as the last used session_id is stored if not os.path.isdir(ConsoleDefaults.METADATA_DIR): os.makedirs(ConsoleDefaults.METADATA_DIR) # Generate a shared 'global' identifier for this test run and create the directory # in which all test results will be stored session_id = generate_session_id(ConsoleDefaults.SESSION_ID_FILE) results_dir = generate_results_dir(args_dict["results_root"], session_id) setup_results_directory(results_dir) session_context = SessionContext(session_id=session_id, results_dir=results_dir, **args_dict) for k, v in args_dict.iteritems(): session_context.logger.debug("Configuration: %s=%s", k, v) # Discover and load tests to be run extend_import_paths(args_dict["test_path"]) loader = TestLoader(session_context, parameters) try: tests = loader.discover(args_dict["test_path"]) except LoaderException as e: print "Failed while trying to discover tests: {}".format(e) sys.exit(1) if args_dict["collect_only"]: print "Collected %d tests:" % len(tests) for test in tests: print " " + str(test) sys.exit(0) # Initializing the cluster is slow, so do so only if # tests are sure to be run try: (cluster_mod_name, cluster_class_name) = args_dict["cluster"].rsplit('.', 1) cluster_mod = importlib.import_module(cluster_mod_name) cluster_class = getattr(cluster_mod, cluster_class_name) session_context.cluster = cluster_class(cluster_file=args_dict["cluster_file"]) except: print "Failed to load cluster: ", str(sys.exc_info()[0]) print traceback.format_exc(limit=16) sys.exit(1) # Run the tests runner = SerialTestRunner(session_context, tests) test_results = runner.run_all_tests() # Report results reporter = SimpleStdoutSummaryReporter(test_results) reporter.report() reporter = SimpleFileSummaryReporter(test_results) reporter.report() # Generate HTML reporter reporter = HTMLSummaryReporter(test_results) reporter.report() update_latest_symlink(args_dict["results_root"], results_dir) if not test_results.get_aggregate_success(): sys.exit(1)
def main(): """Ducktape entry point. This contains top level logic for ducktape command-line program which does the following: Discover tests Initialize cluster for distributed services Run tests Report a summary of all results """ args = parse_args() if args.version: print ducktape_version() sys.exit(0) # Make .ducktape directory where metadata such as the last used session_id is stored if not os.path.isdir(ConsoleConfig.METADATA_DIR): os.makedirs(ConsoleConfig.METADATA_DIR) # Generate a shared 'global' identifier for this test run and create the directory # in which all test results will be stored session_id = generate_session_id(ConsoleConfig.SESSION_ID_FILE) results_dir = generate_results_dir(args.results_root, session_id) setup_results_directory(args.results_root, results_dir) session_context = SessionContext(session_id, results_dir, cluster=None, args=args) for k, v in vars(args).iteritems(): session_context.logger.debug("Configuration: %s=%s", k, v) # Discover and load tests to be run extend_import_paths(args.test_path) loader = TestLoader(session_context) try: tests = loader.discover(args.test_path) except LoaderException as e: print "Failed while trying to discover tests: {}".format(e) sys.exit(1) if args.collect_only: print "Collected %d tests:" % len(tests) for test in tests: print " " + str(test) sys.exit(0) # Initializing the cluster is slow, so do so only if # tests are sure to be run try: (cluster_mod_name, cluster_class_name) = args.cluster.rsplit('.', 1) cluster_mod = importlib.import_module(cluster_mod_name) cluster_class = getattr(cluster_mod, cluster_class_name) session_context.cluster = cluster_class() except: print "Failed to load cluster: ", str(sys.exc_info()[0]) print traceback.format_exc(limit=16) sys.exit(1) # Run the tests runner = SerialTestRunner(session_context, tests) test_results = runner.run_all_tests() # Report results # TODO command-line hook for type of reporter reporter = SimpleStdoutSummaryReporter(test_results) reporter.report() reporter = SimpleFileSummaryReporter(test_results) reporter.report() # Generate HTML reporter reporter = HTMLSummaryReporter(test_results) reporter.report() if not test_results.get_aggregate_success(): sys.exit(1)
def main(): """Ducktape entry point. This contains top level logic for ducktape command-line program which does the following: Discover tests Initialize cluster for distributed services Run tests Report a summary of all results """ args_dict = parse_args(sys.argv[1:]) parameters = None if args_dict["parameters"]: try: parameters = json.loads(args_dict["parameters"]) except ValueError as e: print "parameters are not valid json: " + str(e.message) sys.exit(1) args_dict["globals"] = get_user_defined_globals(args_dict.get("globals")) # Make .ducktape directory where metadata such as the last used session_id is stored if not os.path.isdir(ConsoleDefaults.METADATA_DIR): os.makedirs(ConsoleDefaults.METADATA_DIR) # Generate a shared 'global' identifier for this test run and create the directory # in which all test results will be stored session_id = generate_session_id(ConsoleDefaults.SESSION_ID_FILE) results_dir = generate_results_dir(args_dict["results_root"], session_id) setup_results_directory(results_dir) session_context = SessionContext(session_id=session_id, results_dir=results_dir, **args_dict) for k, v in args_dict.iteritems(): session_context.logger.debug("Configuration: %s=%s", k, v) # Discover and load tests to be run extend_import_paths(args_dict["test_path"]) loader = TestLoader(session_context, parameters) try: tests = loader.discover(args_dict["test_path"]) except LoaderException as e: print "Failed while trying to discover tests: {}".format(e) sys.exit(1) if args_dict["collect_only"]: print "Collected %d tests:" % len(tests) for test in tests: print " " + str(test) sys.exit(0) # Initializing the cluster is slow, so do so only if # tests are sure to be run try: (cluster_mod_name, cluster_class_name) = args_dict["cluster"].rsplit('.', 1) cluster_mod = importlib.import_module(cluster_mod_name) cluster_class = getattr(cluster_mod, cluster_class_name) session_context.cluster = cluster_class( cluster_file=args_dict["cluster_file"]) except: print "Failed to load cluster: ", str(sys.exc_info()[0]) print traceback.format_exc(limit=16) sys.exit(1) # Run the tests runner = SerialTestRunner(session_context, tests) test_results = runner.run_all_tests() # Report results reporter = SimpleStdoutSummaryReporter(test_results) reporter.report() reporter = SimpleFileSummaryReporter(test_results) reporter.report() # Generate HTML reporter reporter = HTMLSummaryReporter(test_results) reporter.report() update_latest_symlink(args_dict["results_root"], results_dir) if not test_results.get_aggregate_success(): sys.exit(1)