[Erp5-report] r11537 - in /erp5/trunk/utils/erp5mechanize: multi_userperzope.py userperzope.py
nobody at svn.erp5.org
nobody at svn.erp5.org
Thu Nov 30 13:44:44 CET 2006
Author: vincent
Date: Thu Nov 30 13:44:41 2006
New Revision: 11537
URL: http://svn.erp5.org?rev=11537&view=rev
Log:
userperzope.py : fix comment typo. Change unlogical test condition.
multi_userperzope.py : userperzope.py version for multiSmartRun.py
Added:
erp5/trunk/utils/erp5mechanize/multi_userperzope.py (with props)
Modified:
erp5/trunk/utils/erp5mechanize/userperzope.py
Added: erp5/trunk/utils/erp5mechanize/multi_userperzope.py
URL: http://svn.erp5.org/erp5/trunk/utils/erp5mechanize/multi_userperzope.py?rev=11537&view=auto
==============================================================================
--- erp5/trunk/utils/erp5mechanize/multi_userperzope.py (added)
+++ erp5/trunk/utils/erp5mechanize/multi_userperzope.py Thu Nov 30 13:44:41 2006
@@ -1,0 +1,190 @@
+#!/usr/bin/python
+##############################################################################
+#
+# Copyright (c) 2006 Nexedi SARL and Contributors. All Rights Reserved.
+# Vincent Pelletier <vincent at nexedi.com>
+#
+# WARNING: This program as such is intended to be used by professional
+# programmers who take the whole responsability of assessing all potential
+# consequences resulting from its eventual inadequacies and bugs
+# End users who are looking for a ready-to-use solution with commercial
+# garantees and support are strongly adviced to contract a Free Software
+# Service Company
+#
+# This program is Free Software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+#
+##############################################################################
+import sys
+import getopt
+
+"""
+ Same as userperzope.py, except that multiple files are just concatenated
+ for reading, instead of reading them as separate results.
+ To be used with multiSmartRun.py
+"""
+
+def compute_max_error_count(user_count, maximum_failure):
+ if maximum_failure is None:
+ return None
+ maximum_failure = int(maximum_failure)
+ if maximum_failure < 0:
+ return -maximum_failure / user_count
+ else:
+ return maximum_failure
+
+def result_cmp(a, b):
+ dif = cmp(a['user'], b['user'])
+ if dif != 0:
+ return dif
+ return cmp(a['duration'], b['duration'])
+
+def parse_csv_line(line, sep):
+ line = line.replace('\n','')
+ item_list = line.split(sep)
+ for pos in xrange(len(item_list)):
+ item = item_list[pos]
+ if item[0] == "'":
+ item = item[1:]
+ if item[-1] == "'":
+ item = item[:-1]
+ item_list[pos] = item
+ return item_list
+
+def output_csv(fields=[], separator=','):
+ sys.stdout.write(separator.join([repr(v) for v in fields]))
+ sys.stdout.write('\n')
+
+try:
+ opt_list, arg_list = getopt.getopt(sys.argv[1:], '', ['maximum_duration=', 'maximum_failure=', 'csv_separator=', 'default_step_number=', 'ignore_first_run'])
+except getopt.error, msg:
+ print 'Error: %s' % (msg, )
+ print \
+'''Synopsis:
+ %s [--maximum_duration=float] [--maximum_failure=int] [--csv_separator=char] [--default_step_number=integer] [file [...]]
+
+ Each given file must be a CSV file separated by separator (default = ,).
+ First CSV column must be of the form user at host.
+ If last collumn contains "FAILED" (without quotes) the following is ignored
+ and the test immediatelly marked as failed.
+ If maximum_failure is given and positive, it will be the absolute maximum
+ of tolerated failures in a test, independently of user count.
+ If maximum_failure is given and negative, its absolute value will be the
+ maximum number of tolerated failures per user in average
+ (computed as -maximum_failure divided by the number of user for a given
+ test run).
+ If maximum_duration is given, second and third columns must be floating
+ point values (second is start time, third is stop time). The
+ maximum_duration parameter must be a floating point value aswel. If the
+ test duration exceed the given time limit ,the test is marked as failed.
+ Default is not to check the test duration.
+ If default_step_number is given and a file don't contain a 4th field
+ representing the step number in the test, use the given value as step
+ count.
+
+Output:
+ On the standard output is given a CSV file giving for every number of zope
+ the maximum number of users for which the test was successfull.
+ The CSV separator is the same as the one given as parameter.
+''' % (sys.argv[0], )
+ sys.exit(2)
+
+csv_separator = ','
+maximum_duration = None
+maximum_failure = None
+ignore_first_run = False
+default_step_number = None
+for o, a in opt_list:
+ if o == '--maximum_duration':
+ maximum_duration = float(a)
+ elif o == '--maximum_failure':
+ maximum_failure = a
+ elif o == '--csv_separator':
+ csv_separator = a
+ elif o == '--default_step_number':
+ default_step_number = int(a)
+ elif o == '--ignore_first_run':
+ ignore_first_run = True
+
+result_list = {}
+known_user_list = []
+known_zope_list = []
+duration_list = []
+failed = 0
+for filename in arg_list:
+ csv = open(filename)
+ line_list = csv.readlines()
+ for line in line_list:
+ field_list = parse_csv_line(line, csv_separator)
+ user, zope = field_list[0].split('@', 1)
+ if zope not in known_zope_list:
+ known_zope_list.append(zope)
+ if user not in known_user_list:
+ known_user_list.append(user)
+ if ignore_first_run: # This allows to avoid the impact of the first run for a given user (cache filling, ...)
+ continue
+ if field_list[-1] == 'FAILED':
+ failed += 1
+ continue
+ if len(field_list) < 4:
+ if default_step_number is not None:
+ duration_list.append(float(field_list[2])/default_step_number)
+ else:
+ sys.stderr.write('Error in file %s : at least one line has less than 4 fields and --default_step_number has not been given.' % (filename, ))
+ raise KeyError
+ else:
+ duration_list.append(float(field_list[2])/int(field_list[3]))
+ csv.close()
+if len(duration_list):
+ result = {'user': len(known_user_list),
+ 'duration': len(duration_list) and sum(duration_list)/len(duration_list) or 0,
+ 'max_duration': len(duration_list) and max(duration_list) or 0,
+ 'min_duration': len(duration_list) and min(duration_list) or 0,
+ 'failures': failed,
+ 'filename': filename}
+ if not result_list.has_key(len(known_zope_list)):
+ result_list[len(known_zope_list)] = [result]
+ else:
+ result_list[len(known_zope_list)].append(result)
+
+output_csv(separator=csv_separator, fields=['Zope count', 'Total user count', 'Average test duration at maximum user count', 'Min', 'Max', 'Limited by', 'File'])
+failure_count = 0
+for k, v in result_list.items():
+ v.sort(cmp=result_cmp)
+ maximum_user_number = 0
+ avg_duration = 0
+ min_duration = 0
+ max_duration = 0
+ filename = ''
+ reason = '(no limit reached)'
+ for result in v:
+ if result['user'] < maximum_user_number or (result['user'] == maximum_user_number and result['duration'] > avg_duration):
+ continue
+ max_failure_for_this_run = compute_max_error_count(result['user'], maximum_failure)
+ if max_failure_for_this_run is not None and result['failures'] > max_failure_for_this_run:
+ reason = 'Too many failures'
+ break
+ if maximum_duration is not None and result['duration'] > maximum_duration:
+ reason = 'Too slow'
+ break
+ maximum_user_number = result['user']
+ avg_duration = result['duration']
+ min_duration = result['min_duration']
+ max_duration = result['max_duration']
+ filename = result['filename']
+ if reason != '(no limit reached)':
+ failure_count += 1
+ output_csv(separator=csv_separator, fields=[k, maximum_user_number, avg_duration, min_duration, max_duration, reason, filename])
+
+sys.exit(failure_count)
Propchange: erp5/trunk/utils/erp5mechanize/multi_userperzope.py
------------------------------------------------------------------------------
svn:executable = *
Modified: erp5/trunk/utils/erp5mechanize/userperzope.py
URL: http://svn.erp5.org/erp5/trunk/utils/erp5mechanize/userperzope.py?rev=11537&r1=11536&r2=11537&view=diff
==============================================================================
--- erp5/trunk/utils/erp5mechanize/userperzope.py (original)
+++ erp5/trunk/utils/erp5mechanize/userperzope.py Thu Nov 30 13:44:41 2006
@@ -88,7 +88,7 @@
count.
Output:
- On the standard output is given a CSV file giving for every nimber of zope
+ On the standard output is given a CSV file giving for every number of zope
the maximum number of users for which the test was successfull.
The CSV separator is the same as the one given as parameter.
''' % (sys.argv[0], )
@@ -139,7 +139,7 @@
raise KeyError
else:
duration_list.append(float(field_list[2])/int(field_list[3]))
- if len(line_list):
+ if len(duration_list):
result = {'user': len(known_user_list), 'duration': len(duration_list) and sum(duration_list)/len(duration_list) or 0, 'max_duration': len(duration_list) and max(duration_list) or 0, 'min_duration': len(duration_list) and min(duration_list) or 0, 'failures': failed, 'filename': filename}
if not result_list.has_key(len(known_zope_list)):
result_list[len(known_zope_list)] = [result]
More information about the Erp5-report
mailing list