Mailing List Archive

[6848] cherokee/trunk/qa: Front-Line Cache related QA tests could not be run neither more
Revision: 6848
http://svn.cherokee-project.com/changeset/6848
Author: alo
Date: 2011-09-14 21:29:48 +0200 (Wed, 14 Sep 2011)
Log Message:
-----------
Front-Line Cache related QA tests could not be run neither more
than once in the same session nor in parallel by multiple threads.
This patch works out those QA tests so they behave like any other
QA test of the bench.

Modified Paths:
--------------
cherokee/trunk/qa/275-Flcache-basic1.py
cherokee/trunk/qa/277-Flcache-cookie2.py
cherokee/trunk/qa/280-Flcache-gzip1.py
cherokee/trunk/qa/283-Flcache-expired3.py
cherokee/trunk/qa/285-Flcache-overwrite.py
cherokee/trunk/qa/base.py

Modified: cherokee/trunk/qa/275-Flcache-basic1.py
===================================================================
--- cherokee/trunk/qa/275-Flcache-basic1.py 2011-09-14 12:02:01 UTC (rev 6847)
+++ cherokee/trunk/qa/275-Flcache-basic1.py 2011-09-14 19:29:48 UTC (rev 6848)
@@ -1,7 +1,7 @@
+import itertools
from base import *

DIR = "flcache-basic1"
-FILE = "file.txt"
CONTENT = "Front-line cache boosts Cherokee performance"

CONF = """
@@ -14,14 +14,16 @@


class TestEntry (TestBase):
- def __init__ (self):
+ def __init__ (self, filename):
TestBase.__init__ (self, __file__)
- self.request = "GET /%s/%s HTTP/1.0\r\n" %(DIR, FILE) +\
+ self.request = "GET /%s/%s HTTP/1.0\r\n" %(DIR, filename) +\
"Connection: close\r\n"
self.expected_error = 200


class Test (TestCollection):
+ counter = itertools.count()
+
def __init__ (self):
TestCollection.__init__ (self, __file__)

@@ -30,14 +32,28 @@
self.proxy_suitable = True
self.delay = 1

- def Prepare (self, www):
- d = self.Mkdir (www, DIR)
- self.WriteFile (d, FILE, 0444, CONTENT)
+ def JustBefore (self, www):
+ test_num = Test.counter.next()
+ self.filename = "test275-id%s-test%s" %(id(self), test_num)

- # First request
- obj = self.Add (TestEntry())
+ # Write the new file
+ self.WriteFile (self.local_dir, self.filename, 0444, CONTENT)
+
+ # Create sub-request objects
+ self.Empty()
+
+ obj = self.Add (TestEntry (self.filename))
obj.expected_content = ['X-Cache: MISS', CONTENT]

- # Second request
- obj = self.Add (TestEntry())
+ obj = self.Add (TestEntry (self.filename))
obj.expected_content = ['X-Cache: HIT', CONTENT]
+
+ def JustAfter (self, www):
+ # Clean up the local file
+ fp = os.path.join (self.local_dir, self.filename)
+ os.unlink (fp)
+ self.filename = None
+
+ def Prepare (self, www):
+ # Create the directory
+ self.local_dir = self.Mkdir (www, DIR)

Modified: cherokee/trunk/qa/277-Flcache-cookie2.py
===================================================================
--- cherokee/trunk/qa/277-Flcache-cookie2.py 2011-09-14 12:02:01 UTC (rev 6847)
+++ cherokee/trunk/qa/277-Flcache-cookie2.py 2011-09-14 19:29:48 UTC (rev 6848)
@@ -1,7 +1,7 @@
+import itertools
from base import *

DIR = "flcache-cookie2"
-FILE = "test.cgi"
CONTENT = "Front-line can cache responses setting 'diregarded cookies'"

CONF = """
@@ -28,14 +28,16 @@


class TestEntry (TestBase):
- def __init__ (self):
+ def __init__ (self, filename):
TestBase.__init__ (self, __file__)
- self.request = "GET /%s/%s HTTP/1.0\r\n" %(DIR, FILE) +\
+ self.request = "GET /%s/%s HTTP/1.0\r\n" %(DIR, filename) +\
"Connection: close\r\n"
self.expected_error = 200


class Test (TestCollection):
+ counter = itertools.count()
+
def __init__ (self):
TestCollection.__init__ (self, __file__)

@@ -44,14 +46,28 @@
self.proxy_suitable = True
self.delay = 1

- def Prepare (self, www):
- d = self.Mkdir (www, DIR)
- self.WriteFile (d, FILE, 0755, CGI_CODE)

- # First request
- obj = self.Add (TestEntry())
+ def JustBefore (self, www):
+ test_num = Test.counter.next()
+ self.filename = "test277-id%s-test%s" %(id(self), test_num)
+
+ # Write the new file
+ self.WriteFile (self.local_dir, self.filename, 0755, CGI_CODE)
+
+ # Create sub-request objects
+ self.Empty()
+
+ obj = self.Add (TestEntry (self.filename))
obj.expected_content = ['X-Cache: MISS', CONTENT]

- # Second request
- obj = self.Add (TestEntry())
+ obj = self.Add (TestEntry (self.filename))
obj.expected_content = ['X-Cache: HIT', CONTENT]
+
+ def JustAfter (self, www):
+ # Clean up the local file
+ fp = os.path.join (self.local_dir, self.filename)
+ os.unlink (fp)
+ self.filename = None
+
+ def Prepare (self, www):
+ self.local_dir = self.Mkdir (www, DIR)

Modified: cherokee/trunk/qa/280-Flcache-gzip1.py
===================================================================
--- cherokee/trunk/qa/280-Flcache-gzip1.py 2011-09-14 12:02:01 UTC (rev 6847)
+++ cherokee/trunk/qa/280-Flcache-gzip1.py 2011-09-14 19:29:48 UTC (rev 6848)
@@ -1,8 +1,8 @@
import types
+import itertools
from base import *

DIR = "flcache-gzip1"
-FILE = "test.cgi"
CONTENT = "Front-line supports encoded and non-encoded content"
GZIP_HEADER = "\037\213"

@@ -17,9 +17,9 @@


class TestEntry (TestBase):
- def __init__ (self, use_gzip):
+ def __init__ (self, filename, use_gzip):
TestBase.__init__ (self, __file__)
- self.request = "GET /%s/%s HTTP/1.0\r\n" %(DIR, FILE) +\
+ self.request = "GET /%s/%s HTTP/1.0\r\n" %(DIR, filename) +\
"Connection: close\r\n"
if use_gzip:
self.request += "Accept-Encoding: gzip\r\n"
@@ -28,6 +28,8 @@


class Test (TestCollection):
+ counter = itertools.count()
+
def __init__ (self):
TestCollection.__init__ (self, __file__)

@@ -36,26 +38,41 @@
self.proxy_suitable = True
self.delay = 1

- def Prepare (self, www):
- d = self.Mkdir (www, DIR)
- self.WriteFile (d, FILE, 0444, CONTENT)
+ def JustBefore (self, www):
+ test_num = Test.counter.next()
+ self.filename = "test280-id%s-test%s" %(id(self), test_num)

+ # Write the new file
+ self.WriteFile (self.local_dir, self.filename, 0444, CONTENT)
+
+ # Create sub-request objects
+ self.Empty()
+
# GZip (miss)
- obj = self.Add (TestEntry(True))
+ obj = self.Add (TestEntry (self.filename, True))
obj.forbidden_content = [CONTENT]
obj.expected_content = [GZIP_HEADER, "X-Cache: MISS"]

# No-GZip (miss)
- obj = self.Add (TestEntry(False))
+ obj = self.Add (TestEntry (self.filename, False))
obj.expected_content = [CONTENT, "X-Cache: MISS"]
obj.forbidden_content = [GZIP_HEADER]

# GZip (hit)
- obj = self.Add (TestEntry(True))
+ obj = self.Add (TestEntry (self.filename, True))
obj.forbidden_content = [CONTENT]
obj.expected_content = [GZIP_HEADER, "X-Cache: HIT"]

# No-GZip (hit)
- obj = self.Add (TestEntry(False))
+ obj = self.Add (TestEntry (self.filename, False))
obj.expected_content = [CONTENT, "X-Cache: HIT"]
obj.forbidden_content = [GZIP_HEADER]
+
+ def JustAfter (self, www):
+ # Clean up the local file
+ fp = os.path.join (self.local_dir, self.filename)
+ os.unlink (fp)
+ self.filename = None
+
+ def Prepare (self, www):
+ self.local_dir = self.Mkdir (www, DIR)

Modified: cherokee/trunk/qa/283-Flcache-expired3.py
===================================================================
--- cherokee/trunk/qa/283-Flcache-expired3.py 2011-09-14 12:02:01 UTC (rev 6847)
+++ cherokee/trunk/qa/283-Flcache-expired3.py 2011-09-14 19:29:48 UTC (rev 6848)
@@ -1,9 +1,9 @@
import time
import types
+import itertools
from base import *

DIR = "flcache-expired3"
-FILE = "test.cgi"
CONTENT = "Front-line checks back-end 'Expires' header"

CONF = """
@@ -27,14 +27,16 @@


class TestEntry (TestBase):
- def __init__ (self):
+ def __init__ (self, filename):
TestBase.__init__ (self, __file__)
- self.request = "GET /%s/%s HTTP/1.0\r\n" %(DIR, FILE) +\
+ self.request = "GET /%s/%s HTTP/1.0\r\n" %(DIR, filename) +\
"Connection: close\r\n"
self.expected_error = 200


class Test (TestCollection):
+ counter = itertools.count()
+
def __init__ (self):
TestCollection.__init__ (self, __file__)

@@ -44,13 +46,28 @@
self.delay = 1

def Prepare (self, www):
- d = self.Mkdir (www, DIR)
- self.WriteFile (d, FILE, 0755, CGI_CODE)
+ self.local_dir = self.Mkdir (www, DIR)

+ def JustBefore (self, www):
+ test_num = Test.counter.next()
+ self.filename = "test283-id%s-test%s" %(id(self), test_num)
+
+ # Write the new file
+ self.WriteFile (self.local_dir, self.filename, 0755, CGI_CODE)
+
+ # Create sub-request objects
+ self.Empty()
+
# Miss
- obj = self.Add (TestEntry())
+ obj = self.Add (TestEntry (self.filename))
obj.expected_content = [CONTENT, "X-Cache: MISS"]

# Miss
- obj = self.Add (TestEntry())
+ obj = self.Add (TestEntry (self.filename))
obj.expected_content = [CONTENT, "X-Cache: HIT"]
+
+ def JustAfter (self, www):
+ # Clean up the local file
+ fp = os.path.join (self.local_dir, self.filename)
+ os.unlink (fp)
+ self.filename = None

Modified: cherokee/trunk/qa/285-Flcache-overwrite.py
===================================================================
--- cherokee/trunk/qa/285-Flcache-overwrite.py 2011-09-14 12:02:01 UTC (rev 6847)
+++ cherokee/trunk/qa/285-Flcache-overwrite.py 2011-09-14 19:29:48 UTC (rev 6848)
@@ -1,7 +1,7 @@
+import itertools
from base import *

DIR = "flcache-replace1"
-FILE = "file.txt"
CONTENT = "Front-line cache boosts Cherokee performance"

CONF = """
@@ -26,14 +26,16 @@


class TestEntry (TestBase):
- def __init__ (self):
+ def __init__ (self, filename):
TestBase.__init__ (self, __file__)
- self.request = "GET /%s/%s HTTP/1.0\r\n" %(DIR, FILE) +\
+ self.request = "GET /%s/%s HTTP/1.0\r\n" %(DIR, filename) +\
"Connection: close\r\n"
self.expected_error = 200


class Test (TestCollection):
+ counter = itertools.count()
+
def __init__ (self):
TestCollection.__init__ (self, __file__)

@@ -42,16 +44,31 @@
self.proxy_suitable = True
self.delay = 1

- def Prepare (self, www):
- d = self.Mkdir (www, DIR)
- self.WriteFile (d, FILE, 0755, CGI_CODE)
+ def JustBefore (self, www):
+ test_num = Test.counter.next()
+ self.filename = "test275-id%s-test%s" %(id(self), test_num)

+ # Write the new file
+ self.WriteFile (self.local_dir, self.filename, 0755, CGI_CODE)
+
+ # Create sub-request objects
+ self.Empty()
+
# First request
- obj = self.Add (TestEntry())
+ obj = self.Add (TestEntry (self.filename))
obj.expected_content = ['X-Cache: MISS', CONTENT, "public"]
obj.forbidden_content = ['no-store', 'no-cache']

# Second request
- obj = self.Add (TestEntry())
+ obj = self.Add (TestEntry (self.filename))
obj.expected_content = ['X-Cache: HIT', CONTENT, "public"]
obj.forbidden_content = ['no-store', 'no-cache']
+
+ def JustAfter (self, www):
+ # Clean up the local file
+ fp = os.path.join (self.local_dir, self.filename)
+ os.unlink (fp)
+ self.filename = None
+
+ def Prepare (self, www):
+ self.local_dir = self.Mkdir (www, DIR)

Modified: cherokee/trunk/qa/base.py
===================================================================
--- cherokee/trunk/qa/base.py 2011-09-14 12:02:01 UTC (rev 6847)
+++ cherokee/trunk/qa/base.py 2011-09-14 19:29:48 UTC (rev 6848)
@@ -413,6 +413,10 @@
self.tests.append (test)
return test

+ def Empty (self):
+ self.tests = []
+ self.num = 0
+
def Clean (self):
for t in self.tests:
self.current_test = t