bneradt commented on code in PR #13238:
URL: https://github.com/apache/trafficserver/pull/13238#discussion_r3374201983


##########
tests/gold_tests/pluginTest/prefetch/prefetch_no_cachekey.test.py:
##########
@@ -0,0 +1,76 @@
+'''
+'''
+#  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.
+
+Test.Summary = '''
+Test prefetch.so plugin without cachekey.so loaded ahead of it. Exercises the
+path where TSHttpTxnCacheLookupUrlGet must be served by the core's own cache
+lookup URL initialization rather than a prior plugin's 
TSHttpTxnCacheLookupUrlSet.
+'''
+
+server = Test.MakeOriginServer("server")
+for i in list(range(1, 1 + 3)):
+    request_header = {
+        "headers":
+            f"GET /texts/demo-{i}.txt HTTP/1.1\r\n"
+            "Host: does.not.matter\r\n"  # But cannot be omitted.
+            "\r\n",
+        "timestamp": "1469733493.993",
+        "body": ""
+    }
+    response_header = {
+        "headers": "HTTP/1.1 200 OK\r\n"
+                   "Connection: close\r\n"
+                   "Cache-control: max-age=85000\r\n"
+                   "\r\n",
+        "timestamp": "1469733493.993",
+        "body": f"This is the body for demo-{i}.txt.\n"
+    }
+    server.addResponse("sessionlog.json", request_header, response_header)
+
+dns = Test.MakeDNServer("dns")
+
+ts = Test.MakeATSProcess("ts")
+ts.Disk.records_config.update(
+    {
+        'proxy.config.diags.debug.enabled': 1,
+        'proxy.config.diags.debug.tags': 'http|dns|prefetch',
+        'proxy.config.dns.nameservers': f"127.0.0.1:{dns.Variables.Port}",
+        'proxy.config.dns.resolv_conf': "NULL",
+    })
+ts.Disk.remap_config.AddLine(
+    f"map http://domain.in http://127.0.0.1:{server.Variables.Port}"; + " 
@plugin=prefetch.so" + " @pparam=--front=true" +
+    " @pparam=--fetch-policy=simple" + r" 
@pparam=--fetch-path-pattern=/(.*-)(\d+)(.*)/$1{$2+1}$3/" + " 
@pparam=--fetch-count=3")
+ts.ReturnCode = Any(0, -2)
+
+tr = Test.AddTestRun()
+tr.Processes.Default.StartBefore(server)
+tr.Processes.Default.StartBefore(dns)
+tr.Processes.Default.StartBefore(ts)
+tr.Processes.Default.Command = 'echo start TS, HTTP server and DNS.'
+tr.Processes.Default.ReturnCode = 0
+
+tr = Test.AddTestRun()
+tr.MakeCurlCommand(f'--verbose --proxy 127.0.0.1:{ts.Variables.port} 
http://domain.in/texts/demo-1.txt', ts=ts)
+tr.Processes.Default.ReturnCode = 0
+
+Test.AddAwaitFileContainsTestRun('Await transactions to finish logging.', 
ts.Disk.traffic_out.Name, 'demo-4.txt')
+
+tr = Test.AddTestRun()
+tr.Processes.Default.Command = (f"grep 'GET http://' 
{ts.Disk.traffic_out.Name} | grep -v '127.0.0.1'")
+tr.Streams.stdout = "prefetch_simple.gold"
+tr.Processes.Default.ReturnCode = 0

Review Comment:
   Does this really verify that no prefetching is done by the plugin? Maybe it 
is and I'm missing that. That's the intention of this patch, so we want to make 
sure the test is verifying that.



-- 
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