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

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

commit 3e41224ba76fe0d9dd88d22c9b35c6c656b76ba4
Author: Walt Karas <[email protected]>
AuthorDate: Tue Apr 30 11:12:50 2024 -0400

    Add Au testing for statichit.so plugin. (#11293)
    
    (cherry picked from commit c8b6400a04e8b163191843173c6d9f028ae0bf09)
---
 tests/gold_tests/pluginTest/statichit/empty.txt    |   0
 .../gold_tests/pluginTest/statichit/small_body.txt |   1 +
 .../pluginTest/statichit/statichit.replay.yaml     | 168 +++++++++
 .../pluginTest/statichit/statichit.test.py         |  88 +++++
 .../gold_tests/pluginTest/statichit/story_16.json  | 395 +++++++++++++++++++++
 5 files changed, 652 insertions(+)

diff --git a/tests/gold_tests/pluginTest/statichit/empty.txt 
b/tests/gold_tests/pluginTest/statichit/empty.txt
new file mode 100644
index 0000000000..e69de29bb2
diff --git a/tests/gold_tests/pluginTest/statichit/small_body.txt 
b/tests/gold_tests/pluginTest/statichit/small_body.txt
new file mode 100644
index 0000000000..9858bc75e7
--- /dev/null
+++ b/tests/gold_tests/pluginTest/statichit/small_body.txt
@@ -0,0 +1 @@
+small body content
diff --git a/tests/gold_tests/pluginTest/statichit/statichit.replay.yaml 
b/tests/gold_tests/pluginTest/statichit/statichit.replay.yaml
new file mode 100644
index 0000000000..175435ae48
--- /dev/null
+++ b/tests/gold_tests/pluginTest/statichit/statichit.replay.yaml
@@ -0,0 +1,168 @@
+#  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.
+
+# This replay file tests the stale response plugin when no
+# --stale-while-revalidate-default and no --stale-if-error-default are
+# specified.
+
+sessions:
+
+- transactions:
+
+  - client-request:
+      method: GET
+      url: /
+      version: '1.1'
+      headers:
+        fields:
+        - [ Host, fqdn1 ]
+        - [ uuid, 1 ]
+
+    proxy-response:
+      status: 200
+      headers:
+        fields:
+        - [ Content-Length, { value: 19, as: equal } ]
+        - [ Cache-Control, { value: no-cache, as: equal } ]
+        - [ Content-Type, { value: text/plain, as: equal } ]
+        - [ Server, { value: ATS, as: contains } ]
+      content:
+        encoding: plain
+        data: |
+          small body content
+        verify: { as: equal }
+
+  - client-request:
+      method: GET
+      url: /path
+      version: '1.1'
+      headers:
+        fields:
+        - [ Host, fqdn1 ]
+        - [ uuid, 2 ]
+
+    proxy-response:
+      status: 404
+      headers:
+        fields:
+        - [ Cache-Control, { value: no-store, as: equal } ]
+        - [ Content-Type, { value: text/html, as: equal } ]
+        - [ Server, { value: ATS, as: contains } ]
+      content:
+        encoding: plain
+        data: Error
+        verify: { as: contains }
+
+  - client-request:
+      method: GET
+      url: /
+      version: '1.1'
+      headers:
+        fields:
+        - [ Host, fqdn2 ]
+        - [ uuid, 3 ]
+
+    proxy-response:
+      status: 200
+      headers:
+        fields:
+        - [ Content-Length, { value: 19, as: equal } ]
+        - [ Cache-Control, { value: max-age=123, as: equal } ]
+        - [ Content-Type, { value: text/plain, as: equal } ]
+        - [ Server, { value: ATS, as: contains } ]
+      content:
+        encoding: plain
+        data: |
+          small body content
+        verify: { as: equal }
+
+  - client-request:
+      method: GET
+      url: /path
+      version: '1.1'
+      headers:
+        fields:
+        - [ Host, fqdn3 ]
+        - [ uuid, 4 ]
+
+    proxy-response:
+      status: 200
+      headers:
+        fields:
+        - [ Content-Length, { value: 19, as: equal } ]
+        - [ Cache-Control, { value: no-cache, as: equal } ]
+        - [ Content-Type, { value: text/plain, as: equal } ]
+        - [ Server, { value: ATS, as: contains } ]
+      content:
+        encoding: plain
+        data: |
+          small body content
+        verify: { as: equal }
+
+  - client-request:
+      method: GET
+      url: /
+      version: '1.1'
+      headers:
+        fields:
+        - [ Host, fqdn4 ]
+        - [ uuid, 5 ]
+
+    proxy-response:
+      status: 412
+      headers:
+        fields:
+        - [ Server, { value: ATS, as: contains } ]
+
+  - client-request:
+      method: GET
+      url: /
+      version: '1.1'
+      headers:
+        fields:
+        - [ Host, fqdn5 ]
+        - [ uuid, 6 ]
+
+    proxy-response:
+      status: 200
+      headers:
+        fields:
+        - [ Content-Length, { value: 10917, as: equal } ]
+        - [ Cache-Control, { value: no-cache, as: equal } ]
+        - [ Content-Type, { value: application/json, as: equal } ]
+        - [ Server, { value: ATS, as: contains } ]
+      content:
+        encoding: plain
+        data: http://en.wikipedia.org/wiki/Main_Page
+        verify: { as: contains }
+
+  - client-request:
+      method: GET
+      url: /
+      version: '1.1'
+      headers:
+        fields:
+        - [ Host, fqdn6 ]
+        - [ uuid, 7 ]
+
+    proxy-response:
+      status: 200
+      headers:
+        fields:
+        - [ Content-Length, { value: 0, as: equal } ]
+        - [ Cache-Control, { value: no-cache, as: equal } ]
+        - [ Content-Type, { value: text/plain, as: equal } ]
+        - [ Server, { value: ATS, as: contains } ]
diff --git a/tests/gold_tests/pluginTest/statichit/statichit.test.py 
b/tests/gold_tests/pluginTest/statichit/statichit.test.py
new file mode 100644
index 0000000000..35552d9976
--- /dev/null
+++ b/tests/gold_tests/pluginTest/statichit/statichit.test.py
@@ -0,0 +1,88 @@
+'''
+Verify correct statichit plugin behavior
+'''
+#  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.
+
+import os
+
+Test.Summary = '''
+Verify correct statichit plugin behavior
+'''
+
+Test.SkipUnless(Condition.PluginExists('statichit.so'),)
+
+
+class RemapData:
+    """Data for each remap rule"""
+
+    @staticmethod
+    def setup():
+        Test.Setup.Copy('small_body.txt', Test.RunDirectory)
+        RemapData.small_body_path = os.path.join(Test.RunDirectory, 
'small_body.txt')
+
+        Test.Setup.Copy('story_16.json', Test.RunDirectory)
+        RemapData.json_body_path = os.path.join(Test.RunDirectory, 
'story_16.json')
+
+        Test.Setup.Copy('empty.txt', Test.RunDirectory)
+        RemapData.empty_body_path = os.path.join(Test.RunDirectory, 
'empty.txt')
+
+    def __init__(self, from_url, *args) -> None:
+        self.remap_from = from_url
+        self.plugin_args = args
+        self.body = RemapData.small_body_path
+
+    def bad_body(self):
+        self.body = 'invalid'
+        return self
+
+    def json_body(self):
+        self.body = RemapData.json_body_path
+        return self
+
+    def empty_body(self):
+        self.body = RemapData.empty_body_path
+        return self
+
+
+RemapData.setup()
+
+remap_data = [
+    RemapData('http://fqdn1'),
+    RemapData('http://fqdn2', 'max-age=123'),
+    RemapData('http://fqdn3', 'success-code=200', 'disable-exact', 
'failure-code=222'),
+    RemapData('http://fqdn4', 'success-code=200', 
'failure-code=412').bad_body(),
+    RemapData('http://fqdn5', 'success-code=200', 'failure-code=412', 
"mime-type=application/json").json_body(),
+    RemapData('http://fqdn6', 'success-code=200', 
'failure-code=222').empty_body()
+]
+
+ts = Test.MakeATSProcess('ts')
+
+ts.Disk.records_config.update({
+    "proxy.config.diags.debug.enabled": 1,
+    "proxy.config.diags.debug.tags": "statichit",
+})
+
+for d in remap_data:
+    arg_str = ''
+    for arg in d.plugin_args:
+        arg_str += ' @pparam=--' + arg
+    ts.Disk.remap_config.AddLine(f'map {d.remap_from} http://127.0.0.1/ 
@plugin=statichit.so @pparam=--file-path={d.body}{arg_str}')
+
+tr = Test.AddTestRun()
+p = tr.AddVerifierClientProcess('client', 'statichit.replay.yaml', 
http_ports=[ts.Variables.port], other_args='--thread-limit 1')
+p.StartBefore(ts)
+p.StillRunningAfter = ts
diff --git a/tests/gold_tests/pluginTest/statichit/story_16.json 
b/tests/gold_tests/pluginTest/statichit/story_16.json
new file mode 100644
index 0000000000..38e589636b
--- /dev/null
+++ b/tests/gold_tests/pluginTest/statichit/story_16.json
@@ -0,0 +1,395 @@
+{
+  "cases": [
+    {
+      "seqnum": 0,
+      "headers": [
+        {
+          ":method": "GET"
+        },
+        {
+          ":scheme": "http"
+        },
+        {
+          ":authority": "en.wikipedia.org"
+        },
+        {
+          ":path": "/"
+        },
+        {
+          "user-agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:16.0) 
Gecko/20100101 Firefox/16.0"
+        },
+        {
+          "accept": 
"text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"
+        },
+        {
+          "accept-language": "en-US,en;q=0.5"
+        },
+        {
+          "accept-encoding": "gzip, deflate"
+        },
+        {
+          "connection": "keep-alive"
+        },
+        {
+          "cookie": "centralnotice_bucket=1; 
clicktracking-session=eJko6IiUcEm69ehQfaakQlJfiLy9lShNP; 
mediaWiki.user.bucket%3Aext.articleFeedback-tracking=10%3Atrack; 
mediaWiki.user.id=EM83jsjaqPzIMLwBTiKF3aLiiTKeweez; 
mediaWiki.user.bucket%3Aext.articleFeedback-options=8%3Ashow"
+        }
+      ],
+      "wire": 
"8286418c2d4bf8375356590c35cf64df847abcd07f66a281b0dae053fad0321aa49d13fda992a49685340c8a6adca7e28102ef7da9677b8171707f6a62293a9d810020004015309ac2ca7f2c05c5c153b0497ca589d34d1f43aeba0c41a4c7a98f33a69a3fdf9a68fa1d75d0620d263d4c79a68fbed00177febe58f9fbed00177b518b2d4b70ddf45abefb4005db90408721eaa8a4498f5788ea52d6b0e83772ff60ff3d216a4d83a2a3a4c42c51da4ea54c01fb5094189d5360c9d4d54cb20a8418f5405cbd4ee64370260a5c7cb3ec9463ebb28cb29b3fa7e8dd3e9d7f6a52590c3e46ea65ed416c5e3b49d4a95
 [...]
+    },
+    {
+      "seqnum": 1,
+      "headers": [
+        {
+          ":method": "GET"
+        },
+        {
+          ":scheme": "http"
+        },
+        {
+          ":authority": "en.wikipedia.org"
+        },
+        {
+          ":path": "/wiki/Main_Page"
+        },
+        {
+          "user-agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:16.0) 
Gecko/20100101 Firefox/16.0"
+        },
+        {
+          "accept": 
"text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"
+        },
+        {
+          "accept-language": "en-US,en;q=0.5"
+        },
+        {
+          "accept-encoding": "gzip, deflate"
+        },
+        {
+          "connection": "keep-alive"
+        },
+        {
+          "cookie": "centralnotice_bucket=1; 
clicktracking-session=eJko6IiUcEm69ehQfaakQlJfiLy9lShNP; 
mediaWiki.user.bucket%3Aext.articleFeedback-tracking=10%3Atrack; 
mediaWiki.user.id=EM83jsjaqPzIMLwBTiKF3aLiiTKeweez; 
mediaWiki.user.bucket%3Aext.articleFeedback-options=8%3Ashow"
+        }
+      ],
+      "wire": "8286c3448b63c1ba998d0335516b1cc5c3c2c190c0bf"
+    },
+    {
+      "seqnum": 2,
+      "headers": [
+        {
+          ":method": "GET"
+        },
+        {
+          ":scheme": "http"
+        },
+        {
+          ":authority": "bits.wikimedia.org"
+        },
+        {
+          ":path": "/en.wikipedia.org/load.php"
+        },
+        {
+          "user-agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:16.0) 
Gecko/20100101 Firefox/16.0"
+        },
+        {
+          "accept": "text/css,*/*;q=0.1"
+        },
+        {
+          "accept-language": "en-US,en;q=0.5"
+        },
+        {
+          "accept-encoding": "gzip, deflate"
+        },
+        {
+          "connection": "keep-alive"
+        },
+        {
+          "referer": "http://en.wikipedia.org/wiki/Main_Page";
+        },
+        {
+          "if-modified-since": "Wed, 31 Oct 2012 17:52:04 GMT"
+        }
+      ],
+      "wire": 
"8286418d8cc942fe0dd4d496430d73d937449360b52fe0dd4d596430d73d933141c722f5cf5fc5538e497ca582211f5f2c7cfdf6800b87c490c3739c9d29aee30c16a5fc1ba9ab2c861ae7b2663c1ba998d0335516b1cc5f6896e4593e94642a6a225410022502edc6c5700d298b46ff"
+    },
+    {
+      "seqnum": 3,
+      "headers": [
+        {
+          ":method": "GET"
+        },
+        {
+          ":scheme": "http"
+        },
+        {
+          ":authority": "bits.wikimedia.org"
+        },
+        {
+          ":path": "/en.wikipedia.org/load.php"
+        },
+        {
+          "user-agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:16.0) 
Gecko/20100101 Firefox/16.0"
+        },
+        {
+          "accept": "text/css,*/*;q=0.1"
+        },
+        {
+          "accept-language": "en-US,en;q=0.5"
+        },
+        {
+          "accept-encoding": "gzip, deflate"
+        },
+        {
+          "connection": "keep-alive"
+        },
+        {
+          "referer": "http://en.wikipedia.org/wiki/Main_Page";
+        },
+        {
+          "if-modified-since": "Thu, 01 Nov 2012 09:33:27 GMT"
+        }
+      ],
+      "wire": 
"8286c2c1c8c0c690c5bf6896df3dbf4a002a693f75040089403f71966e09d53168df"
+    },
+    {
+      "seqnum": 4,
+      "headers": [
+        {
+          ":method": "GET"
+        },
+        {
+          ":scheme": "http"
+        },
+        {
+          ":authority": "bits.wikimedia.org"
+        },
+        {
+          ":path": "/en.wikipedia.org/load.php"
+        },
+        {
+          "user-agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:16.0) 
Gecko/20100101 Firefox/16.0"
+        },
+        {
+          "accept": "*/*"
+        },
+        {
+          "accept-language": "en-US,en;q=0.5"
+        },
+        {
+          "accept-encoding": "gzip, deflate"
+        },
+        {
+          "connection": "keep-alive"
+        },
+        {
+          "referer": "http://en.wikipedia.org/wiki/Main_Page";
+        },
+        {
+          "if-modified-since": "Sat, 03 Nov 2012 12:53:27 GMT"
+        }
+      ],
+      "wire": 
"8286c3c2c95383f963e7c890c7c16896dc34fd280654d27eea0801128115c6d9b82754c5a37f"
+    },
+    {
+      "seqnum": 5,
+      "headers": [
+        {
+          ":method": "GET"
+        },
+        {
+          ":scheme": "http"
+        },
+        {
+          ":authority": "bits.wikimedia.org"
+        },
+        {
+          ":path": "/en.wikipedia.org/load.php"
+        },
+        {
+          "user-agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:16.0) 
Gecko/20100101 Firefox/16.0"
+        },
+        {
+          "accept": "*/*"
+        },
+        {
+          "accept-language": "en-US,en;q=0.5"
+        },
+        {
+          "accept-encoding": "gzip, deflate"
+        },
+        {
+          "connection": "keep-alive"
+        },
+        {
+          "referer": "http://en.wikipedia.org/wiki/Main_Page";
+        },
+        {
+          "if-modified-since": "Wed, 31 Oct 2012 17:52:04 GMT"
+        }
+      ],
+      "wire": "8286c5c4cbbfc990c8c2c1"
+    },
+    {
+      "seqnum": 6,
+      "headers": [
+        {
+          ":method": "GET"
+        },
+        {
+          ":scheme": "http"
+        },
+        {
+          ":authority": "bits.wikimedia.org"
+        },
+        {
+          ":path": "/en.wikipedia.org/load.php"
+        },
+        {
+          "user-agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:16.0) 
Gecko/20100101 Firefox/16.0"
+        },
+        {
+          "accept": "*/*"
+        },
+        {
+          "accept-language": "en-US,en;q=0.5"
+        },
+        {
+          "accept-encoding": "gzip, deflate"
+        },
+        {
+          "connection": "keep-alive"
+        },
+        {
+          "referer": "http://en.wikipedia.org/wiki/Main_Page";
+        },
+        {
+          "if-modified-since": "Thu, 01 Nov 2012 09:33:27 GMT"
+        }
+      ],
+      "wire": "8286c5c4cbbfc990c8c2c0"
+    },
+    {
+      "seqnum": 7,
+      "headers": [
+        {
+          ":method": "GET"
+        },
+        {
+          ":scheme": "http"
+        },
+        {
+          ":authority": "upload.wikimedia.org"
+        },
+        {
+          ":path": "/wikipedia/en/c/ca/Kanthirava_cropped.png"
+        },
+        {
+          "user-agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:16.0) 
Gecko/20100101 Firefox/16.0"
+        },
+        {
+          "accept": "image/png,image/*;q=0.8,*/*;q=0.5"
+        },
+        {
+          "accept-language": "en-US,en;q=0.5"
+        },
+        {
+          "accept-encoding": "gzip, deflate"
+        },
+        {
+          "connection": "keep-alive"
+        },
+        {
+          "referer": "http://en.wikipedia.org/wiki/Main_Page";
+        },
+        {
+          "if-modified-since": "Fri, 02 Nov 2012 23:46:59 GMT"
+        },
+        {
+          "if-none-match": "288bdb2fd5e5a4f7272f58fcb083a7e1"
+        }
+      ],
+      "wire": 
"8286418fb6ba0e3917f06ea6a4b2186b9ec9bf449e63c1ba9ab2c861b05a9823041b198752673583ee388961ebacb22f5d537fcd539a352398ac5754df46a473158f9fbed00177bebe58f9fbed00176fcc90cbc56896c361be940094d27eea0801128266e34e5c6df53168df699713cf4724629646cad8da95d13a295b7a524607991ba50f"
+    },
+    {
+      "seqnum": 8,
+      "headers": [
+        {
+          ":method": "GET"
+        },
+        {
+          ":scheme": "http"
+        },
+        {
+          ":authority": "upload.wikimedia.org"
+        },
+        {
+          ":path": 
"/wikipedia/commons/thumb/d/d2/Dancing_girl_ajanta_%28cropped%29.jpg/72px-Dancing_girl_ajanta_%28cropped%29.jpg"
+        },
+        {
+          "user-agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:16.0) 
Gecko/20100101 Firefox/16.0"
+        },
+        {
+          "accept": "image/png,image/*;q=0.8,*/*;q=0.5"
+        },
+        {
+          "accept-language": "en-US,en;q=0.5"
+        },
+        {
+          "accept-encoding": "gzip, deflate"
+        },
+        {
+          "connection": "keep-alive"
+        },
+        {
+          "referer": "http://en.wikipedia.org/wiki/Main_Page";
+        },
+        {
+          "if-modified-since": "Tue, 30 Oct 2012 17:37:15 GMT"
+        },
+        {
+          "if-none-match": "6e8d56df9be35494b4d9f0ea72ed1a3e"
+        }
+      ],
+      "wire": 
"8286c244cf63c1ba9ab2c861b043d349ea43099eda636246241317c7510d54d14c6b28887d07524712a278961ebacb22a27d7e95ccc3a2afcad7c7510d54d14c6b28887d07524712a278961ebacb22a27d7e95cdd1c1cf90cec86896df697e94640a6a225410022502edc65db816d4c5a37f699770af48db924afc6565b69f6a36a47e50146e88b2046c97"
+    },
+    {
+      "seqnum": 9,
+      "headers": [
+        {
+          ":method": "GET"
+        },
+        {
+          ":scheme": "http"
+        },
+        {
+          ":authority": "bits.wikimedia.org"
+        },
+        {
+          ":path": "/en.wikipedia.org/load.php"
+        },
+        {
+          "user-agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:16.0) 
Gecko/20100101 Firefox/16.0"
+        },
+        {
+          "accept": "*/*"
+        },
+        {
+          "accept-language": "en-US,en;q=0.5"
+        },
+        {
+          "accept-encoding": "gzip, deflate"
+        },
+        {
+          "connection": "keep-alive"
+        },
+        {
+          "referer": "http://en.wikipedia.org/wiki/Main_Page";
+        },
+        {
+          "if-modified-since": "Sat, 03 Nov 2012 12:53:27 GMT"
+        }
+      ],
+      "wire": "8286cdccd3c7d190d0cac6"
+    }
+  ],
+  "description": "Apache Traffic Server"
+}

Reply via email to