Ver código fonte

Add date check je (#4452)

* added Python vibora -- certain issues with the framework only allow for 3 tests currently

* changed updateworld to fetch a random world before updating it

* fixed update routes for all perfect permutations with updates

* WIP

* WIP

* WIP Dockerfile

* upgraded rust version and imported serde as the github said to

* removed muffin

* pippo json and plaintext

* added a 15 second delta to check for cached dates

* removed pippo entry

* added date check using sleep and a second request

* removed unnecessary import
jenriquez-techempower 6 anos atrás
pai
commit
cb6f62fff2

+ 1 - 1
toolset/benchmark/test_types/db_type.py

@@ -50,7 +50,7 @@ class DBTestType(FrameworkTestType):
 
         # Verify response content
         problems += verify_randomnumber_object(response, url)
-        problems += verify_headers(headers, url, should_be='json')
+        problems += verify_headers(self.request_headers_and_body, headers, url, should_be='json')
 
         if len(problems) == 0:
             return [('pass', '', url)]

+ 1 - 1
toolset/benchmark/test_types/fortune_type.py

@@ -37,7 +37,7 @@ class FortuneTestType(FrameworkTestType):
         (valid, diff) = parser.isValidFortune(self.name, body)
 
         if valid:
-            problems += verify_headers(headers, url, should_be='html')
+            problems += verify_headers(self.request_headers_and_body, headers, url, should_be='html')
 
             if len(problems) == 0:
                 return [('pass', '', url)]

+ 1 - 1
toolset/benchmark/test_types/json_type.py

@@ -32,7 +32,7 @@ class JsonTestType(FrameworkTestType):
             return problems
 
         problems += verify_helloworld_object(response, url)
-        problems += verify_headers(headers, url, should_be='json')
+        problems += verify_headers(self.request_headers_and_body, headers, url, should_be='json')
 
         if len(problems) > 0:
             return problems

+ 2 - 1
toolset/benchmark/test_types/plaintext_type.py

@@ -1,5 +1,6 @@
 from toolset.benchmark.test_types.framework_test_type import FrameworkTestType
 from toolset.benchmark.test_types.verifications import basic_body_verification, verify_headers
+from time import sleep
 
 
 class PlaintextTestType(FrameworkTestType):
@@ -38,7 +39,7 @@ class PlaintextTestType(FrameworkTestType):
                   "This may negatively affect benchmark performance." %
                   extra_bytes), url))
 
-        problems += verify_headers(headers, url, should_be='plaintext')
+        problems += verify_headers(self.request_headers_and_body, headers, url, should_be='plaintext')
 
         if len(problems) == 0:
             return [('pass', '', url)]

+ 17 - 4
toolset/benchmark/test_types/verifications.py

@@ -4,7 +4,7 @@ import traceback
 
 from datetime import datetime
 from toolset.utils.output_helper import log
-
+from time import sleep
 
 def basic_body_verification(body, url, is_json_check=True):
     '''
@@ -36,7 +36,7 @@ def basic_body_verification(body, url, is_json_check=True):
     return None, []
 
 
-def verify_headers(headers, url, should_be='json'):
+def verify_headers(request_headers_and_body, headers, url, should_be='json'):
     '''
     Verifies the headers of a framework response
     param `should_be` is a switch for the three acceptable content types
@@ -67,6 +67,19 @@ def verify_headers(headers, url, should_be='json'):
                 'Invalid Date header, found \"%s\", did not match \"%s\".'
                 % (date, expected_date_format), url))
 
+    # Verify response content
+    # Make sure that the date object isn't cached
+    sleep(3)
+    second_headers, body2 = request_headers_and_body(url)
+    second_date = second_headers.get('Date')
+
+    date2 = second_headers.get('Date')
+    if date == date2:
+        problems.append((
+        'fail',
+        'Invalid Cached Date. Found \"%s\" and \"%s\" on separate requests.'
+        % (date, date2), url))
+
     content_type = headers.get('Content-Type')
     if content_type is not None:
         types = {
@@ -338,7 +351,7 @@ def verify_query_cases(self, cases, url, check_updates=False):
 
             problems += verify_randomnumber_list(expected_len, headers, body,
                                                  case_url, max_infraction)
-            problems += verify_headers(headers, case_url)
+            problems += verify_headers(self.request_headers_and_body, headers, case_url)
 
             # Only check update changes if we are doing an Update verification and if we're testing
             # the highest number of queries, to ensure that we don't accidentally FAIL for a query
@@ -368,6 +381,6 @@ def verify_query_cases(self, cases, url, check_updates=False):
                 # parameter input
                 problems += verify_randomnumber_list(
                     expected_len, headers, body, case_url, max_infraction)
-                problems += verify_headers(headers, case_url)
+                problems += verify_headers(self.request_headers_and_body, headers, case_url)
 
     return problems