[Erp5-report] r14211 - /erp5/trunk/utils/oood/testOoodHighLoad.py

nobody at svn.erp5.org nobody at svn.erp5.org
Wed Apr 25 02:15:25 CEST 2007


Author: bartek
Date: Wed Apr 25 02:15:23 2007
New Revision: 14211

URL: http://svn.erp5.org?rev=14211&view=rev
Log:
configuration at the beginning of script
total number of conversions to be given on cmdline (defaults to 100)
results are counted and stored in stats.txt file (flushing every time, so they can be viewed at runtime)

Modified:
    erp5/trunk/utils/oood/testOoodHighLoad.py

Modified: erp5/trunk/utils/oood/testOoodHighLoad.py
URL: http://svn.erp5.org/erp5/trunk/utils/oood/testOoodHighLoad.py?rev=14211&r1=14210&r2=14211&view=diff
==============================================================================
--- erp5/trunk/utils/oood/testOoodHighLoad.py (original)
+++ erp5/trunk/utils/oood/testOoodHighLoad.py Wed Apr 25 02:15:23 2007
@@ -50,10 +50,20 @@
 import config
 import lib
 
+### configuration
+max_batch_size = 5
+max_interval = 15
+###
+
 enc = base64.encodestring
 dec = base64.decodestring
 
 sp = ServerProxy('http://%s:%d' % (config.server_host, config.server_port), allow_none = True)
+
+if len(sys.argv) == 2:
+  total_conversions = int(sys.argv[1])
+else:
+  total_conversions = 100
 
 # create a list of od? files if not present
 # first check if the oood_home is writeable
@@ -94,6 +104,33 @@
 
 class TestScalability(unittest.TestCase):
 
+  result_dict = {}
+
+  def logResult(self, res):
+    self.result_dict[res] = self.result_dict.get(res, 0) + 1
+    f = open('stats.txt', 'w')
+    for res, count in self.result_dict.items():
+      f.write('%s : %s\n' % (count, res))
+    f.write("""
+    Server responses:
+    True - everyting went fine
+    50   - the client called a non-existent function
+    51   - the server is temporarily blocked because emergency restart is in progress
+    52   - worker pool is empty, the server will be restarted
+    53   - pool and semaphore are out of sync (this should not happen, so the server
+           will be restarted)
+    54   - the instance timed out while trying to process a document (probably
+           the document froze the OOo instance); the OOo instance will be restarted
+    55   - the OOo failed (two times) to load or process the document; chances are
+           that the document has an invalid format.
+
+    Anything else (a dictionary, an exception or else) means that something is
+    really wrong and the oood needs to be fixed.
+    """)
+    f.close()
+
+  #watch = [0]
+
   def generateFormat(self):
     """
       take a random file from od? file list, randomly choose one target format
@@ -108,6 +145,7 @@
     local.target_list = sp.getAllowedTargetItemList(ext2mime[local.fname[-3:]])
     if type(local.target_list) != type([]):
       log('got error code: %s' % local.target_list)
+      self.logResult(local.target_list)
       self.failUnless(type(local.target_list) == type(4))
       return 
     local.tgt = random.choice(local.target_list)
@@ -116,9 +154,11 @@
     local.res = sp.run_generate(lib.asciify(local.fname), enc(local.data), None, local.tgt[0])
     if type(local.res) != type({}) or ('data' not in local.res.keys()) or ('meta' not in local.res.keys()):
       log('got error code: %s' % local.res)
+      self.logResult(local.res)
       self.failUnless(type(local.res) == type(4))
       return 
     local.res = bool(local.res)
+    self.logResult(local.res)
     self.failUnless(local.res)
 
   def testRandomLoad(self):
@@ -129,17 +169,20 @@
       do it 100 times
     """
     counter = 0
-    repeat = 100
+    #repeat = 2
     print ' '
-    for iteration in range(repeat):
+    #for iteration in range(repeat):
+    while True:
       random.seed()
-      batch_size = random.randint(1, 5)
-      interval = random.randint(1, 30)
-      log('batch %d, interval %d' % (batch_size, interval))
+      batch_size = random.randint(1, max_batch_size)
+      interval = random.randint(1, max_interval)
+      log('batch %d (total %d), interval %d' % (batch_size, counter + batch_size, interval))
       for i in range(batch_size):
         counter += 1
         t = threading.Thread(target=self.generateFormat)
         t.start()
+        if counter == total_conversions:
+          return
       time.sleep(interval)
 
 if __name__=='__main__':




More information about the Erp5-report mailing list