This is an automated email from the ASF dual-hosted git repository.

zwoop pushed a commit to branch 9.0.x
in repository https://gitbox.apache.org/repos/asf/trafficserver.git


The following commit(s) were added to refs/heads/9.0.x by this push:
     new 09a1738  Make all_headers test more resilient to timimng
09a1738 is described below

commit 09a17385a81b8bfe0d512abd80e3c83d0fd79503
Author: Susan Hinrichs <shinr...@verizonmedia.com>
AuthorDate: Mon Mar 9 15:20:18 2020 +0000

    Make all_headers test more resilient to timimng
    
    (cherry picked from commit 4f0a6be7fd38a09eb407fd872f6a492fbfcbef3f)
---
 tests/gold_tests/logging/all_headers.test.py      |  3 +--
 tests/gold_tests/logging/all_headers_sanitizer.py | 26 +++++++++++++++++------
 2 files changed, 21 insertions(+), 8 deletions(-)

diff --git a/tests/gold_tests/logging/all_headers.test.py 
b/tests/gold_tests/logging/all_headers.test.py
index 12b81f0..7e0f47e 100644
--- a/tests/gold_tests/logging/all_headers.test.py
+++ b/tests/gold_tests/logging/all_headers.test.py
@@ -96,8 +96,7 @@ tr.Processes.Default.ReturnCode = 0
 # Delay to allow TS to flush report to disk, then "sanitize" generated log.
 #
 tr = Test.AddTestRun()
-tr.DelayStart = 10
-tr.Processes.Default.Command = 'python3 {0} {4} < {2} | sh {1} > {3}'.format(
+tr.Processes.Default.Command = 'python3 {0} {2} {4} | sh {1} > {3}'.format(
     os.path.join(Test.TestDirectory, 'all_headers_sanitizer.py'),
     os.path.join(Test.TestDirectory, 'all_headers_sanitizer.sh'),
     os.path.join(ts.Variables.LOGDIR, 'test_all_headers.log'),
diff --git a/tests/gold_tests/logging/all_headers_sanitizer.py 
b/tests/gold_tests/logging/all_headers_sanitizer.py
index 2206b5e..64c22fd 100644
--- a/tests/gold_tests/logging/all_headers_sanitizer.py
+++ b/tests/gold_tests/logging/all_headers_sanitizer.py
@@ -19,6 +19,8 @@ Sanitize the ATS-generated custom log file from the 
all_headers test.
 
 import sys
 import re
+from os import path
+import time
 
 rexl = []
 rexl.append((re.compile(r"\{\{Date\}\:\{[^}]*\}\}"), "({__DATE__}}"))
@@ -29,15 +31,27 @@ rexl.append((re.compile(r"\{\{Server\}\:\{ECS [^}]*\}\}"), 
"({__ECS_SERVER__}}")
 rexl.append((re.compile(r"\{\{Via\}\:\{[^}]*\}\}"), "({__VIA__}}"))
 rexl.append((re.compile(r"\{\{Server\}\:\{ApacheTrafficServer/[0-9.]*\}\}"), 
"({__ATS2_SERVER__}}"))
 rexl.append((re.compile(r"\{\{Age\}\:\{[0-9]*\}\}"), "({__AGE__}}"))
-rexl.append((re.compile(r"\:" + sys.argv[1]), "__TS_PORT__")) # 1st and only 
argument is TS client port
+rexl.append((re.compile(r"\:" + sys.argv[2]), "__TS_PORT__")) # 1st and only 
argument is TS client port
 
 # Handle inconsistencies which I think are caused by different revisions of 
the standard Python http.server.HTTPServer class.
 
 rexl.append((re.compile(r'\{"359670651[^"]*"\}'), '{"{359670651__WEIRD__}"}'))
 rexl.append((re.compile(r'\{\{Accept-Ranges\}:\{bytes\}\}'), ''))
 
-for line in sys.stdin:
-    for rex, subStr in rexl:
-        line = rex.sub(subStr, line)
-
-    print(line)
+# Loop until the file specified in argv[1] becomes availble
+filename = sys.argv[1]
+processed = False
+# Give up looking for file after 2 minutes
+limit_count = 0
+limit_max = 120
+while not processed and limit_count < limit_max:
+  limit_count += 1
+  if not path.exists(filename):
+    time.sleep(1);
+  else:
+    with open(filename, "r") as f:
+      processed = True
+      for line in f:
+        for rex, subStr in rexl:
+          line = rex.sub(subStr, line)
+        print(line)

Reply via email to