Browse Source

Moved accept header choice to FrameworkTestType

Hamilton Turner 10 years ago
parent
commit
58c210c906

+ 5 - 9
toolset/benchmark/framework_test.py

@@ -21,16 +21,10 @@ from threading import Event
 from utils import header
 
 class FrameworkTest:
-  ##########################################################################################
-  # Class variables
-  ##########################################################################################
   headers_template = "-H 'Host: localhost' -H '{accept}' -H 'Connection: keep-alive'"
-  headers_full_template = "-H 'Host: localhost' -H '{accept}' -H 'Accept-Language: en-US,en;q=0.5' -H 'User-Agent: Mozilla/5.0 (X11; Linux x86_64) Gecko/20130501 Firefox/30.0 AppleWebKit/600.00 Chrome/30.0.0000.0 Trident/10.0 Safari/600.00' -H 'Cookie: uid=12345678901234567890; __utma=1.1234567890.1234567890.1234567890.1234567890.12; wd=2560x1600' -H 'Connection: keep-alive'"
  
-  accept_json = "Accept: application/json,text/html;q=0.9,application/xhtml+xml;q=0.9,application/xml;q=0.8,*/*;q=0.7"
-  accept_html = "Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"
-  accept_plaintext = "Accept: text/plain,text/html;q=0.9,application/xhtml+xml;q=0.9,application/xml;q=0.8,*/*;q=0.7"
-
+  # Used for test types that do not require a database - 
+  # These tests are run at multiple concurrency levels
   concurrency_template = """
     
     echo ""
@@ -73,7 +67,9 @@ class FrameworkTest:
       sleep 2
     done
   """
-
+  # Used for test types that require a database - 
+  # These tests run at a static concurrency level and vary the size of
+  # the query sent with each request
   query_template = """
     
     echo ""

+ 13 - 6
toolset/benchmark/test_types/framework_test_type.py

@@ -19,12 +19,19 @@ class FrameworkTestType:
   exist a member `X.spam = 'foobar'`. 
   '''
 
-  def __init__(self, name, requires_db = False, args = []):
+  accept_json = "Accept: application/json,text/html;q=0.9,application/xhtml+xml;q=0.9,application/xml;q=0.8,*/*;q=0.7"
+  accept_html = "Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"
+  accept_plaintext = "Accept: text/plain,text/html;q=0.9,application/xhtml+xml;q=0.9,application/xml;q=0.8,*/*;q=0.7"
+
+  def __init__(self, name, requires_db = False, accept_header = None, args = []):
     self.name = name
     self.requires_db = requires_db
     self.args = args
     self.out = [] # You can use [sys.stdout] to tee
     self.err = [] # [sys.stderr]
+    self.accept_header = accept_header
+    if accept_header is None:
+      self.accept_header = self.accept_plaintext
 
     self.passed = None
     self.failed = None
@@ -134,25 +141,25 @@ class JsonTestType(FrameworkTestType):
 class DBTestType(FrameworkTestType):
   def __init__(self):
     args = ['db_url']
-    FrameworkTestType.__init__(self, 'db', True, args)
+    FrameworkTestType.__init__(self, name='db', requires_db=True, args=args)
 
 class QueryTestType(FrameworkTestType):
   def __init__(self):
     args = ['query_url']
-    FrameworkTestType.__init__(self, 'query', True, args)
+    FrameworkTestType.__init__(self, name='query', requires_db=True, args=args)
 
 
 class FortuneTestType(FrameworkTestType):
   def __init__(self):
     args = ['fortune_url']
-    FrameworkTestType.__init__(self, 'fortune', True, args)
+    FrameworkTestType.__init__(self, name='fortune', requires_db=True, args=args)
 
 class UpdateTestType(FrameworkTestType):
   def __init__(self):
     args = ['update_url']
-    FrameworkTestType.__init__(self, 'update', True, args)
+    FrameworkTestType.__init__(self, name='update', requires_db=True, args=args)
 
 class PlaintextTestType(FrameworkTestType):
   def __init__(self):
     args = ['plaintext_url']
-    FrameworkTestType.__init__(self, 'plaintext', False, args)
+    FrameworkTestType.__init__(self, name='plaintext', requires_db=False, args=args)