def main(): """ main processing module """ options = parse_command_line() initialize_logging(options.log_name) log = logging.getLogger("main") log.info("program starts") halt_event = Event() gevent.signal(signal.SIGTERM, _handle_sigterm, halt_event) log.info("loading test script from %r" % (options.test_script, )) with open(options.test_script, "rt") as input_file: test_script = json.load(input_file) log.info("loading user identity files from %r" % ( options.user_identity_dir, )) customer_list = list() for file_name in os.listdir(options.user_identity_dir): if not ('motoboto' in file_name and 'benchmark' in file_name): continue if options.max_users is not None \ and len(customer_list) >= options.max_users: log.info("breaking at %s users" % (options.max_users, )) break log.info("loading %r" % (file_name, )) user_identity = load_identity_from_file( os.path.join(options.user_identity_dir, file_name) ) customer = GreenletCustomer(halt_event, user_identity, test_script) customer.link_exception(_unhandled_greenlet_exception) customer.start_later(random.uniform(0.0, 15.0)) customer_list.append(customer) log.info("waiting") try: halt_event.wait(options.test_duration) except KeyboardInterrupt: log.info("KeyBoardInterrupt") if test_script.get("audit-after", False): print >>sys.stderr, "run redis_stats_collector, press return when done" raw_input("waiting...") log.info("setting halt event") halt_event.set() total_error_count = 0 log.info("joining") for customer in customer_list: customer.join() total_error_count += customer.error_count log.info("program ends {0} total errors, {1} unhandled exceptions".format( total_error_count, _unhandled_exception_count)) return 0
def main(): """ main processing module """ options = parse_command_line() initialize_logging(options.log_name) log = logging.getLogger("main") log.info("program starts") halt_event = Event() gevent.signal(signal.SIGTERM, _handle_sigterm, halt_event) log.info("loading test script from %r" % (options.test_script,)) with open(options.test_script, "rt") as input_file: test_script = json.load(input_file) log.info("loading user identity files from %r" % (options.user_identity_dir,)) customer_list = list() for file_name in os.listdir(options.user_identity_dir): if not ("motoboto" in file_name and "benchmark" in file_name): continue if options.max_users is not None and len(customer_list) >= options.max_users: log.info("breaking at %s users" % (options.max_users,)) break log.info("loading %r" % (file_name,)) user_identity = load_identity_from_file(os.path.join(options.user_identity_dir, file_name)) customer = GreenletCustomer(halt_event, user_identity, test_script) customer.link_exception(_unhandled_greenlet_exception) customer.start_later(random.uniform(0.0, 15.0)) customer_list.append(customer) log.info("waiting") try: halt_event.wait(options.test_duration) except KeyboardInterrupt: log.info("KeyBoardInterrupt") if test_script.get("audit-after", False): print >>sys.stderr, "run redis_stats_collector, press return when done" raw_input("waiting...") log.info("setting halt event") halt_event.set() total_error_count = 0 log.info("joining") for customer in customer_list: customer.join() total_error_count += customer.error_count log.info( "program ends {0} total errors, {1} unhandled exceptions".format(total_error_count, _unhandled_exception_count) ) return 0
def __init__(self, identity=None): self._log = logging.getLogger("S3Emulator") if identity is not None: self._identity = identity else: identity = load_identity_from_environment() if identity is not None: self._identity = identity else: identity = load_identity_from_file() if identity is not None: self._identity = identity else: raise ValueError( "You must specify identity in environment or file") self._default_bucket = Bucket( self._identity, compute_default_collection_name(self._identity.user_name))
def __init__(self, identity=None): self._log = logging.getLogger("S3Emulator") if identity is not None: self._identity = identity else: identity = load_identity_from_environment() if identity is not None: self._identity = identity else: identity = load_identity_from_file() if identity is not None: self._identity = identity else: raise ValueError( "You must specify identity in environment or file" ) self._default_bucket = Bucket( self._identity, compute_default_collection_name(self._identity.user_name) )
def main(test_script_path, user_identity_path): """ main module """ user_identity = load_identity_from_file(user_identity_path) _initialize_logging(user_identity.user_name) log = logging.getLogger("main") log.info("program starts") halt_event = Event() signal.signal(signal.SIGTERM, _create_signal_handler(halt_event)) log.info("loading test script from %r" % (test_script_path, )) with open(test_script_path, "rt") as input_file: test_script = json.load(input_file) customer = BaseCustomer(halt_event, user_identity, test_script) try: customer._main_loop() except Exception, instance: log.exception(instance) return -1