You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@trafficserver.apache.org by GitBox <gi...@apache.org> on 2023/01/02 16:09:16 UTC

[GitHub] [trafficserver] bneradt commented on a diff in pull request #9238: Add slice config to strip Range header for HEAD requests

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


##########
tests/gold_tests/pluginTest/slice/slice_rm_range.test.py:
##########
@@ -0,0 +1,70 @@
+'''
+Verify ATS slice plugin config: @pparam=--strip-range-for-head
+'''
+#  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 = '''
+Verify ATS slice plugin config: @pparam=--strip-range-for-head
+'''
+Test.SkipUnless(
+    Condition.PluginExists('slice.so'),
+    Condition.PluginExists('cache_range_requests.so'),
+)
+
+
+class SliceStripRangeForHeadRequestTest:
+    replay_file = "replay/slice_range.replay.yaml"
+
+    def __init__(self):
+        """Initialize the Test processes for the test runs."""
+        self._server = Test.MakeVerifierServerProcess("server", SliceStripRangeForHeadRequestTest.replay_file)
+        self._configure_trafficserver()
+
+    def _configure_trafficserver(self):
+        """Configure Traffic Server."""
+        self._ts = Test.MakeATSProcess("ts", enable_cache=False)
+
+        self._ts.Disk.remap_config.AddLines([
+            f"map /no/range http://127.0.0.1:{self._server.Variables.http_port} \
+                @plugin=slice.so @pparam=--blockbytes-test=10 @pparam=--strip-range-for-head \
+                @plugin=cache_range_requests.so",
+            f"map /with/range http://127.0.0.1:{self._server.Variables.http_port} \
+                @plugin=slice.so @pparam=--blockbytes-test=10 \
+                @plugin=cache_range_requests.so",
+        ])
+
+        self._ts.Disk.records_config.update({
+            'proxy.config.diags.debug.enabled': 1,
+            'proxy.config.diags.debug.tags': 'http|slice',

Review Comment:
   Let's put the cache_range_requests tag in here too.



##########
tests/gold_tests/pluginTest/slice/replay/slice_range.replay.yaml:
##########
@@ -0,0 +1,82 @@
+#  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.
+
+meta:
+  version: "1.0"
+
+sessions:
+- transactions:
+  - client-request:
+      method: "HEAD"
+      version: "1.1"
+      url: /no/range
+      headers:
+        fields:
+        - [ Host, example.com ]
+        - [ X-Request, request ]
+        - [ Range, bytes=0-5 ]
+        - [ uuid, 1 ]
+
+    proxy-request:
+      headers:
+        fields:
+        - [ Range, { as: absent } ]
+
+    server-response:
+      status: 200
+      reason: OK
+      headers:
+        fields:
+        - [ Content-Length, 16 ]
+        - [ X-Response, response ]
+
+    proxy-response:
+      status: 200
+      headers:
+        fields:
+        - [ X-Response, { value: response, as: equal } ]
+        - [ Content-Length, 16 ]
+
+  - client-request:
+      method: "HEAD"
+      version: "1.1"
+      url: /with/range
+      headers:
+        fields:
+        - [ Host, example.com ]
+        - [ X-Request, request ]
+        - [ Range, bytes=0-5 ]
+        - [ uuid, 2 ]
+
+    proxy-request:
+      headers:
+        fields:
+        - [ Range, { as: present } ]
+
+    server-response:
+      status: 206
+      headers:
+        fields:
+        - [ Content-Length, 6 ]
+        - [ X-Response, response ]
+        - [ Content-Range, bytes 0-5/16 ]
+
+    proxy-response:
+      status: 206
+      headers:
+        fields:
+        - [ Content-Length, 6 ]

Review Comment:
   Do we expect this to have a Content-Length header? Proxy Verifier does support proxy-request and proxy-response headers:fields nodes without verification directives, but those are generally useful for something like the traffic_dump plugin which records in real-time what those header fields were at the time the replay files were recorded. In those instances, they are not helpful for replay, per se, but are helpful for someone reading the file to see what headers the proxy actually sent (either toward the origin or toward the client). For an AuTest, proxy-* header fields will almost always have verification directives with them, and will simply be absent for the headers we don't care about verifying (usually Date, Via, etc.).
   
   That said, we likely do want to verify Content-Range?



-- 
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: github-unsubscribe@trafficserver.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org