Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add more options to multimechanize-run #47

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions docs/configfile.rst
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ Here is a sample ``config.cfg`` file showing all possible options, defining 2 gr
progress_bar = on
console_logging = off
xml_report = off
drop_expired = True
results_database = sqlite:///my_project/results.db
post_run_script = python my_project/foo.py

Expand All @@ -62,6 +63,7 @@ The following settings/options are available in the ``[global]`` config section:
* ``progress_bar``: turn on/off console progress bar during test run [optional, default = on]
* ``console_logging``: turn on/off logging to stdout [optional, default = off]
* ``xml_report``: turn on/off xml/jtl report [optional, default = off]
* ``drop_expired``: drop elapsed requests which finish after ``run_time``
* ``results_database``: database connection string [optional]
* ``post_run_script``: hook to call a script at test completion [optional]

Expand Down
9 changes: 5 additions & 4 deletions multimechanize/results.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@



def output_results(results_dir, results_file, run_time, rampup, ts_interval, user_group_configs=None, xml_reports=False):
results = Results(results_dir + results_file, run_time)
def output_results(results_dir, results_file, run_time, rampup, ts_interval, user_group_configs=None, xml_reports=False, drop_expired=True):
results = Results(results_dir + results_file, run_time, drop_expired)

report = reportwriter.Report(results_dir)

Expand Down Expand Up @@ -240,9 +240,10 @@ def output_results(results_dir, results_file, run_time, rampup, ts_interval, use


class Results(object):
def __init__(self, results_file_name, run_time):
def __init__(self, results_file_name, run_time, drop_expired=True):
self.results_file_name = results_file_name
self.run_time = run_time
self.drop_expired = drop_expired
self.total_transactions = 0
self.total_errors = 0
self.uniq_timer_names = set()
Expand Down Expand Up @@ -289,7 +290,7 @@ def __parse_file(self):

r = ResponseStats(request_num, elapsed_time, epoch_secs, user_group_name, trans_time, error, custom_timers)

if elapsed_time < self.run_time: # drop all times that appear after the last request was sent (incomplete interval)
if not self.drop_expired or elapsed_time < self.run_time: # drop all times that appear after the last request was sent (incomplete interval)
resp_stats_list.append(r)

if error != '':
Expand Down
28 changes: 19 additions & 9 deletions multimechanize/utilities/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,12 @@ def main():
parser.add_option('-r', '--results', dest='results_dir', help='results directory to reprocess')
parser.add_option('-b', '--bind-addr', dest='bind_addr', help='rpc bind address', default='localhost')
parser.add_option('-d', '--directory', dest='projects_dir', help='directory containing project folder', default='.')
parser.add_option('-g', '--groups', dest='user_groups', help='User groups to run, separated by comma', default=None)
cmd_opts, args = parser.parse_args()

if cmd_opts.user_groups:
cmd_opts.user_groups = set(cmd_opts.user_groups.split(','))

try:
project_name = args[0]
except IndexError:
Expand Down Expand Up @@ -74,7 +78,7 @@ def run_test(project_name, cmd_opts, remote_starter=None):
remote_starter.test_running = True
remote_starter.output_dir = None

run_time, rampup, results_ts_interval, console_logging, progress_bar, results_database, post_run_script, xml_report, user_group_configs = configure(project_name, cmd_opts)
run_time, rampup, results_ts_interval, console_logging, progress_bar, results_database, post_run_script, xml_report, user_group_configs, drop_expired = configure(project_name, cmd_opts)

run_localtime = time.localtime()
output_dir = '%s/%s/results/results_%s' % (cmd_opts.projects_dir, project_name, time.strftime('%Y.%m.%d_%H.%M.%S/', run_localtime))
Expand Down Expand Up @@ -136,7 +140,7 @@ def run_test(project_name, cmd_opts, remote_starter=None):
# all agents are done running at this point
time.sleep(.2) # make sure the writer queue is flushed
print '\n\nanalyzing results...\n'
results.output_results(output_dir, 'results.csv', run_time, rampup, results_ts_interval, user_group_configs, xml_report)
results.output_results(output_dir, 'results.csv', run_time, rampup, results_ts_interval, user_group_configs, xml_report, drop_expired)
print 'created: %sresults.html\n' % output_dir
if xml_report:
print 'created: %sresults.jtl' % output_dir
Expand Down Expand Up @@ -186,6 +190,7 @@ def configure(project_name, cmd_opts, config_file=None):
if config_file is None:
config_file = '%s/%s/config.cfg' % (cmd_opts.projects_dir, project_name)
config.read(config_file)
user_group_set = cmd_opts.user_groups
for section in config.sections():
if section == 'global':
run_time = config.getint(section, 'run_time')
Expand Down Expand Up @@ -213,14 +218,19 @@ def configure(project_name, cmd_opts, config_file=None):
xml_report = config.getboolean(section, 'xml_report')
except ConfigParser.NoOptionError:
xml_report = False
try:
drop_expired = config.getboolean(section, 'drop_expired')
except ConfigParser.NoOptionError:
drop_expired = True
else:
threads = config.getint(section, 'threads')
script = config.get(section, 'script')
user_group_name = section
ug_config = UserGroupConfig(threads, user_group_name, script)
user_group_configs.append(ug_config)

return (run_time, rampup, results_ts_interval, console_logging, progress_bar, results_database, post_run_script, xml_report, user_group_configs)
if not user_group_set or section in cmd_opts.user_groups:
threads = config.getint(section, 'threads')
script = config.get(section, 'script')
user_group_name = section
ug_config = UserGroupConfig(threads, user_group_name, script)
user_group_configs.append(ug_config)

return (run_time, rampup, results_ts_interval, console_logging, progress_bar, results_database, post_run_script, xml_report, user_group_configs, drop_expired)



Expand Down