def run_distributed(options, module_name, class_name, method_name, sys_args): ret = None from funkload.Distributed import DistributionMgr global _manager try: distmgr = DistributionMgr( module_name, class_name, method_name, options, sys_args) _manager = distmgr except UserWarning as error: trace(red_str("Distribution failed with:%s \n" % (error))) return 1 try: try: distmgr.prepare_workers(allow_errors=True) ret = distmgr.run() distmgr.final_collect() except KeyboardInterrupt: trace("* ^C received *") finally: # in any case we want to stop the workers at the end distmgr.abort() _manager = None return ret
def run_distributed(options, module_name, class_name, method_name, sys_args): ret = None from funkload.Distributed import DistributionMgr global _manager try: distmgr = DistributionMgr(module_name, class_name, method_name, options, sys_args) _manager = distmgr except UserWarning, error: trace(red_str("Distribution failed with:%s \n" % (error))) return 1
def main(args=sys.argv[1:]): """Default main.""" # enable to load module in the current path cur_path = os.path.abspath(os.path.curdir) sys.path.insert(0, cur_path) parser = OptionParser(USAGE, formatter=TitledHelpFormatter(), version="FunkLoad %s" % get_version()) parser.add_option("", "--config", type="string", dest="config", metavar='CONFIG', help="Path to alternative config file") parser.add_option("-u", "--url", type="string", dest="main_url", help="Base URL to bench.") parser.add_option("-c", "--cycles", type="string", dest="bench_cycles", help="Cycles to bench, colon-separated list of " "virtual concurrent users. To run a bench with 3 " "cycles of 5, 10 and 20 users, use: -c 5:10:20") parser.add_option("-D", "--duration", type="string", dest="bench_duration", help="Duration of a cycle in seconds.") parser.add_option("-m", "--sleep-time-min", type="string", dest="bench_sleep_time_min", help="Minimum sleep time between requests.") parser.add_option("-M", "--sleep-time-max", type="string", dest="bench_sleep_time_max", help="Maximum sleep time between requests.") parser.add_option("-t", "--test-sleep-time", type="string", dest="bench_sleep_time", help="Sleep time between tests.") parser.add_option("-s", "--startup-delay", type="string", dest="bench_startup_delay", help="Startup delay between thread.") parser.add_option("-f", "--as-fast-as-possible", action="store_true", help="Remove sleep times between requests and between " "tests, shortcut for -m0 -M0 -t0") parser.add_option("-r", "--runner-class", type="string", dest="bench_runner_class", default="funkload.BenchRunner.BenchRunner", help="Python dotted import path to BenchRunner class to use.") parser.add_option("", "--no-color", action="store_true", help="Monochrome output.") parser.add_option("", "--accept-invalid-links", action="store_true", help="Do not fail if css/image links are not reachable.") parser.add_option("", "--simple-fetch", action="store_true", dest="bench_simple_fetch", help="Don't load additional links like css or images " "when fetching an html page.") parser.add_option("-l", "--label", type="string", help="Add a label to this bench run for easier " "identification (it will be appended to the " "directory name for reports generated from it).") parser.add_option("--enable-debug-server", action="store_true", dest="debugserver", help="Instantiates a debug HTTP server which exposes an " "interface using which parameters can be modified " "at run-time. Currently supported parameters: " "/cvu?inc=<integer> to increase the number of " "CVUs, /cvu?dec=<integer> to decrease the number " "of CVUs, /getcvu returns number of CVUs ") parser.add_option("--debug-server-port", type="string", dest="debugport", help="Port at which debug server should run during the " "test") parser.add_option("--distribute", action="store_true", dest="distribute", help="Distributes the CVUs over a group of worker " "machines that are defined in the workers section") parser.add_option("--distribute-workers", type="string", dest="workerlist", help="This parameter will over-ride the list of " "workers defined in the config file. expected " "notation is uname@host,uname:pwd@host or just " "host...") parser.add_option("--distribute-python", type="string", dest="python_bin", help="When running in distributed mode, this Python " "binary will be used across all hosts.") parser.add_option("--is-distributed", action="store_true", dest="is_distributed", help="This parameter is for internal use only. it " "signals to a worker node that it is in " "distributed mode and shouldn't perform certain " "actions.") parser.add_option("--distributed-packages", type="string", dest="distributed_packages", help="Additional packages to be passed to easy_install " "on remote machines when being run in distributed " "mode.") parser.add_option("--distributed-log-path", type="string", dest="distributed_log_path", help="Path where all the logs will be stored when " "running a distributed test") parser.add_option("--feedback-endpoint", type="string", dest="feedback_endpoint", help="Path where all the logs will be stored when " "running a distributed test") parser.add_option("--feedback-pubsub-endpoint", type="string", dest="feedback_pubsub_endpoint", help="Path where all the logs will be stored when " "running a distributed test") parser.add_option("--feedback", action="store_true", dest="feedback", help="Activates the realtime feedback") # XXX What exactly is this checking for here?? cmd_args = " ".join([k for k in args if k.find('--distribute') < 0]) options, args = parser.parse_args(args) if len(args) != 2: parser.error("incorrect number of arguments") if not args[1].count('.'): parser.error("invalid argument; should be [class].[method]") if options.as_fast_as_possible: options.bench_sleep_time_min = '0' options.bench_sleep_time_max = '0' options.bench_sleep_time = '0' if os.path.exists(args[0]): # We were passed a file for the first argument module_name = os.path.basename(os.path.splitext(args[0])[0]) else: # We were passed a module name module_name = args[0] # registering signals signal.signal(signal.SIGTERM, shutdown) signal.signal(signal.SIGINT, shutdown) if os.name is not 'nt': signal.signal(signal.SIGQUIT, shutdown) klass, method = args[1].split('.') if options.distribute: from funkload.Distributed import DistributionMgr ret = None global _manager try: distmgr = DistributionMgr( module_name, klass, method, options, cmd_args) _manager = distmgr except UserWarning, error: trace(red_str("Distribution failed with:%s \n" % (error))) try: try: distmgr.prepare_workers(allow_errors=True) ret = distmgr.run() distmgr.final_collect() except KeyboardInterrupt: trace("* ^C received *") finally: # in any case we want to stop the workers at the end distmgr.abort() _manager = None return ret
def main(args=sys.argv[1:]): """Default main.""" # enable to load module in the current path cur_path = os.path.abspath(os.path.curdir) sys.path.insert(0, cur_path) parser = OptionParser(USAGE, formatter=TitledHelpFormatter(), version="FunkLoad %s" % get_version()) parser.add_option("", "--config", type="string", dest="config", metavar='CONFIG', help="Path to alternative config file") parser.add_option("-u", "--url", type="string", dest="main_url", help="Base URL to bench.") parser.add_option("-c", "--cycles", type="string", dest="bench_cycles", help="Cycles to bench, colon-separated list of " "virtual concurrent users. To run a bench with 3 " "cycles of 5, 10 and 20 users, use: -c 5:10:20") parser.add_option("-D", "--duration", type="string", dest="bench_duration", help="Duration of a cycle in seconds.") parser.add_option("-m", "--sleep-time-min", type="string", dest="bench_sleep_time_min", help="Minimum sleep time between requests.") parser.add_option("-M", "--sleep-time-max", type="string", dest="bench_sleep_time_max", help="Maximum sleep time between requests.") parser.add_option("-t", "--test-sleep-time", type="string", dest="bench_sleep_time", help="Sleep time between tests.") parser.add_option("-s", "--startup-delay", type="string", dest="bench_startup_delay", help="Startup delay between thread.") parser.add_option("-f", "--as-fast-as-possible", action="store_true", help="Remove sleep times between requests and between " "tests, shortcut for -m0 -M0 -t0") parser.add_option( "-r", "--runner-class", type="string", dest="bench_runner_class", default="funkload.BenchRunner.BenchRunner", help="Python dotted import path to BenchRunner class to use.") parser.add_option("", "--no-color", action="store_true", help="Monochrome output.") parser.add_option("", "--accept-invalid-links", action="store_true", help="Do not fail if css/image links are not reachable.") parser.add_option("", "--simple-fetch", action="store_true", dest="bench_simple_fetch", help="Don't load additional links like css or images " "when fetching an html page.") parser.add_option("-l", "--label", type="string", help="Add a label to this bench run for easier " "identification (it will be appended to the " "directory name for reports generated from it).") parser.add_option("--enable-debug-server", action="store_true", dest="debugserver", help="Instantiates a debug HTTP server which exposes an " "interface using which parameters can be modified " "at run-time. Currently supported parameters: " "/cvu?inc=<integer> to increase the number of " "CVUs, /cvu?dec=<integer> to decrease the number " "of CVUs, /getcvu returns number of CVUs ") parser.add_option("--debug-server-port", type="string", dest="debugport", help="Port at which debug server should run during the " "test") parser.add_option("--distribute", action="store_true", dest="distribute", help="Distributes the CVUs over a group of worker " "machines that are defined in the workers section") parser.add_option("--distribute-workers", type="string", dest="workerlist", help="This parameter will over-ride the list of " "workers defined in the config file. expected " "notation is uname@host,uname:pwd@host or just " "host...") parser.add_option("--distribute-python", type="string", dest="python_bin", help="When running in distributed mode, this Python " "binary will be used across all hosts.") parser.add_option("--is-distributed", action="store_true", dest="is_distributed", help="This parameter is for internal use only. it " "signals to a worker node that it is in " "distributed mode and shouldn't perform certain " "actions.") parser.add_option("--distributed-packages", type="string", dest="distributed_packages", help="Additional packages to be passed to easy_install " "on remote machines when being run in distributed " "mode.") parser.add_option("--distributed-log-path", type="string", dest="distributed_log_path", help="Path where all the logs will be stored when " "running a distributed test") parser.add_option("--feedback-endpoint", type="string", dest="feedback_endpoint", help="Path where all the logs will be stored when " "running a distributed test") parser.add_option("--feedback-pubsub-endpoint", type="string", dest="feedback_pubsub_endpoint", help="Path where all the logs will be stored when " "running a distributed test") parser.add_option("--feedback", action="store_true", dest="feedback", help="Activates the realtime feedback") # XXX What exactly is this checking for here?? cmd_args = " ".join([k for k in args if k.find('--distribute') < 0]) options, args = parser.parse_args(args) if len(args) != 2: parser.error("incorrect number of arguments") if not args[1].count('.'): parser.error("invalid argument; should be [class].[method]") if options.as_fast_as_possible: options.bench_sleep_time_min = '0' options.bench_sleep_time_max = '0' options.bench_sleep_time = '0' if os.path.exists(args[0]): # We were passed a file for the first argument module_name = os.path.basename(os.path.splitext(args[0])[0]) else: # We were passed a module name module_name = args[0] # registering signals signal.signal(signal.SIGTERM, shutdown) signal.signal(signal.SIGINT, shutdown) signal.signal(signal.SIGQUIT, shutdown) klass, method = args[1].split('.') if options.distribute: from funkload.Distributed import DistributionMgr ret = None global _manager try: distmgr = DistributionMgr(module_name, klass, method, options, cmd_args) _manager = distmgr except UserWarning, error: trace(red_str("Distribution failed with:%s \n" % (error))) try: try: distmgr.prepare_workers(allow_errors=True) ret = distmgr.run() distmgr.final_collect() except KeyboardInterrupt: trace("* ^C received *") finally: # in any case we want to stop the workers at the end distmgr.abort() _manager = None return ret