bneradt commented on a change in pull request #8248:
URL: https://github.com/apache/trafficserver/pull/8248#discussion_r702168483



##########
File path: tests/gold_tests/proxy_protocol/proxy_serve_stale.test.py
##########
@@ -0,0 +1,106 @@
+'''
+Test child proxy serving stale content when parents are exhausted
+'''
+#  Licensed to the Apache Software Foundation (ASF) under one
+#  or more contributor license agreements.  See the NOTICE file
+#  distributed with this work for additional information
+#  regarding copyright ownership.  The ASF licenses this file
+#  to you under the Apache License, Version 2.0 (the
+#  "License"); you may not use this file except in compliance
+#  with the License.  You may obtain a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+#  Unless required by applicable law or agreed to in writing, software
+#  distributed under the License is distributed on an "AS IS" BASIS,
+#  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+#  See the License for the specific language governing permissions and
+#  limitations under the License.
+
+
+def setPid(event):
+    Test.Env['SERVERPID'] = str(event.object.pid())
+
+
+Test.ContinueOnFail = True
+# Set up hierarchical caching processes
+ts_child = Test.MakeATSProcess("ts_child")
+ts_parent = Test.MakeATSProcess("ts_parent")
+server = Test.MakeOriginServer("server")
+ts_parent.RunningEvent.Connect(setPid)
+
+Test.testName = "STALE"
+
+# Request from client
+request_header = {"headers":
+                  "GET / HTTP/1.1\r\nHost: localhost\r\n\r\n",
+                  "timestamp": "1469733493.993",
+                  "body": ""}
+# Expected response from the origin server
+response_header = {"headers":
+                   "HTTP/1.1 200 OK\r\nConnection: close\r\nCache-Control: 
max-age=10,public\r\n\r\n",
+                   "timestamp": "1469733493.993",
+                   "body": "CACHED"}
+
+# add request/response
+server.addResponse("sessionlog.log", request_header, response_header)
+
+# Config child proxy to route to parent proxy
+ts_child.Disk.records_config.update({
+    'proxy.config.diags.debug.enabled': 1,
+    'proxy.config.diags.debug.tags': 'http|remap|parent|host',
+    'proxy.config.http.cache.max_stale_age': 20,
+})
+ts_child.Disk.parent_config.AddLine(
+    'dest_domain=. parent="localhost:{0}" round_robin=consistent_hash 
go_direct=false'.format(ts_parent.Variables.port)
+)
+ts_child.Disk.remap_config.AddLine(
+    'map http://localhost:{0} 
http://localhost:{1}'.format(ts_child.Variables.port, server.Variables.Port)
+)
+
+# Config parent proxy to route to server
+ts_parent.Disk.records_config.update({
+    'proxy.config.diags.debug.enabled': 1,
+    'proxy.config.diags.debug.tags': 'http|remap|parent',
+    'proxy.config.http.cache.max_stale_age': 20,
+})
+ts_parent.Disk.remap_config.AddLine(
+    'map / http://127.0.0.1:{0}'.format(server.Variables.Port)
+)
+ts_parent.Disk.remap_config.AddLine(
+    'map http://localhost:{0} 
http://localhost:{0}'.format(server.Variables.Port)
+)
+
+# Request content to cache in parent proxy
+curl_request_running = (
+    'curl -s -v http://localhost:{0};'  # miss

Review comment:
       I agree that it would be best to avoid sleeps as a synchronization 
mechanism.
   
   As Jason suggests, some of the logging AuTests await upon log file entries. 
log-field.test.py has a conditional TestRun that awaits an entry to populate 
the customized log file:
   
https://github.com/apache/trafficserver/blob/5c75a3052e1022662f06ea2b7d8139bb01e32f9b/tests/gold_tests/logging/log-field.test.py#L105
   
   Can something like that be used? You would create a dedicated TestRun that 
awaits the log entry. A similar thing can be done for diags.log entries.
   
   In theory, debug output can be awaited upon as well. We usually let the ATS 
process write to stdout/stderr and then use the AuTest stream mechanism for 
test conditions (ContainsExpression, ExcludesExpression). However that cannot 
be waited upon since it is in memory until the process finishes. We can, 
however, use the `--bind_stdout` and `--bind_stderr` traffic_server arguments 
and wait upon the specified file. That should be easy to do, but we don't have 
an example of that. (If this is done, make sure the file you specify is to the 
RunDirectory which will be in the sandbox.)
   
   Thanks for contributing tests to ATS.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to