[Erp5-report] r9631 - /erp5/trunk/utils/erp5mechanize/smartRun.py

nobody at svn.erp5.org nobody at svn.erp5.org
Mon Sep 4 13:18:47 CEST 2006


Author: vincent
Date: Mon Sep  4 13:18:45 2006
New Revision: 9631

URL: http://svn.erp5.org?rev=9631&view=rev
Log:
First checkin of smart test runner: after each test, decide wether the limit was reached or not, and do not test things which could be predicted to fail.

Added:
    erp5/trunk/utils/erp5mechanize/smartRun.py

Added: erp5/trunk/utils/erp5mechanize/smartRun.py
URL: http://svn.erp5.org/erp5/trunk/utils/erp5mechanize/smartRun.py?rev=9631&view=auto
==============================================================================
--- erp5/trunk/utils/erp5mechanize/smartRun.py (added)
+++ erp5/trunk/utils/erp5mechanize/smartRun.py Mon Sep  4 13:18:45 2006
@@ -1,0 +1,137 @@
+#!/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 os
+import sys
+import getopt
+import tempfile
+
+def execute(command):
+  print command
+  return os.system(command)
+
+min_zope = 1
+max_zope = 1
+runBenchmarks = 'runBenchmarks.py'
+userperzope = 'userperzope.py'
+maxuser = None
+testsuite = None
+usercoef = None
+
+try:
+  opt_list, arg_list = getopt.getopt(sys.argv[1:], '', ['min_zope=',
+      'max_zope=', 'runBenchmarks=', 'userperzope=', 'minuser=',
+      'maxuser=', 'testsuite=', 'usercoef='])
+except getopt.error, msg:
+  print 'Error: %s' % (msg, )
+  print \
+'''Synopsis:
+  %s --testsuite str --usercoef int [--minzope int] [--maxzope int]
+     [--runBenchmarks str] [--userperzope str] [--minuser int] [--maxuser int]
+     [-- userperzope-arguments]
+
+  testsuite si a mandatory argument giving the name of the suite test to run.
+  usercoef is a mandatory argument giving the maximum number of users to
+  simulate per zope.
+  minzope is the number of zope to start with.
+    default: %s
+  maxzope is the number of zope to reach.
+    default: %s
+  runBenchmarks is the name of the program to run a benchmark.
+    default: %s
+  userperzope is the name of the program to test if a result fit the
+  constraints.
+    default: %s
+  minuser is the number of users for the initial run.
+    default: (same as minzope)
+  maxuser is the absolute maximum number of users to test.
+    default: (no limit)
+
+  Optionnally at the end of the arugment list can be given a list of arguments
+  which will be directly passed to userperzope program.
+''' % (sys.argv[0], min_zope, max_zope, runBenchmarks, userperzope)
+  sys.exit(2)
+
+usercount = None
+
+for o, a in opt_list:
+  if o == '--minzope':
+    min_zope = int(a)
+  elif o == '--maxzope':
+    max_zope = int(a)
+  elif o == '--runBenchmarks':
+    runBenchmarks = a
+  elif o == '--userperzope':
+    userperzope = a
+  elif o == '--minuser':
+    minuser = int(a)
+  elif o == '--maxuser':
+    maxuser = int(a)
+  elif o == '--testsuite':
+    testsuite = a
+  elif o == '--usercoef':
+    usercoef = int(a)
+
+userperzope_args = ' '.join(arg_list)
+
+if testsuite is None:
+  print 'Mandatory testsuite agument not given.'
+  sys.exit(2)
+
+if usercoef is None:
+  print 'Mandatory usercoef agument not given.'
+  sys.exit(2)
+
+if usercount is None:
+  usercount = min_zope
+
+userperzope_arguments = ' '.join(arg_list)
+fd, resultpath = tempfile.mkstemp()
+os.close(fd)
+fd, sresultpath = tempfile.mkstemp()
+os.close(fd)
+
+for current_zopecount in xrange(min_zope, max_zope):
+  if usercount < current_zopecount:
+    print 'Less successfull users than zope to test, aborting.'
+    break
+  max_usercount = current_zopecount * usercoef
+  if maxuser is not None:
+    max_usercount = min(maxuser, max_usercount)
+  for current_usercount in xrange(usercount, max_usercount):
+    execute('%s --config %s --results %s --dresults %s --usercount %s --zopecount %s' % (runBenchmarks, testsuite, resultpath, dresultpath, current_usercount, current_zopecount))
+    result = execute('%s %s %s' % (userperzope, userperzope_args, resultpath))
+    print 'Result : %s' % (result, )
+    if result != 0:
+      print 'Test with %s users is out of limits.' % (current_usercount, )
+      break
+    usercount = current_usercount
+
+unlink(resultpath)
+unlink(sresultpath)
+




More information about the Erp5-report mailing list