def do_fire(self, line): """Fires the cannons, asks for URL if none are defined in settings""" if self._cannons_deployed: if self._siege_urls and not self._bypass_urls: report = slam_host(self._cannon_hosts, None) else: target = raw_input(' target: ') if target != '': report = slam_host(self._cannon_hosts, target) else: print 'ERROR: No target specified' return if isinstance(report, str): print report return ### Ad-hoc CSV print 'Results ]------------------' print 'Num_Trans,Elapsed,Tran_Rate' total_trans = 0 for idx in xrange(len(report['num_trans'])): total_trans = total_trans + int(report['num_trans'][idx]) print '%s,%s,%s' % (report['num_trans'][idx], report['elapsed'][idx], report['tran_rate'][idx]) print 'Total:', total_trans else: print 'ERROR: Cannons not deployed yet'
def do_fire(self, line): """Fires the cannons""" if self._cannons_deployed: report = slam_host(self._cannon_hosts) print 'Results ]------------------' print report else: print 'ERROR: Cannons not deployed yet'
def do_mfire(self, line): """Runs `fire` multiple times and aggregates totals""" if self._cannons_deployed: ### Get test arguments from user try: n_times = raw_input(' n times: ') n_times = int(n_times) except: print '<n_times> must be a number.' return print 'Results ]------------------' for run_instance in xrange(n_times): report = slam_host(self._cannon_hosts) print '%s:' % (run_instance) print report else: print 'ERROR: Cannons not deployed yet'
def do_mfire(self, line): """Runs `fire` multiple times and aggregates totals""" if self._cannons_deployed: ### Get test arguments from user try: if not self._siege_urls and self._bypass_urls: target = raw_input(' target: ') n_times = raw_input(' n times: ') n_times = int(n_times) except: print '<target> must be a string.' print '<n_times> must be a number.' return print 'Results ]------------------' print 'Run ID,Sum Transactions,Sum Transaction Rate' total_transactions = 0 for run_instance in xrange(n_times): report = slam_host(self._cannon_hosts, target) if isinstance(report, str): print report return ### Ad-hoc CSV sum_num_trans = 0.0 sum_tran_rate = 0.0 for idx in xrange(len(report['num_trans'])): sum_num_trans = sum_num_trans + float( report['num_trans'][idx]) sum_tran_rate = sum_tran_rate + float( report['tran_rate'][idx]) total_transactions = total_transactions + sum_num_trans print '%s,%s,%s' % (run_instance, sum_num_trans, sum_tran_rate) print 'Total:', total_transactions else: print 'ERROR: Cannons not deployed yet'
def do_mfire(self, line): """Runs `fire` multiple times and aggregates totals""" if self._cannons_deployed: ### Get test arguments from user try: if not self._siege_urls and self._bypass_urls: target = raw_input(' target: ') n_times = raw_input(' n times: ') n_times = int(n_times) except: print '<target> must be a string.' print '<n_times> must be a number.' return print 'Results ]------------------' print 'Run ID,Sum Transactions,Sum Transaction Rate' total_transactions = 0 for run_instance in xrange(n_times): report = slam_host(self._cannon_hosts, target) if isinstance(report, str): print report return ### Ad-hoc CSV sum_num_trans = 0.0 sum_tran_rate = 0.0 for idx in xrange(len(report['num_trans'])): sum_num_trans = sum_num_trans + float(report['num_trans'][idx]) sum_tran_rate = sum_tran_rate + float(report['tran_rate'][idx]) total_transactions = total_transactions + sum_num_trans print '%s,%s,%s' % (run_instance, sum_num_trans, sum_tran_rate) print 'Total:', total_transactions else: print 'ERROR: Cannons not deployed yet'
_cannon_hosts = init_cannons() print 'Giving cannons 30 seconds to boot' time.sleep(30) status = setup_cannons(_cannon_hosts) _cannons_deployed = True # CONFIG elif command == "config": host_string = raw_input(' type host list: ') hosts = eval(host_string) _cannon_hosts = hosts _cannons_deployed = True # FIRE elif command == "fire": if _cannons_deployed: target = raw_input(' target: ') report = slam_host(_cannon_hosts, target) # *close* to a CSV print 'Results ]------------------' print 'Num_Trans,Elapsed,Tran_Rate' for idx in xrange(len(report['num_trans'])): print '%s,%s,%s' % (report['num_trans'][idx], report['elapsed'][idx], report['tran_rate'][idx]) else: print 'ERROR: Cannons not deployed yet'