From e05d1e74c52a4c0a25b961444b0cf05cbe9d564e Mon Sep 17 00:00:00 2001 From: Brian Neradt Date: Mon, 17 Nov 2025 20:15:02 -0600 Subject: [PATCH 1/3] ATSReplayTest: autests via replay.yaml (#12648) For context, this continues the work started in #12371. The goal is to take full advantage of the autest extension capabilities to make writing ATS autests easier. This adds the Test.ATSReplayTest autest extensions so that tests can be written through a replay.yaml file that specifies both the configuration of the test processes as well as the HTTP Proxy Verifier traffic for the test. This patch updates the header_rewrite_bundle to use this new framework. (cherry picked from commit 4b3354fe383afbc2cd08d0dd1a87334f345735ec) --- .../autest-site/ats_replay.test.ext | 145 ++++++++++++++++++ 1 file changed, 145 insertions(+) create mode 100644 tests/gold_tests/autest-site/ats_replay.test.ext diff --git a/tests/gold_tests/autest-site/ats_replay.test.ext b/tests/gold_tests/autest-site/ats_replay.test.ext new file mode 100644 index 00000000000..10e3b0fe850 --- /dev/null +++ b/tests/gold_tests/autest-site/ats_replay.test.ext @@ -0,0 +1,145 @@ +''' +Implement general-purpose ATS test extensions using proxy verifier replay files. +''' +# 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. + +from typing import Optional +import os +import yaml + + +def configure_ats(obj: 'TestRun', server: 'Process', ats_config: dict, dns: Optional['Process'] = None): + '''Configure ATS per the configuration in the replay file. + + :param obj: The Test object to configure ATS for. + :param server: The Proxy Verifier Server process to use. + :param ats_config: The ATS configuration from the replay file. + :param dns: The DNS process to use. Optional. + :returns: The ATS process object. + ''' + name = ats_config.get('name', 'ts') + process_config = ats_config.get('process_config', {}) + ts = obj.MakeATSProcess(name, **process_config) + records_config = ats_config.get('records_config', {}) + ts.Disk.records_config.update(records_config) + remap_config = ats_config.get('remap_config', []) + for remap_entry in remap_config: + if isinstance(remap_entry, str): + ts.Disk.remap_config.AddLine(remap_entry) + elif isinstance(remap_entry, dict): + from_url = remap_entry['from'] + to_url = remap_entry['to'] + to_url = to_url.replace('{SERVER_HTTP_PORT}', str(server.Variables.http_port)) + to_url = to_url.replace('{SERVER_HTTPS_PORT}', str(server.Variables.https_port)) + plugins = remap_entry.get('plugins', []) + line = f'map {from_url} {to_url}' + for plugin in plugins: + line += f' @plugin={plugin["name"]}' + for arg in plugin["args"]: + line += f' @pparam={arg}' + ts.Disk.remap_config.AddLine(line) + if dns: + ts.Disk.records_config.update( + { + 'proxy.config.dns.nameservers': f'127.0.0.1:{dns.Variables.Port}', + 'proxy.config.dns.resolv_conf': 'NULL', + }) + + for item in ats_config.get('copy_to_config_dir', []): + item_path = os.path.join(obj.TestDirectory, item) + if os.path.isdir(item_path): + src_dir = item_path + dst_dir = os.path.join(ts.Variables.CONFIGDIR, item) + ts.Setup.MakeDir(dst_dir) + ts.Setup.Copy(src_dir, dst_dir) + else: + ts.Setup.CopyAs(item, ts.Variables.CONFIGDIR) + return ts + + +def ATSReplayTest(obj, replay_file: str): + '''Create a TestRun that configures ATS and runs HTTP traffic using the replay file. + + :param obj: The Test object to add the test run to. + :param replay_file: Replay file specifying the test configuration and test traffic. + :returns: The TestRun object. + ''' + + replay_path = replay_file if os.path.isabs(replay_file) else os.path.join(obj.TestDirectory, replay_file) + with open(replay_path, 'r') as f: + replay_config = yaml.safe_load(f) + + # The user must specify the 'autest' node. + if not 'autest' in replay_config: + raise ValueError(f"Replay file {replay_file} does not contain 'autest' section") + autest_config = replay_config['autest'] + + tr = obj.AddTestRun(autest_config['description']) + + # Copy the specified files and directories down. + tr.Setup.Copy(replay_file, tr.RunDirectory) + + for files_to_copy in autest_config.get('files_to_copy', []): + tr.Setup.Copy(files_to_copy) + for dirs_to_copy in autest_config.get('dirs_to_copy', []): + tr.Setup.Copy(dirs_to_copy) + + # DNS configuration. + dns = None + if 'dns' in autest_config: + dns_config = autest_config['dns'] + name = dns_config['name'] + if 'process_config' in dns_config: + process_config = dns_config['process_config'] + dns = tr.MakeDNServer(name, **process_config) + else: + dns = tr.MakeDNServer(name, default='127.0.0.1') + + # Proxy Verifier Server configuration. + if not 'server' in autest_config: + raise ValueError(f"Replay file {replay_file} does not contain 'autest.server' section") + server_config = autest_config['server'] + name = server_config['name'] + process_config = server_config.get('process_config', {}) + server = tr.AddVerifierServerProcess(name, replay_file, **process_config) + + # ATS configuration. + if not 'ats' in autest_config: + raise ValueError(f"Replay file {replay_file} does not contain 'autest.ats' section") + ats_config = autest_config['ats'] + enable_tls = ats_config.get('enable_tls', False) + ts = configure_ats(tr, server=server, ats_config=ats_config, dns=dns) + + # Proxy Verifier Client configuration. + if not 'client' in autest_config: + raise ValueError(f"Replay file {replay_file} does not contain 'autest.client' section") + client_config = autest_config['client'] + name = client_config.get('name', 'client') + process_config = client_config.get('process_config', {}) + https_ports = [ts.Variables.ssl_port] if enable_tls else None + client = tr.AddVerifierClientProcess( + name, replay_file, http_ports=[ts.Variables.port], https_ports=https_ports, **process_config) + + if dns: + ts.StartBefore(dns) + ts.StartBefore(server) + client.StartBefore(ts) + + return tr + + +ExtendTest(ATSReplayTest, name="ATSReplayTest") From d8540a9ecf20f176cd0f43a0c0615721da586a7a Mon Sep 17 00:00:00 2001 From: Brian Neradt Date: Fri, 21 Nov 2025 17:43:16 -0600 Subject: [PATCH 2/3] autest.en.rst: Add dev autest docs (#12693) This commit adds a new documentation page (autests.en.rst) that provides guidance for writing end-to-end tests using the AuTest framework, with a focus on the new ATSReplayTest approach that uses YAML-based replay files for traffic specification and verification. This, hopefully living document, will be helpful for devs and AI tools that could use guidance on how to write autests. (cherry picked from commit 32d37f29f12f9d9e13ba33b686468d24d0138406) --- doc/developer-guide/testing/autests.en.rst | 392 +++++++++++++++++++++ doc/developer-guide/testing/index.en.rst | 1 + 2 files changed, 393 insertions(+) create mode 100644 doc/developer-guide/testing/autests.en.rst diff --git a/doc/developer-guide/testing/autests.en.rst b/doc/developer-guide/testing/autests.en.rst new file mode 100644 index 00000000000..8c83cff3266 --- /dev/null +++ b/doc/developer-guide/testing/autests.en.rst @@ -0,0 +1,392 @@ +.. 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. + +.. include:: ../../common.defs + +.. _autest-writing: + +Writing Autests +*************** + +|TS| has two types of developer tests: (1) Catch2 tests for unit tests and (2) +AuTest framework tests for end-to-end testing. The Catch tests reside next the +the associated source code being tested while AuTests are located in +``tests/gold_tests/`` with ``.test.py`` extensions. + +* For catch test framework documentation, see: https://github.com/catchorg/Catch2 +* For AuTest framework documentation, see: https://autestsuite.bitbucket.io/index.html + +This document focuses on AuTest framework tests because they are rather unique +to the |TS| project while Catch2 documentation can be found elsewhere. + +File Structure and Naming +========================== + +Here is a summary of the file structure and naming conventions for AuTest tests: + +- AuTest tests are placed in appropriate subdirectories under + ``tests/gold_tests/`` (e.g., ``cache/``, ``pluginTest/``, ``tls/``, + etc.) +- AuTest test files have a descriptive name with a ``.test.py`` extension (e.g., + ``cache-auth.test.py``, ``stats_over_http.test.py``). When the tests are run, + be aware that their names, sans the ``.test.py`` extension, are used to + identify the test. +- The ``.test.py`` typically are thin and reference the associated + ``replay.yaml`` file that describes the test via the ``Test.ATSReplayTest()`` + method. +- ``tests/gold_tests/autest-site`` is a special directory. AuTest, a general + testing framework, is extended to add domain specific support, |TS| in this + case, via ``.test.ext`` extension files. The files in here customize the + command line arguments recognized by the ``autest`` command, the functions + availabe to the ``Test`` and ``TestRun`` AuTest objects, specific ``Process`` + objects available to test, ``Skip`` conditions for individual tests, etc. + +Running Autests +=============== + +If |TS| cmake build is configured via ``-DENABLE_AUTEST=ON``, tests can be run with: + +.. code-block:: bash + + cmake --build build + cmake --install build + cd build/tests + pipenv install + ./autest.sh --sandbox /tmp/sbcursor --clean=none -f + +For example, to run ``cache-auth.test.py``: + +.. code-block:: bash + + ./autest.sh --sandbox /tmp/sbcursor --clean=none -f cache-auth + +Recommended Approach: ATSReplayTest +==================================== + +Currently, many tests are specified largely entirely using the generic AuTest +framework specific syntax via ``.test.py`` files. These use the generic AuTest +framework syntax, which is generically very capable, but not tuned to the +specific |TS| environment and not generally parseable by code editors and AI +tools. + +AuTest itself has a solution for this via its extensibility mechanism. A +concerted effort is underway to make more full use of the AuTest extension +mechanism to simplify the test writing process specifically for |TS|. At a high +level, the extension is called ``ATSReplayTest`` and it is used in a ``test.py`` +file to reference an associated ``replay.yaml`` file which fully describes the +test. The goal is that a large percentage, maybe 90%, of the tests can be +written using this approach while certain requests, perhaps requiring ad-hoc +clients and servers, will be written using the generic AuTest framework syntax. + +The traffic portion of the ``replay.yaml`` files specify Proxy Verifier HTTP +traffic behavior and follow the replay and verification syntax described +extensively in its project's README.md file here: +https://github.com/yahoo/proxy-verifier + +Simple Test File Structure +--------------------------- + +Here is an example of a test file using ``ATSReplayTest``: + +.. code-block:: python + + ''' + Brief description of what the test validates + ''' + # 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 = ''' + Brief description of test purpose + ''' + + Test.ATSReplayTest(replay_file="replay/my-test.replay.yaml") + +For tests with multiple |TS| configuration scenarios, you can call +``Test.ATSReplayTest()`` multiple times, each with a different replay file +specifying different configurations of |TS|, dns, servers, clients, etc. + +.. code-block:: python + + Test.ATSReplayTest(replay_file="replay/scenario1.replay.yaml") + Test.ATSReplayTest(replay_file="replay/scenario2.replay.yaml") + Test.ATSReplayTest(replay_file="replay/scenario3.replay.yaml") + +Replay File Structure +---------------------- + +The replay file contains both the test configuration (in the ``autest`` YAML +node) and the traffic replay and verification specification (in the ``sessions`` +YAML node). Here is an example: + +.. code-block:: yaml + + # 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" + + # Configuration section for autest integration + autest: + description: 'Test description for this scenario' + + # Optional (but typical) DNS configuration. + dns: + name: 'dns' + # Other MakeDNServer parameters can be set, see microDNS.test.ext + + # Required: Server configuration. + server: + name: 'server' + # Other AddVerifierServerProcess parameters can be set, see verifier_server.test.ext + + # Required: Client configuration. + client: + name: 'client' + # Other AddVerifierClientProcess parameters can be set, see verifier_client.test.ext + + # Required: ATS configuration. + ats: + name: 'ts' + + # Optional: Enable cache (default is determined by process_config) + # enable_cache: true + + # Other parameters can be set, see trafficserver.test.ext + + # Optional: ATS process configuration + process_config: + enable_cache: true + # Other MakeATSProcess parameters can be set, see trafficserver.test.ext + + # ATS records.config settings + records_config: + proxy.config.diags.debug.enabled: 1 + proxy.config.diags.debug.tags: 'http|cache' + proxy.config.http.cache.http: 1 + + # Remap configuration (list format) + remap_config: + # Option 1: String format. + - "map http://test.com/ http://backend.test.com:8080/" + + # Option 2: Dict format with automatic port substitution + # Note: Using hostnames like backend.example.com requires DNS configuration + - from: "http://example.com/" + to: "http://backend.example.com:{SERVER_HTTP_PORT}/" + # Optional plugins + plugins: + - name: "conf_remap.so" + args: + - "proxy.config.http.cache.required_headers=0" + + # Optional: Copy test-specific files/directories to ATS config directory + copy_to_config_dir: + - "my-plugin-config.txt" + - "cert-directory/" + + # Optional: Log (traffic.out or diags.log) validation + log_validation: + traffic_out: + contains: + - expression: "Expected log message in traffic.out" + description: "Verify this appears in traffic.out" + excludes: + - expression: "Unwanted log message" + description: "Verify this does NOT appear in traffic.out" + diags_log: + contains: + - expression: "Expected log message in diags.log" + description: "Verify this appears in diags.log" + excludes: + - expression: "Unwanted message in diags.log" + description: "Verify this does NOT appear in diags.log" + + # Traffic specification using Proxy Verifier format + # client-request and server-response generate request and response traffic + # toward the ATS proxy. + # proxy-request and proxy-response verify the content of the request and response + # after proxying through ATS. + sessions: + - transactions: + + # First transaction: populate cache + + # Send a request to ATS. + - client-request: + method: GET + url: /path + version: '1.1' + headers: + fields: + - [Host, example.com] + - [uuid, transaction-1] + + # Verify request headers from ATS. + proxy-request: + headers: + fields: + - [X-Added-Header, { value: some_field_value, as: equal }] + + # Send a response to ATS. + server-response: + status: 200 + reason: OK + headers: + fields: + - [Content-Type, text/plain] + - [Content-Length, "4"] + - [Cache-Control, "max-age=300"] + + # Verify respone headers from ATS. + proxy-response: + status: 200 + headers: + fields: + - [Content-Length, { value: 4, as: equal }] + + # Second transaction: verify cache hit with delay + - client-request: + # Add delay for cache IO to complete + delay: 100ms + + method: GET + url: /path + version: '1.1' + headers: + fields: + - [Host, example.com] + - [uuid, transaction-2] + + # Server should not receive this request (cache hit) + server-response: + status: 404 + reason: Not Found + + # Expect cached 200 response + proxy-response: + status: 200 + headers: + fields: + - [Content-Length, { value: 4, as: equal }] + +Replay File Components +----------------------- + +autest Configuration Section +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +The ``autest`` section configures the test environment: + +- **description** (required): A brief description of what this test scenario + validates. This is helpful to document the intetion of the test for the human + reading the file and is also helpful when tests fail as this description is included + in failure output. +- **dns** (optional): DNS server configuration with ``name`` and optional + ``process_config``. See the ``microDNS.test.ext`` file for more details. Including + the DNS allows remap entries to contain hostnames rather than localhost IP + addresses. +- **server** (required): Proxy Verifier Server configuration with ``name`` and + optional ``process_config``. See the ``verifier_server.test.ext`` file for + more details. This acts as the HTTP origin server that receives requests from + |TS| as they are proxied from the client to the server. It also provides any + request verification and generates the configured HTTP response. +- **client** (required): Proxy Verifier Client configuration with ``name`` and + optional ``process_config``. See the ``verifier_client.test.ext`` file for + more details. This acts as the HTTP client that requests content from the + server via the |TS| proxy and validates the response. +- **ats** (required): |TS| configuration including: + + - **name**: ATS process name + - **enable_tls**: Set to ``true`` for HTTPS testing + - **process_config**: Parameters passed to ``MakeATSProcess`` (e.g., ``enable_cache``) + - **records_config**: Dictionary of records.config settings + - **remap_config**: List of remap rules (string or dict format) + - **copy_to_config_dir**: List of files/directories to copy to ATS config directory + - **log_validation**: Log validation rules for ``traffic_out`` and ``diags_log`` + +Log Validation +~~~~~~~~~~~~~~ + +The ``log_validation`` section allows you to verify the contents of +``traffic.out`` and ``diags.log`` after the test completes. + +.. code-block:: yaml + + log_validation: + traffic_out: + contains: + - expression: "cache hit" + description: "Verify cache hit occurred" + excludes: + - expression: "cache miss" + description: "Should not be a cache miss" + diags_log: + contains: + - expression: "Plugin initialized" + description: "Verify plugin loaded" + +Sessions and Transactions +~~~~~~~~~~~~~~~~~~~~~~~~~~ + +The ``sessions`` section uses the Proxy Verifier format to specify HTTP traffic +and validation. The below provides a brief overview. For details, see the Proxy +Verifier documentation: https://github.com/yahoo/proxy-verifier + +Key points: + +- The client uses ``client-request`` to generate an HTTP requests to the |TS| + proxy. This must contain a ``uuid`` header value to uniquely identify the + transaction which is later used by the server. +- The server uses ``proxy-request`` to verify the contents of the proxied + request |TS| sent to it. +- The server uses ``server-response`` to specify the HTTP response to send to + the client. The server uses the ``uuid`` header value as the key to look up + which transaction applies to the received request. +- The client uses the ``proxy-response`` to verify the contents of the response + from the |TS| proxy. +- Use ``delay`` in ``client-request`` to wait between requests (e.g., for cache IO). +- Verficiation in ``proxy-*`` nodes uses ``{ value: X, as: }`` + syntax to check header values. +- Status codes can be verified with the ``status`` field in ``proxy-response``. diff --git a/doc/developer-guide/testing/index.en.rst b/doc/developer-guide/testing/index.en.rst index 2cac843da2f..3810a5f00b2 100644 --- a/doc/developer-guide/testing/index.en.rst +++ b/doc/developer-guide/testing/index.en.rst @@ -25,4 +25,5 @@ Testing Traffic Server .. toctree:: :maxdepth: 2 + autests.en blackbox-testing.en From a3310ef3fc182c286949d30682100f5a8671e178 Mon Sep 17 00:00:00 2001 From: Brian Neradt Date: Mon, 24 Nov 2025 13:26:23 -0600 Subject: [PATCH 3/3] cache-*.test.py tests to use ATSReplayTest (#12701) Convert various cache-*.test.py tests to use the new ATSReplayTest extension. These were generally pretty easy to convert because many of them were Proxy Verifier replay file based tests already anyway. To support this, this also adds diags.log and traffic.out log verification support to ATSReplayTest. (cherry picked from commit d74c79580eb4419f8ebcf4561556c38c409c18e3) --- .../autest-site/ats_replay.test.ext | 45 +++ .../cache/alternate-caching.test.py | 27 +- tests/gold_tests/cache/cache-auth.test.py | 89 +---- tests/gold_tests/cache/cache-control.test.py | 348 +----------------- tests/gold_tests/cache/cache-cookie.test.py | 206 +---------- .../cache/cache-range-response.test.py | 18 +- .../cache/cache-request-method.test.py | 80 +--- .../cache/conditional-get-hit.test.py | 17 +- .../cache/gold/cache_and_req_body-hit.gold | 10 - .../cache/gold/cache_and_req_body-miss.gold | 10 - .../cache/gold/cache_hit_stale.gold | 10 - .../gold_tests/cache/gold/cache_no_cache.gold | 12 - tests/gold_tests/cache/gold/cache_no_cc.gold | 9 - .../cache/gold/two_alternates_evicted.gold | 4 +- .../gold_tests/cache/negative-caching.test.py | 62 +--- .../cache/negative-revalidating.test.py | 99 +---- .../replay/alternate-caching-update-size.yaml | 31 ++ .../cache/replay/auth-default.replay.yaml | 68 ---- .../cache/replay/auth-ignored.replay.yaml | 67 ---- .../replay/cache-control-basic.replay.yaml | 217 +++++++++++ .../replay/cache-control-max-age.replay.yaml | 29 ++ .../replay/cache-control-pragma.replay.yaml | 26 ++ .../replay/cache-control-s-maxage.replay.yaml | 27 ++ .../replay/cache-range-response.replay.yaml | 28 ++ .../replay/conditional-get-cache-hit.yaml | 26 ++ .../cookie-all-but-text-with-excp.replay.yaml | 28 ++ .../replay/cookie-all-but-text.replay.yaml | 27 ++ .../replay/cookie-bypass-cache.replay.yaml | 27 ++ .../replay/cookie-cache-img-only.replay.yaml | 27 ++ .../cache/replay/cookie-default.replay.yaml | 27 +- .../replay/head_with_get_cached.replay.yaml | 27 +- .../replay/ignore_authentication.replay.yaml | 157 ++++++++ .../negative-caching-customized.replay.yaml | 28 ++ .../negative-caching-default.replay.yaml | 27 ++ .../negative-caching-disabled.replay.yaml | 27 ++ ...negative-revalidating-disabled.replay.yaml | 29 ++ .../negative-revalidating-enabled.replay.yaml | 34 +- .../negative-revalidating-list.replay.yaml | 35 +- ...ost_with_post_caching_disabled.replay.yaml | 29 ++ ...post_with_post_caching_enabled.replay.yaml | 28 ++ ...ost_with_post_caching_override.replay.yaml | 112 ++++++ .../request-cache-control-default.replay.yaml | 26 ++ ...est-cache-control-honor-client.replay.yaml | 36 ++ ...response-cache-control-default.replay.yaml | 34 ++ ...response-cache-control-ignored.replay.yaml | 35 ++ .../replay/varied_transactions.replay.yaml | 31 ++ tests/gold_tests/cache/vary-handling.test.py | 22 +- .../proxy_protocol/proxy_serve_stale.test.py | 49 +-- .../replay/proxy_serve_stale.replay.yaml | 32 ++ 49 files changed, 1348 insertions(+), 1151 deletions(-) delete mode 100644 tests/gold_tests/cache/gold/cache_and_req_body-hit.gold delete mode 100644 tests/gold_tests/cache/gold/cache_and_req_body-miss.gold delete mode 100644 tests/gold_tests/cache/gold/cache_hit_stale.gold delete mode 100644 tests/gold_tests/cache/gold/cache_no_cache.gold delete mode 100644 tests/gold_tests/cache/gold/cache_no_cc.gold delete mode 100644 tests/gold_tests/cache/replay/auth-default.replay.yaml delete mode 100644 tests/gold_tests/cache/replay/auth-ignored.replay.yaml create mode 100644 tests/gold_tests/cache/replay/cache-control-basic.replay.yaml create mode 100644 tests/gold_tests/cache/replay/ignore_authentication.replay.yaml create mode 100644 tests/gold_tests/cache/replay/post_with_post_caching_override.replay.yaml diff --git a/tests/gold_tests/autest-site/ats_replay.test.ext b/tests/gold_tests/autest-site/ats_replay.test.ext index 10e3b0fe850..3028ac9edff 100644 --- a/tests/gold_tests/autest-site/ats_replay.test.ext +++ b/tests/gold_tests/autest-site/ats_replay.test.ext @@ -36,6 +36,17 @@ def configure_ats(obj: 'TestRun', server: 'Process', ats_config: dict, dns: Opti ts = obj.MakeATSProcess(name, **process_config) records_config = ats_config.get('records_config', {}) ts.Disk.records_config.update(records_config) + + # Configure plugin_config if specified. + plugin_config = ats_config.get('plugin_config', []) + for plugin_line in plugin_config: + ts.Disk.plugin_config.AddLine(plugin_line) + + # Configure parent_config if specified. + parent_config = ats_config.get('parent_config', []) + for parent_line in parent_config: + ts.Disk.parent_config.AddLine(parent_line) + remap_config = ats_config.get('remap_config', []) for remap_entry in remap_config: if isinstance(remap_entry, str): @@ -68,6 +79,40 @@ def configure_ats(obj: 'TestRun', server: 'Process', ats_config: dict, dns: Opti ts.Setup.Copy(src_dir, dst_dir) else: ts.Setup.CopyAs(item, ts.Variables.CONFIGDIR) + + # Configure log validation if specified. + log_validation = ats_config.get('log_validation', {}) + if log_validation: + # traffic_out validation. + traffic_out = log_validation.get('traffic_out', {}) + for contains_entry in traffic_out.get('contains', []): + expression = contains_entry['expression'] + description = contains_entry.get('description', f'Verify traffic_out contains: {expression}') + ts.Disk.traffic_out.Content += Testers.ContainsExpression(expression, description) + for excludes_entry in traffic_out.get('excludes', []): + expression = excludes_entry['expression'] + description = excludes_entry.get('description', f'Verify traffic_out excludes: {expression}') + ts.Disk.traffic_out.Content += Testers.ExcludesExpression(expression, description) + # Gold file validation for traffic_out. + if 'gold_file' in traffic_out: + gold_file = traffic_out['gold_file'] + ts.Disk.traffic_out.Content += gold_file + + # diags_log validation. + diags_log = log_validation.get('diags_log', {}) + for contains_entry in diags_log.get('contains', []): + expression = contains_entry['expression'] + description = contains_entry.get('description', f'Verify diags_log contains: {expression}') + ts.Disk.diags_log.Content += Testers.ContainsExpression(expression, description) + for excludes_entry in diags_log.get('excludes', []): + expression = excludes_entry['expression'] + description = excludes_entry.get('description', f'Verify diags_log excludes: {expression}') + ts.Disk.diags_log.Content += Testers.ExcludesExpression(expression, description) + # Gold file validation for diags_log. + if 'gold_file' in diags_log: + gold_file = diags_log['gold_file'] + ts.Disk.diags_log.Content += gold_file + return ts diff --git a/tests/gold_tests/cache/alternate-caching.test.py b/tests/gold_tests/cache/alternate-caching.test.py index 21b7ef017a5..b6ec1350836 100644 --- a/tests/gold_tests/cache/alternate-caching.test.py +++ b/tests/gold_tests/cache/alternate-caching.test.py @@ -21,28 +21,5 @@ Test the alternate caching feature. ''' -# -# Verify disabled negative_revalidating behavior. -# -ts = Test.MakeATSProcess("ts-alternate-caching") -ts.Disk.records_config.update( - { - 'proxy.config.diags.debug.enabled': 1, - 'proxy.config.diags.debug.tags': 'http|cache', - 'proxy.config.http.cache.max_stale_age': 6, - 'proxy.config.cache.select_alternate': 1, - 'proxy.config.cache.limits.http.max_alts': 4, - - # Try with and without this - 'proxy.config.http.negative_revalidating_enabled': 1, - 'proxy.config.http.negative_caching_enabled': 1, - 'proxy.config.http.negative_caching_lifetime': 30 - }) -tr = Test.AddTestRun("Verify disabled negative revalidating behavior.") -replay_file = "replay/alternate-caching-update-size.yaml" -server = tr.AddVerifierServerProcess("server1", replay_file) -server_port = server.Variables.http_port -tr.AddVerifierClientProcess("client1", replay_file, http_ports=[ts.Variables.port]) -ts.Disk.remap_config.AddLine('map / http://127.0.0.1:{0}'.format(server_port)) -tr.Processes.Default.StartBefore(ts) -tr.StillRunningAfter = ts +# Verify disabled negative revalidating behavior. +Test.ATSReplayTest(replay_file="replay/alternate-caching-update-size.yaml") diff --git a/tests/gold_tests/cache/cache-auth.test.py b/tests/gold_tests/cache/cache-auth.test.py index 9e8f3e6c310..08613554647 100644 --- a/tests/gold_tests/cache/cache-auth.test.py +++ b/tests/gold_tests/cache/cache-auth.test.py @@ -21,90 +21,5 @@ Test authorization-related caching behaviors ''' -Test.ContinueOnFail = True - -# **testname is required** -testName = "" - - -class AuthDefaultTest: - # Verify the proper caching behavior for request/response containing - # auth-related fields when ATS is in default configuration - authDefaultReplayFile = "replay/auth-default.replay.yaml" - - def __init__(self): - self.setupOriginServer() - self.setupTS() - - def setupOriginServer(self): - self.server = Test.MakeVerifierServerProcess("auth-default-verifier-server", self.authDefaultReplayFile) - - def setupTS(self): - self.ts = Test.MakeATSProcess("ts-auth-default") - self.ts.Disk.records_config.update({ - "proxy.config.diags.debug.enabled": 1, - "proxy.config.diags.debug.tags": "http", - }) - self.ts.Disk.remap_config.AddLine(f"map / http://127.0.0.1:{self.server.Variables.http_port}/",) - - # Verify log for skipping the WWW-Authenticate response - self.ts.Disk.traffic_out.Content += Testers.ContainsExpression( - "response has WWW-Authenticate, response is not cacheable", - "Verify ATS doesn't store the response with WWW-Authenticate.") - - def runTraffic(self): - tr = Test.AddTestRun( - "Verify the proper caching behavior for request/response containing auth-related fields when ATS is in default configuration" - ) - tr.AddVerifierClientProcess("auth-default-client", self.authDefaultReplayFile, http_ports=[self.ts.Variables.port]) - tr.Processes.Default.StartBefore(self.server) - tr.Processes.Default.StartBefore(self.ts) - tr.StillRunningAfter = self.server - tr.StillRunningAfter = self.ts - - def run(self): - self.runTraffic() - - -AuthDefaultTest().run() - - -class AuthIgnoredTest: - # Verify the proper caching behavior for request/response containing - # auth-related fields when ATS is configured to bypass caching for those - authIgnoredReplayFile = "replay/auth-ignored.replay.yaml" - - def __init__(self): - self.setupOriginServer() - self.setupTS() - - def setupOriginServer(self): - self.server = Test.MakeVerifierServerProcess("auth-ignored-verifier-server", self.authIgnoredReplayFile) - - def setupTS(self): - self.ts = Test.MakeATSProcess("ts-auth-ignored") - self.ts.Disk.records_config.update( - { - "proxy.config.diags.debug.enabled": 1, - "proxy.config.diags.debug.tags": "http", - # Configure ATS to ignore the WWW-Authenticate header in - # response(allow caching of such response) - "proxy.config.http.cache.ignore_authentication": 1 - }) - self.ts.Disk.remap_config.AddLine(f"map / http://127.0.0.1:{self.server.Variables.http_port}/",) - - def runTraffic(self): - tr = Test.AddTestRun( - "Verify the proper caching behavior for request/response containing auth-related fields when ATS is configured to bypass caching for those" - ) - tr.AddVerifierClientProcess("auth-ignored-client", self.authIgnoredReplayFile, http_ports=[self.ts.Variables.port]) - tr.Processes.Default.StartBefore(self.server) - tr.Processes.Default.StartBefore(self.ts) - tr.StillRunningAfter = self.server - tr.StillRunningAfter = self.ts - - def run(self): - self.runTraffic() - - -AuthIgnoredTest().run() +# Verify proxy.config.http.cache.ignore_authentication behavior. +Test.ATSReplayTest(replay_file="replay/ignore_authentication.replay.yaml") diff --git a/tests/gold_tests/cache/cache-control.test.py b/tests/gold_tests/cache/cache-control.test.py index 82cbd180a2e..809798b8fb1 100644 --- a/tests/gold_tests/cache/cache-control.test.py +++ b/tests/gold_tests/cache/cache-control.test.py @@ -18,343 +18,29 @@ # limitations under the License. Test.Summary = ''' -Test cached responses and requests with bodies +Test cached responses and cache-control directives ''' -Test.ContinueOnFail = True - -# Define default ATS -ts = Test.MakeATSProcess("ts") -server = Test.MakeOriginServer("server") - -# **testname is required** -testName = "" -request_header1 = {"headers": "GET / HTTP/1.1\r\nHost: www.example.com\r\n\r\n", "timestamp": "1469733493.993", "body": ""} -response_header1 = { - "headers": "HTTP/1.1 200 OK\r\nConnection: close\r\nCache-Control: max-age=300\r\n\r\n", - "timestamp": "1469733493.993", - "body": "xxx" -} -request_header2 = { - "headers": "GET /no_cache_control HTTP/1.1\r\nHost: www.example.com\r\n\r\n", - "timestamp": "1469733493.993", - "body": "" -} -response_header2 = { - "headers": "HTTP/1.1 200 OK\r\nConnection: close\r\n\r\n", - "timestamp": "1469733493.993", - "body": "the flinstones" -} -request_header3 = { - "headers": "GET /max_age_10sec HTTP/1.1\r\nHost: www.example.com\r\n\r\n", - "timestamp": "1469733493.993", - "body": "" -} -response_header3 = { - "headers": "HTTP/1.1 200 OK\r\nConnection: close\r\nCache-Control: max-age=10,public\r\n\r\n", - "timestamp": "1469733493.993", - "body": "yabadabadoo" -} -server.addResponse("sessionlog.json", request_header1, response_header1) -server.addResponse("sessionlog.json", request_header2, response_header2) -server.addResponse("sessionlog.json", request_header3, response_header3) - -# ATS Configuration -ts.Disk.plugin_config.AddLine('xdebug.so --enable=x-cache,x-cache-key,via') -ts.Disk.records_config.update( - { - 'proxy.config.diags.debug.enabled': 1, - 'proxy.config.diags.debug.tags': 'http', - 'proxy.config.http.response_via_str': 3, - 'proxy.config.http.insert_age_in_response': 0, - }) - -ts.Disk.remap_config.AddLine('map / http://127.0.0.1:{0}'.format(server.Variables.Port)) - -ipv4flag = "" -if not Condition.CurlUsingUnixDomainSocket(): - ipv4flag = "--ipv4" - -# Test 1 - 200 response and cache fill -tr = Test.AddTestRun() -tr.Processes.Default.StartBefore(server) -tr.Processes.Default.StartBefore(Test.Processes.ts) -tr.MakeCurlCommand( - '-s -D - -v {ipv4} --http1.1 -H "x-debug: x-cache,via" -H "Host: www.example.com" http://localhost:{port}/max_age_10sec'.format( - port=ts.Variables.port, ipv4=ipv4flag), - ts=ts) -tr.Processes.Default.ReturnCode = 0 -tr.Processes.Default.Streams.stdout = "gold/cache_and_req_body-miss.gold" -tr.StillRunningAfter = ts - -# Test 2 - 200 cached response and using netcat -tr = Test.AddTestRun() -tr.Processes.Default.Command = "printf 'GET /max_age_10sec HTTP/1.1\r\n''x-debug: x-cache,x-cache-key,via\r\n''Host: www.example.com\r\n''\r\n'|nc 127.0.0.1 -w 1 {port}".format( - port=ts.Variables.port) -tr.Processes.Default.ReturnCode = 0 -tr.Processes.Default.Streams.stdout = "gold/cache_and_req_body-hit.gold" -tr.StillRunningAfter = ts - -# Test 3 - response doesn't have cache control directive, so cache-miss every -# time -tr = Test.AddTestRun() -tr.Processes.Default.Command = "printf 'GET /no_cache_control HTTP/1.1\r\n''x-debug: x-cache,x-cache-key,via\r\n''Host: www.example.com\r\n''\r\n'|nc 127.0.0.1 -w 1 {port}".format( - port=ts.Variables.port) -tr.Processes.Default.ReturnCode = 0 -tr.Processes.Default.Streams.stdout = "gold/cache_no_cc.gold" -tr.StillRunningAfter = ts - -# Test 4 - hit stale cache. -tr = Test.AddTestRun() -tr.Processes.Default.Command = "sleep 15; printf 'GET /max_age_10sec HTTP/1.1\r\n''x-debug: x-cache,x-cache-key,via\r\n''Host: www.example.com\r\n''\r\n'|nc 127.0.0.1 -w 1 {port}".format( - port=ts.Variables.port) -tr.Processes.Default.ReturnCode = 0 -tr.Processes.Default.Streams.stdout = "gold/cache_hit_stale.gold" -tr.StillRunningAfter = ts - -# Test 5 - only-if-cached. 504 "Not Cached" should be returned if not in cache -tr = Test.AddTestRun() -tr.Processes.Default.Command = "printf 'GET /no_cache_control HTTP/1.1\r\n''Cache-Control: only-if-cached\r\n''x-debug: x-cache,x-cache-key,via\r\n''Host: www.example.com\r\n''Cache-control: max-age=300\r\n''\r\n'|nc 127.0.0.1 -w 1 {port}".format( - port=ts.Variables.port) -tr.Processes.Default.ReturnCode = 0 -tr.Processes.Default.Streams.stdout = "gold/cache_no_cache.gold" -tr.StillRunningAfter = ts - -# -# Verify correct handling of various max-age directives in both clients and -# responses. -# -ts = Test.MakeATSProcess("ts-for-proxy-verifier") -replay_file = "replay/cache-control-max-age.replay.yaml" -server = Test.MakeVerifierServerProcess("proxy-verifier-server", replay_file) -ts.Disk.records_config.update( - { - 'proxy.config.diags.debug.enabled': 1, - 'proxy.config.diags.debug.tags': 'http', - 'proxy.config.http.insert_age_in_response': 0, - - # Disable ignoring max-age in the client request so we can test that - # behavior too. - 'proxy.config.http.cache.ignore_client_cc_max_age': 0, - }) -ts.Disk.remap_config.AddLine('map / http://127.0.0.1:{0}'.format(server.Variables.http_port)) -tr = Test.AddTestRun("Verify correct max-age cache-control behavior.") -tr.Processes.Default.StartBefore(server) -tr.Processes.Default.StartBefore(ts) -tr.AddVerifierClientProcess("proxy-verifier-client", replay_file, http_ports=[ts.Variables.port]) - -# -# Verify correct handling of various s-maxage directives in responses. -# -ts = Test.MakeATSProcess("ts-s-maxage") -replay_file = "replay/cache-control-s-maxage.replay.yaml" -server = Test.MakeVerifierServerProcess("s-maxage-server", replay_file) -ts.Disk.records_config.update( - { - 'proxy.config.diags.debug.enabled': 1, - 'proxy.config.diags.debug.tags': 'http', - 'proxy.config.http.insert_age_in_response': 0, - }) -ts.Disk.remap_config.AddLine('map / http://127.0.0.1:{0}'.format(server.Variables.http_port)) -tr = Test.AddTestRun("Verify correct max-age cache-control behavior.") -tr.Processes.Default.StartBefore(server) -tr.Processes.Default.StartBefore(ts) -tr.AddVerifierClientProcess("s-maxage-client", replay_file, http_ports=[ts.Variables.port]) - -# -# Verify correct interaction between cache-control no-cache and pragma header -# -ts = Test.MakeATSProcess("ts-cache-control-pragma") -ts.Disk.records_config.update({ - 'proxy.config.diags.debug.enabled': 1, - 'proxy.config.diags.debug.tags': 'http|cache', -}) -tr = Test.AddTestRun("Verify Pragma: no-cache does not conflict with Cache-Control headers") -replay_file = "replay/cache-control-pragma.replay.yaml" -server = tr.AddVerifierServerProcess("pragma-server", replay_file) -tr.AddVerifierClientProcess("pragma-client", replay_file, http_ports=[ts.Variables.port]) -ts.Disk.remap_config.AddLine('map / http://127.0.0.1:{0}'.format(server.Variables.http_port)) -tr.Processes.Default.StartBefore(server) -tr.Processes.Default.StartBefore(ts) -tr.StillRunningAfter = ts - - -class RequestCacheControlDefaultTest: - # Verify the proper handling of cache-control directives in requests in - # default configuration - requestCacheControlReplayFile = "replay/request-cache-control-default.replay.yaml" - - def __init__(self): - self.setupOriginServer() - self.setupTS() - - def setupOriginServer(self): - self.server = Test.MakeVerifierServerProcess( - "request-cache-control-default-verifier-server", self.requestCacheControlReplayFile) - - def setupTS(self): - self.ts = Test.MakeATSProcess("ts-request-cache-control-default") - self.ts.Disk.records_config.update({ - "proxy.config.diags.debug.enabled": 1, - "proxy.config.diags.debug.tags": "http", - }) - self.ts.Disk.remap_config.AddLine(f"map / http://127.0.0.1:{self.server.Variables.http_port}/",) - - def runTraffic(self): - tr = Test.AddTestRun("Verify the proper handling of cache-control directives in requests in default configuration") - tr.AddVerifierClientProcess( - "request-cache-control-default-client", self.requestCacheControlReplayFile, http_ports=[self.ts.Variables.port]) - tr.Processes.Default.StartBefore(self.server) - tr.Processes.Default.StartBefore(self.ts) - tr.StillRunningAfter = self.server - tr.StillRunningAfter = self.ts - - def run(self): - self.runTraffic() - - -RequestCacheControlDefaultTest().run() - - -class RequestCacheControlHonorClientTest: - # Verify the proper handling of cache-control directives in requests when - # ATS is configured to honor client's request to bypass the cache - requestCacheControlReplayFile = "replay/request-cache-control-honor-client.replay.yaml" - - def __init__(self): - self.setupOriginServer() - self.setupTS() - - def setupOriginServer(self): - self.server = Test.MakeVerifierServerProcess( - "request-cache-control-honor-client-verifier-server", self.requestCacheControlReplayFile) - - def setupTS(self): - self.ts = Test.MakeATSProcess("ts-request-cache-control-honor-client") - self.ts.Disk.records_config.update( - { - "proxy.config.diags.debug.enabled": 1, - "proxy.config.diags.debug.tags": "http", - # Configured to honor client requests to bypass the cache - "proxy.config.http.cache.ignore_client_no_cache": 0 - }) - self.ts.Disk.remap_config.AddLine(f"map / http://127.0.0.1:{self.server.Variables.http_port}/",) - - # Verify logs for the request containing no-cache - self.ts.Disk.traffic_out.Content += Testers.ContainsExpression( - "Revalidate document with server", "Verify that ATS honors the no-cache and performs a revalidation.") - # Verify logs for the request containing no-store - self.ts.Disk.traffic_out.Content += Testers.ContainsExpression( - "client does not permit storing, and cache control does not say to ignore client no-cache", - "Verify that ATS honors the no-store.") - - def runTraffic(self): - tr = Test.AddTestRun( - "Verify the proper handling of cache-control directives in requests when ATS is configured to honor client's request to bypass the cache" - ) - tr.AddVerifierClientProcess( - "request-cache-control-honor-client-client", self.requestCacheControlReplayFile, http_ports=[self.ts.Variables.port]) - tr.Processes.Default.StartBefore(self.server) - tr.Processes.Default.StartBefore(self.ts) - tr.StillRunningAfter = self.server - tr.StillRunningAfter = self.ts - - def run(self): - self.runTraffic() - - -RequestCacheControlHonorClientTest().run() - - -class ResponseCacheControlDefaultTest: - # Verify the proper handling of cache-control directives in responses in - # default configuration - responseCacheControlReplayFile = "replay/response-cache-control-default.replay.yaml" - - def __init__(self): - self.setupOriginServer() - self.setupTS() - - def setupOriginServer(self): - self.server = Test.MakeVerifierServerProcess( - "response-cache-control-default-verifier-server", self.responseCacheControlReplayFile) - - def setupTS(self): - self.ts = Test.MakeATSProcess("ts-response-cache-control-default") - self.ts.Disk.records_config.update({ - "proxy.config.diags.debug.enabled": 1, - "proxy.config.diags.debug.tags": "http", - }) - self.ts.Disk.remap_config.AddLine(f"map / http://127.0.0.1:{self.server.Variables.http_port}/",) - - # Verify logs for the response containing no-cache - self.ts.Disk.traffic_out.Content += Testers.ContainsExpression( - "Revalidate document with server", "Verify that ATS honors the no-cache in response and performs a revalidation.") - # Verify logs for the response containing no-store - self.ts.Disk.traffic_out.Content += Testers.ContainsExpression( - "server does not permit storing and config file does not indicate that server directive should be ignored", - "Verify that ATS honors the no-store in response and bypasses the cache.") - - def runTraffic(self): - tr = Test.AddTestRun("Verify the proper handling of cache-control directives in responses in default configuration") - tr.AddVerifierClientProcess( - "response-cache-control-client-default", self.responseCacheControlReplayFile, http_ports=[self.ts.Variables.port]) - tr.Processes.Default.StartBefore(self.server) - tr.Processes.Default.StartBefore(self.ts) - tr.StillRunningAfter = self.server - tr.StillRunningAfter = self.ts - - def run(self): - self.runTraffic() - - -ResponseCacheControlDefaultTest().run() - - -class ResponseCacheControlIgnoredTest: - # Verify the proper handling of cache-control directives in responses when - # ATS is configured to ignore server's request to bypass the cache - responseCacheControlReplayFile = "replay/response-cache-control-ignored.replay.yaml" - - def __init__(self): - self.setupOriginServer() - self.setupTS() +# Basic cache operations: miss, hit, no-cache-control, stale, and only-if-cached +Test.ATSReplayTest(replay_file="replay/cache-control-basic.replay.yaml") - def setupOriginServer(self): - self.server = Test.MakeVerifierServerProcess( - "response-cache-control-ignored-verifier-server", self.responseCacheControlReplayFile) +# Max-age directives in both clients and responses +Test.ATSReplayTest(replay_file="replay/cache-control-max-age.replay.yaml") - def setupTS(self): - self.ts = Test.MakeATSProcess("ts-response-cache-control-ignored") - self.ts.Disk.records_config.update( - { - "proxy.config.diags.debug.enabled": 1, - "proxy.config.diags.debug.tags": "http", - "proxy.config.http.cache.ignore_server_no_cache": 1 - }) - self.ts.Disk.remap_config.AddLine(f"map / http://127.0.0.1:{self.server.Variables.http_port}/",) +# S-maxage directives in responses +Test.ATSReplayTest(replay_file="replay/cache-control-s-maxage.replay.yaml") - # Verify logs for the response containing no-cache or no-store - self.ts.Disk.traffic_out.Content += Testers.ExcludesExpression( - "Revalidate document with server", - "Verify that ATS ignores the no-cache in response and therefore doesn't perform a revalidation.") - self.ts.Disk.traffic_out.Content += Testers.ExcludesExpression( - "server does not permit storing and config file does not indicate that server directive should be ignored", - "Verify that ATS ignores the no-store in response and caches the responses despite its presence.") +# Interaction between cache-control no-cache and pragma header +Test.ATSReplayTest(replay_file="replay/cache-control-pragma.replay.yaml") - def runTraffic(self): - tr = Test.AddTestRun( - "Verify the proper handling of cache-control directives in responses when ATS is configured to ignore server's request to bypass the cache" - ) - tr.AddVerifierClientProcess( - "response-cache-control-client-ignored", self.responseCacheControlReplayFile, http_ports=[self.ts.Variables.port]) - tr.Processes.Default.StartBefore(self.server) - tr.Processes.Default.StartBefore(self.ts) - tr.StillRunningAfter = self.server - tr.StillRunningAfter = self.ts +# Request cache-control directives in default configuration +Test.ATSReplayTest(replay_file="replay/request-cache-control-default.replay.yaml") - def run(self): - self.runTraffic() +# Request cache-control directives when ATS honors client requests to bypass cache +Test.ATSReplayTest(replay_file="replay/request-cache-control-honor-client.replay.yaml") +# Response cache-control directives in default configuration +Test.ATSReplayTest(replay_file="replay/response-cache-control-default.replay.yaml") -ResponseCacheControlIgnoredTest().run() +# Response cache-control directives when ATS ignores server requests to bypass cache +Test.ATSReplayTest(replay_file="replay/response-cache-control-ignored.replay.yaml") diff --git a/tests/gold_tests/cache/cache-cookie.test.py b/tests/gold_tests/cache/cache-cookie.test.py index 01d781a3fed..64805406755 100644 --- a/tests/gold_tests/cache/cache-cookie.test.py +++ b/tests/gold_tests/cache/cache-cookie.test.py @@ -21,203 +21,17 @@ Test cookie-related caching behaviors ''' -Test.ContinueOnFail = True +# Verify correct caching behavior in default configuration +Test.ATSReplayTest(replay_file="replay/cookie-default.replay.yaml") -# **testname is required** -testName = "" +# Verify correct caching behavior when not caching responses to cookies +Test.ATSReplayTest(replay_file="replay/cookie-bypass-cache.replay.yaml") +# Verify correct caching behavior when caching only image responses to cookies +Test.ATSReplayTest(replay_file="replay/cookie-cache-img-only.replay.yaml") -class CookieDefaultTest: - # Verify the correct caching behavior when ATS is in default configuration - cookieDefaultReplayFile = "replay/cookie-default.replay.yaml" +# Verify correct caching behavior when caching all but text responses to cookies +Test.ATSReplayTest(replay_file="replay/cookie-all-but-text.replay.yaml") - def __init__(self): - self.setupOriginServer() - self.setupTS() - - def setupOriginServer(self): - self.server = Test.MakeVerifierServerProcess("cookie-default-verifier-server", self.cookieDefaultReplayFile) - - def setupTS(self): - self.ts = Test.MakeATSProcess("ts-cookie-default") - self.ts.Disk.records_config.update({ - "proxy.config.diags.debug.enabled": 1, - "proxy.config.diags.debug.tags": "http", - }) - self.ts.Disk.remap_config.AddLine(f"map / http://127.0.0.1:{self.server.Variables.http_port}/",) - - def runTraffic(self): - tr = Test.AddTestRun("Verify the correct caching behavior when ATS is in default configuration") - tr.AddVerifierClientProcess("cookie-default-client", self.cookieDefaultReplayFile, http_ports=[self.ts.Variables.port]) - tr.Processes.Default.StartBefore(self.server) - tr.Processes.Default.StartBefore(self.ts) - tr.StillRunningAfter = self.server - tr.StillRunningAfter = self.ts - - def run(self): - self.runTraffic() - - -CookieDefaultTest().run() - - -class CookieBypassTest: - # Verify the correct caching behavior when ATS is configured to not cache - # response to cookie for any content type - cookieBypassReplayFile = "replay/cookie-bypass-cache.replay.yaml" - - def __init__(self): - self.setupOriginServer() - self.setupTS() - - def setupOriginServer(self): - self.server = Test.MakeVerifierServerProcess("cookie-bypass-verifier-server", self.cookieBypassReplayFile) - - def setupTS(self): - self.ts = Test.MakeATSProcess("ts-cookie-bypass") - self.ts.Disk.records_config.update( - { - "proxy.config.diags.debug.enabled": 1, - "proxy.config.diags.debug.tags": "http", - # Bypass cache for any responses to cookies - "proxy.config.http.cache.cache_responses_to_cookies": 0 - }) - self.ts.Disk.remap_config.AddLine(f"map / http://127.0.0.1:{self.server.Variables.http_port}/",) - - def runTraffic(self): - tr = Test.AddTestRun( - "Verify the correct caching behavior when ATS is configured to not cache response to cookie for any content type") - tr.AddVerifierClientProcess("cookie-bypass-client", self.cookieBypassReplayFile, http_ports=[self.ts.Variables.port]) - tr.Processes.Default.StartBefore(self.server) - tr.Processes.Default.StartBefore(self.ts) - tr.StillRunningAfter = self.server - tr.StillRunningAfter = self.ts - - def run(self): - self.runTraffic() - - -CookieBypassTest().run() - - -class CookieImgOnlyTest: - # Verify the correct caching behavior when ATS is configured to cache - # response to cookie only for image content type - cookieImgOnlyReplayFile = "replay/cookie-cache-img-only.replay.yaml" - - def __init__(self): - self.setupOriginServer() - self.setupTS() - - def setupOriginServer(self): - self.server = Test.MakeVerifierServerProcess("cookie-img-only-verifier-server", self.cookieImgOnlyReplayFile) - - def setupTS(self): - self.ts = Test.MakeATSProcess("ts-cookie-img-only") - self.ts.Disk.records_config.update( - { - "proxy.config.diags.debug.enabled": 1, - "proxy.config.diags.debug.tags": "http", - # Cache only for image types - "proxy.config.http.cache.cache_responses_to_cookies": 2 - }) - self.ts.Disk.remap_config.AddLine(f"map / http://127.0.0.1:{self.server.Variables.http_port}/",) - - def runTraffic(self): - tr = Test.AddTestRun( - "Verify the correct caching behavior when ATS is configured to cache response to cookie only for image content type") - tr.AddVerifierClientProcess("cookie-img-only-client", self.cookieImgOnlyReplayFile, http_ports=[self.ts.Variables.port]) - tr.Processes.Default.StartBefore(self.server) - tr.Processes.Default.StartBefore(self.ts) - tr.StillRunningAfter = self.server - tr.StillRunningAfter = self.ts - - def run(self): - self.runTraffic() - - -CookieImgOnlyTest().run() - - -class CookieAllButTextTest: - # Verify the correct caching behavior when ATS is configured to cache - # response to cookie for all but text types - cookieAllButTextReplayFile = "replay/cookie-all-but-text.replay.yaml" - - def __init__(self): - self.setupOriginServer() - self.setupTS() - - def setupOriginServer(self): - self.server = Test.MakeVerifierServerProcess("cookie-all-but-text-verifier-server", self.cookieAllButTextReplayFile) - - def setupTS(self): - self.ts = Test.MakeATSProcess("ts-cookie-all-but-text") - self.ts.Disk.records_config.update( - { - "proxy.config.diags.debug.enabled": 1, - "proxy.config.diags.debug.tags": "http", - # Cache all content type except text - "proxy.config.http.cache.cache_responses_to_cookies": 3 - }) - self.ts.Disk.remap_config.AddLine(f"map / http://127.0.0.1:{self.server.Variables.http_port}/",) - - def runTraffic(self): - tr = Test.AddTestRun( - "Verify the correct caching behavior when ATS is configured to cache response to cookie for all but text types") - tr.AddVerifierClientProcess( - "cookie-all-but-text-client", self.cookieAllButTextReplayFile, http_ports=[self.ts.Variables.port]) - tr.Processes.Default.StartBefore(self.server) - tr.Processes.Default.StartBefore(self.ts) - tr.StillRunningAfter = self.server - tr.StillRunningAfter = self.ts - - def run(self): - self.runTraffic() - - -CookieAllButTextTest().run() - - -class CookieAllButTextWithExcpTest: - # Verify the correct caching behavior when ATS is configured to cache all - # content types but text, but with a few exceptions for text types which - # would also be cached - cookieAllButTextReplayFile = "replay/cookie-all-but-text-with-excp.replay.yaml" - - def __init__(self): - self.setupOriginServer() - self.setupTS() - - def setupOriginServer(self): - self.server = Test.MakeVerifierServerProcess( - "cookie-all-but-text-with-excp-verifier-server", self.cookieAllButTextReplayFile) - - def setupTS(self): - self.ts = Test.MakeATSProcess("ts-cookie-all-but-text-with-excp") - self.ts.Disk.records_config.update( - { - "proxy.config.diags.debug.enabled": 1, - "proxy.config.diags.debug.tags": "http", - # Cache all content type but text. Text type also gets cached for - # server responses without Set-Cookie or with Cache-Control: public - "proxy.config.http.cache.cache_responses_to_cookies": 4 - }) - self.ts.Disk.remap_config.AddLine(f"map / http://127.0.0.1:{self.server.Variables.http_port}/",) - - def runTraffic(self): - tr = Test.AddTestRun( - "Verify the correct caching behavior when ATS is configured to cache all content types but text, but with a few exceptions for text types which would also be cached" - ) - tr.AddVerifierClientProcess( - "cookie-all-but-text-with-excp-client", self.cookieAllButTextReplayFile, http_ports=[self.ts.Variables.port]) - tr.Processes.Default.StartBefore(self.server) - tr.Processes.Default.StartBefore(self.ts) - tr.StillRunningAfter = self.server - tr.StillRunningAfter = self.ts - - def run(self): - self.runTraffic() - - -CookieAllButTextWithExcpTest().run() +# Verify correct caching behavior for all but text with exceptions +Test.ATSReplayTest(replay_file="replay/cookie-all-but-text-with-excp.replay.yaml") diff --git a/tests/gold_tests/cache/cache-range-response.test.py b/tests/gold_tests/cache/cache-range-response.test.py index 4202095f077..f82ee7940d1 100644 --- a/tests/gold_tests/cache/cache-range-response.test.py +++ b/tests/gold_tests/cache/cache-range-response.test.py @@ -21,19 +21,5 @@ Verify correct caching behavior for range requests. ''' -ts = Test.MakeATSProcess("ts") -replay_file = "replay/cache-range-response.replay.yaml" -server = Test.MakeVerifierServerProcess("server0", replay_file) -ts.Disk.records_config.update( - { - 'proxy.config.diags.debug.enabled': 1, - 'proxy.config.diags.debug.tags': 'http.*|cache.*', - 'proxy.config.http.cache.range.write': 1, - 'proxy.config.http.cache.when_to_revalidate': 4, - 'proxy.config.http.insert_response_via_str': 3, - }) -ts.Disk.remap_config.AddLine(f'map / http://127.0.0.1:{server.Variables.http_port}') -tr = Test.AddTestRun("Verify range request is transformed from a 200 response") -tr.Processes.Default.StartBefore(server) -tr.Processes.Default.StartBefore(ts) -tr.AddVerifierClientProcess("client0", replay_file, http_ports=[ts.Variables.port]) +# Verify range request is transformed from a 200 response. +Test.ATSReplayTest(replay_file="replay/cache-range-response.replay.yaml") diff --git a/tests/gold_tests/cache/cache-request-method.test.py b/tests/gold_tests/cache/cache-request-method.test.py index 21fd65517dd..6e702a222e7 100644 --- a/tests/gold_tests/cache/cache-request-method.test.py +++ b/tests/gold_tests/cache/cache-request-method.test.py @@ -21,78 +21,14 @@ Verify correct caching behavior with respect to request method. ''' -# Test 0: Verify correct POST response handling when caching POST responses is -# disabled. -tr = Test.AddTestRun("Verify correct with POST response caching disabled.") -ts = tr.MakeATSProcess("ts") -replay_file = "replay/post_with_post_caching_disabled.replay.yaml" -server = tr.AddVerifierServerProcess("server0", replay_file) -ts.Disk.records_config.update( - { - 'proxy.config.diags.debug.enabled': 1, - 'proxy.config.diags.debug.tags': 'http.*|cache.*', - 'proxy.config.http.insert_age_in_response': 0, +# Verify correct POST response handling when caching POST responses is disabled +Test.ATSReplayTest(replay_file="replay/post_with_post_caching_disabled.replay.yaml") - # Caching of POST responses is disabled by default. Verify default behavior - # by leaving it unconfigured. - # 'proxy.config.http.cache.post_method': 0, - }) -ts.Disk.remap_config.AddLine('map / http://127.0.0.1:{0}'.format(server.Variables.http_port)) -tr.Processes.Default.StartBefore(server) -tr.Processes.Default.StartBefore(ts) -tr.AddVerifierClientProcess("client0", replay_file, http_ports=[ts.Variables.port]) +# Verify correct POST response handling when caching POST responses is enabled +Test.ATSReplayTest(replay_file="replay/post_with_post_caching_enabled.replay.yaml") -# Test 1: Verify correct POST response handling when caching POST responses is -# enabled. -tr = Test.AddTestRun("Verify correct with POST response caching enabled.") -ts = tr.MakeATSProcess("ts-cache-post") -replay_file = "replay/post_with_post_caching_enabled.replay.yaml" -server = tr.AddVerifierServerProcess("server1", replay_file) -ts.Disk.records_config.update( - { - 'proxy.config.diags.debug.enabled': 1, - 'proxy.config.diags.debug.tags': 'http.*|cache.*', - 'proxy.config.http.insert_age_in_response': 0, - 'proxy.config.http.cache.post_method': 1, - }) -ts.Disk.remap_config.AddLine('map / http://127.0.0.1:{0}'.format(server.Variables.http_port)) -tr.Processes.Default.StartBefore(server) -tr.Processes.Default.StartBefore(ts) -tr.AddVerifierClientProcess("client1", replay_file, http_ports=[ts.Variables.port]) +# Verify correct POST response handling when caching POST responses is enabled via overridable config +Test.ATSReplayTest(replay_file="replay/post_with_post_caching_override.replay.yaml") -# Test 2: Verify correct POST response handling when caching POST responses is -# enabled via an overridable config. -tr = Test.AddTestRun("Verify correct with POST response caching enabled overridably.") -ts = tr.MakeATSProcess("ts-cache-post-override") -replay_file = "replay/post_with_post_caching_enabled.replay.yaml" -server = tr.AddVerifierServerProcess("server2", replay_file) -ts.Disk.records_config.update( - { - 'proxy.config.diags.debug.enabled': 1, - 'proxy.config.diags.debug.tags': 'http.*|cache.*', - 'proxy.config.http.insert_age_in_response': 0, - # Override the following in remap.config. - 'proxy.config.http.cache.post_method': 0, - }) -ts.Disk.remap_config.AddLine( - f'map / http://127.0.0.1:{server.Variables.http_port} ' - '@plugin=conf_remap.so @pparam=proxy.config.http.cache.post_method=1') -tr.Processes.Default.StartBefore(server) -tr.Processes.Default.StartBefore(ts) -tr.AddVerifierClientProcess("client2", replay_file, http_ports=[ts.Variables.port]) - -# Test 3: Verify correct HEAD response handling with cached GET response -tr = Test.AddTestRun("Verify correct with HEAD response.") -ts = tr.MakeATSProcess("ts-cache-head") -replay_file = "replay/head_with_get_cached.replay.yaml" -server = tr.AddVerifierServerProcess("server3", replay_file) -ts.Disk.records_config.update( - { - 'proxy.config.diags.debug.enabled': 1, - 'proxy.config.diags.debug.tags': 'http.*|cache.*', - 'proxy.config.http.insert_age_in_response': 0, - }) -ts.Disk.remap_config.AddLine('map / http://127.0.0.1:{0}'.format(server.Variables.http_port)) -tr.Processes.Default.StartBefore(server) -tr.Processes.Default.StartBefore(ts) -tr.AddVerifierClientProcess("client3", replay_file, http_ports=[ts.Variables.port]) +# Verify correct HEAD response handling with cached GET response +Test.ATSReplayTest(replay_file="replay/head_with_get_cached.replay.yaml") diff --git a/tests/gold_tests/cache/conditional-get-hit.test.py b/tests/gold_tests/cache/conditional-get-hit.test.py index f3df0a1f4ed..22b15e52954 100644 --- a/tests/gold_tests/cache/conditional-get-hit.test.py +++ b/tests/gold_tests/cache/conditional-get-hit.test.py @@ -21,18 +21,5 @@ Test conditional get with body drains the body from client" ''' -ts = Test.MakeATSProcess("ts-conditional-get-caching") -ts.Disk.records_config.update( - { - 'proxy.config.diags.debug.enabled': 1, - 'proxy.config.diags.debug.tags': 'http|cache', - 'proxy.config.http.cache.max_stale_age': 6, - }) -tr = Test.AddTestRun("Verify conditional get with cache hit drain client body") -replay_file = "replay/conditional-get-cache-hit.yaml" -server = tr.AddVerifierServerProcess("server1", replay_file) -server_port = server.Variables.http_port -tr.AddVerifierClientProcess("client1", replay_file, http_ports=[ts.Variables.port]) -ts.Disk.remap_config.AddLine('map / http://127.0.0.1:{0}'.format(server_port)) -tr.Processes.Default.StartBefore(ts) -tr.StillRunningAfter = ts +# Verify conditional get with cache hit drains client body. +Test.ATSReplayTest(replay_file="replay/conditional-get-cache-hit.yaml") diff --git a/tests/gold_tests/cache/gold/cache_and_req_body-hit.gold b/tests/gold_tests/cache/gold/cache_and_req_body-hit.gold deleted file mode 100644 index 34bb179c50b..00000000000 --- a/tests/gold_tests/cache/gold/cache_and_req_body-hit.gold +++ /dev/null @@ -1,10 +0,0 @@ -HTTP/1.1 200 OK -Cache-Control: max-age=10,public -Content-Length: 11 -Date: `` -Connection: keep-alive -Via: `` -Server: `` -X-Cache: hit-fresh -`` -yabadabadoo`` diff --git a/tests/gold_tests/cache/gold/cache_and_req_body-miss.gold b/tests/gold_tests/cache/gold/cache_and_req_body-miss.gold deleted file mode 100644 index 33efb4bac07..00000000000 --- a/tests/gold_tests/cache/gold/cache_and_req_body-miss.gold +++ /dev/null @@ -1,10 +0,0 @@ -HTTP/1.1 200 OK -Cache-Control: max-age=10,public -Content-Length: 11 -Date: `` -Connection: keep-alive -Via: `` -Server: `` -X-Cache: miss -`` -yabadabadoo`` diff --git a/tests/gold_tests/cache/gold/cache_hit_stale.gold b/tests/gold_tests/cache/gold/cache_hit_stale.gold deleted file mode 100644 index 25a3d6670ca..00000000000 --- a/tests/gold_tests/cache/gold/cache_hit_stale.gold +++ /dev/null @@ -1,10 +0,0 @@ -HTTP/1.1 200 OK -Cache-Control: max-age=10,public -Content-Length: 11 -Date: `` -Connection: keep-alive -Via: `` -Server: `` -X-Cache: hit-stale -`` -yabadabadoo`` diff --git a/tests/gold_tests/cache/gold/cache_no_cache.gold b/tests/gold_tests/cache/gold/cache_no_cache.gold deleted file mode 100644 index 6cadfa0c284..00000000000 --- a/tests/gold_tests/cache/gold/cache_no_cache.gold +++ /dev/null @@ -1,12 +0,0 @@ -HTTP/1.1 504 Not Cached `` -Date: `` -Connection: keep-alive -Via: http/1.1 `` -Server: `` -Cache-Control: no-store -Content-Type: text/html -Content-Language: en -`` -X-Cache: miss -Content-Length: 340 -`` diff --git a/tests/gold_tests/cache/gold/cache_no_cc.gold b/tests/gold_tests/cache/gold/cache_no_cc.gold deleted file mode 100644 index 7f50b005e62..00000000000 --- a/tests/gold_tests/cache/gold/cache_no_cc.gold +++ /dev/null @@ -1,9 +0,0 @@ -HTTP/1.1 200 OK -Content-Length: 14 -Date: `` -Connection: keep-alive -Via: `` -Server: `` -X-Cache: miss -`` -the flinstones`` diff --git a/tests/gold_tests/cache/gold/two_alternates_evicted.gold b/tests/gold_tests/cache/gold/two_alternates_evicted.gold index 3b10b2c9b2d..d6bce37e504 100644 --- a/tests/gold_tests/cache/gold/two_alternates_evicted.gold +++ b/tests/gold_tests/cache/gold/two_alternates_evicted.gold @@ -1,3 +1,3 @@ `` -``STATUS: The maximum number of alternates was exceeded for a resource. An alternate was evicted for URL: http://127.0.0.1:``/same/path/for/all/requests -``STATUS: The maximum number of alternates was exceeded for a resource. An alternate was evicted for URL: http://127.0.0.1:``/same/path/for/all/requests +``STATUS: The maximum number of alternates was exceeded for a resource. An alternate was evicted for URL: http://backend.example.com:``/same/path/for/all/requests +``STATUS: The maximum number of alternates was exceeded for a resource. An alternate was evicted for URL: http://backend.example.com:``/same/path/for/all/requests diff --git a/tests/gold_tests/cache/negative-caching.test.py b/tests/gold_tests/cache/negative-caching.test.py index 1c5cf2ac0ed..d2e7ffea12d 100644 --- a/tests/gold_tests/cache/negative-caching.test.py +++ b/tests/gold_tests/cache/negative-caching.test.py @@ -21,66 +21,18 @@ Test negative caching. ''' -# -# Negative caching disabled. -# -ts = Test.MakeATSProcess("ts-disabled") -replay_file = "replay/negative-caching-disabled.replay.yaml" -server = Test.MakeVerifierServerProcess("server-disabled", replay_file) -ts.Disk.records_config.update( - { - 'proxy.config.diags.debug.enabled': 1, - 'proxy.config.diags.debug.tags': 'http', - 'proxy.config.http.insert_age_in_response': 0, - 'proxy.config.http.negative_caching_enabled': 0 - }) -ts.Disk.remap_config.AddLine('map / http://127.0.0.1:{0}'.format(server.Variables.http_port)) -tr = Test.AddTestRun("Verify correct behavior without negative caching enabled.") -tr.Processes.Default.StartBefore(server) -tr.Processes.Default.StartBefore(ts) -tr.AddVerifierClientProcess("client-disabled", replay_file, http_ports=[ts.Variables.port]) +# Negative caching disabled +Test.ATSReplayTest(replay_file="replay/negative-caching-disabled.replay.yaml") -# -# Negative caching enabled with otherwise default configuration. -# -ts = Test.MakeATSProcess("ts-default") -replay_file = "replay/negative-caching-default.replay.yaml" -server = Test.MakeVerifierServerProcess("server-default", replay_file) -ts.Disk.records_config.update( - { - 'proxy.config.diags.debug.enabled': 1, - 'proxy.config.diags.debug.tags': 'http', - 'proxy.config.http.insert_age_in_response': 0, - 'proxy.config.http.negative_caching_enabled': 1 - }) -ts.Disk.remap_config.AddLine('map / http://127.0.0.1:{0}'.format(server.Variables.http_port)) -tr = Test.AddTestRun("Verify default negative caching behavior") -tr.Processes.Default.StartBefore(server) -tr.Processes.Default.StartBefore(ts) -tr.AddVerifierClientProcess("client-default", replay_file, http_ports=[ts.Variables.port]) +# Negative caching enabled with default configuration +Test.ATSReplayTest(replay_file="replay/negative-caching-default.replay.yaml") -# -# Customized response caching for negative caching configuration. -# -ts = Test.MakeATSProcess("ts-customized") -replay_file = "replay/negative-caching-customized.replay.yaml" -server = Test.MakeVerifierServerProcess("server-customized", replay_file) -ts.Disk.records_config.update( - { - 'proxy.config.diags.debug.enabled': 1, - 'proxy.config.diags.debug.tags': 'http', - 'proxy.config.http.insert_age_in_response': 0, - 'proxy.config.http.negative_caching_enabled': 1, - 'proxy.config.http.negative_caching_list': "400" - }) -ts.Disk.remap_config.AddLine('map / http://127.0.0.1:{0}'.format(server.Variables.http_port)) -tr = Test.AddTestRun("Verify customized negative caching list") -tr.Processes.Default.StartBefore(server) -tr.Processes.Default.StartBefore(ts) -tr.AddVerifierClientProcess("client-customized", replay_file, http_ports=[ts.Variables.port]) +# Customized response caching for negative caching configuration +Test.ATSReplayTest(replay_file="replay/negative-caching-customized.replay.yaml") # # Verify correct proxy.config.http.negative_caching_lifetime behavior. +# These tests require multiple test runs with shared ATS processes, so use class-based approach. # ts = Test.MakeATSProcess("ts-lifetime") ts.Disk.records_config.update( diff --git a/tests/gold_tests/cache/negative-revalidating.test.py b/tests/gold_tests/cache/negative-revalidating.test.py index 21519e62169..30071d147e4 100644 --- a/tests/gold_tests/cache/negative-revalidating.test.py +++ b/tests/gold_tests/cache/negative-revalidating.test.py @@ -17,102 +17,15 @@ # See the License for the specific language governing permissions and # limitations under the License. -import os - Test.Summary = ''' Test the negative revalidating feature. ''' +# Verify negative revalidating disabled +Test.ATSReplayTest(replay_file="replay/negative-revalidating-disabled.replay.yaml") -class NegativeRevalidatingTest: - _test_num: int = 0 - - def __init__(self, name: str, records_config: dict, replay_file: str, gold_access_log=""): - self._tr = Test.AddTestRun(name) - self._replay_file = replay_file - - self.__setupOriginServer() - self.__setupTS(records_config) - self.__setupClient() - - if gold_access_log: - self.__testAccessLog(gold_access_log) - - NegativeRevalidatingTest._test_num += 1 - - def __setupClient(self): - self._tr.AddVerifierClientProcess( - f"client-{NegativeRevalidatingTest._test_num}", self._replay_file, http_ports=[self._ts.Variables.port]) - - def __setupOriginServer(self): - self._server = self._tr.AddVerifierServerProcess(f"server-{NegativeRevalidatingTest._test_num}", self._replay_file) - - def __setupTS(self, records_config): - self._ts = Test.MakeATSProcess(f"ts-{NegativeRevalidatingTest._test_num}") - self._ts.Disk.records_config.update(records_config) - self._ts.Disk.remap_config.AddLine('map / http://127.0.0.1:{0}'.format(self._server.Variables.http_port)) - self._ts.Disk.logging_yaml.AddLines( - ''' -logging: - formats: - - name: access - format: '%<{uuid}cqh> % % %' - logs: - - filename: access - format: access - mode: ascii -'''.split("\n")) - - def __testAccessLog(self, gold_access_log): - Test.Disk.File(os.path.join(self._ts.Variables.LOGDIR, 'access.log'), exists=True, content=gold_access_log) - - def run(self): - self._tr.Processes.Default.StartBefore(self._ts) - self._tr.StillRunningAfter = self._ts +# Verify negative revalidating enabled +Test.ATSReplayTest(replay_file="replay/negative-revalidating-enabled.replay.yaml") - -# -# Verify disabled negative_revalidating behavior. -# -NegativeRevalidatingTest( - "Verify negative revalidating disabled", { - 'proxy.config.diags.debug.enabled': 1, - 'proxy.config.diags.debug.tags': 'http|cache', - 'proxy.config.http.insert_age_in_response': 0, - 'proxy.config.http.insert_response_via_str': 2, - 'proxy.config.http.negative_revalidating_enabled': 0, - 'proxy.config.http.cache.max_stale_age': 6 - }, "replay/negative-revalidating-disabled.replay.yaml").run() - -# -# Verify enabled negative_revalidating behavior. -# -NegativeRevalidatingTest( - "Verify negative revalidating enabled", - { - 'proxy.config.diags.debug.enabled': 1, - 'proxy.config.diags.debug.tags': 'http|cache', - 'proxy.config.http.insert_age_in_response': 0, - 'proxy.config.http.insert_response_via_str': 2, - - # Negative revalidating is on by default. Verify this by leaving out the - # following line and expect negative_revalidating to be enabled. - # 'proxy.config.http.negative_revalidating_enabled': 1, - 'proxy.config.http.cache.max_stale_age': 6 - }, - "replay/negative-revalidating-enabled.replay.yaml", - "gold/negative-revalidating-enabled-access.gold").run() - -# -# Verify negative_revalidating list behavior. -# -NegativeRevalidatingTest( - "Verify negative_revalidating_list behavior", { - 'proxy.config.diags.debug.enabled': 1, - 'proxy.config.diags.debug.tags': 'http|cache', - 'proxy.config.http.insert_age_in_response': 0, - 'proxy.config.http.insert_response_via_str': 2, - 'proxy.config.http.cache.max_stale_age': 6, - 'proxy.config.http.negative_revalidating_enabled': 1, - 'proxy.config.http.negative_revalidating_list': "403 404" - }, "replay/negative-revalidating-list.replay.yaml").run() +# Verify negative_revalidating_list behavior +Test.ATSReplayTest(replay_file="replay/negative-revalidating-list.replay.yaml") diff --git a/tests/gold_tests/cache/replay/alternate-caching-update-size.yaml b/tests/gold_tests/cache/replay/alternate-caching-update-size.yaml index ddc4a461942..ad7fdda5938 100644 --- a/tests/gold_tests/cache/replay/alternate-caching-update-size.yaml +++ b/tests/gold_tests/cache/replay/alternate-caching-update-size.yaml @@ -50,6 +50,37 @@ meta: - [ Accept-Language, es_US ] delay: 100ms +autest: + description: 'Verify disabled negative revalidating behavior' + + dns: + name: 'dns-alternate-caching' + + server: + name: 'server-alternate-caching' + + client: + name: 'client-alternate-caching' + + ats: + name: 'ts-alternate-caching' + process_config: + enable_cache: true + + records_config: + proxy.config.diags.debug.enabled: 1 + proxy.config.diags.debug.tags: 'http|cache' + proxy.config.http.cache.max_stale_age: 6 + proxy.config.cache.select_alternate: 1 + proxy.config.cache.limits.http.max_alts: 4 + proxy.config.http.negative_revalidating_enabled: 1 + proxy.config.http.negative_caching_enabled: 1 + proxy.config.http.negative_caching_lifetime: 30 + + remap_config: + - from: "http://example.com/" + to: "http://backend.example.com:{SERVER_HTTP_PORT}/" + sessions: - transactions: # These first two requests just store the two alternats for this url diff --git a/tests/gold_tests/cache/replay/auth-default.replay.yaml b/tests/gold_tests/cache/replay/auth-default.replay.yaml deleted file mode 100644 index d68cdffc502..00000000000 --- a/tests/gold_tests/cache/replay/auth-default.replay.yaml +++ /dev/null @@ -1,68 +0,0 @@ -# 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 assumes that caching is enabled and -# proxy.config.http.cache.ignore_authentication is set to 0(current default) -# -meta: - version: "1.0" - -sessions: - - transactions: - # Verify the response containing WWW-Authenticate is not cached - - client-request: - method: "GET" - version: "1.1" - url: /cc/auth - headers: - fields: - - [uuid, cc-www-auth-response] - - [Host, example.com] - - server-response: - status: 401 - reason: Unauthorized - headers: - fields: - - [Content-Length, 4] - - [Cache-Control, "max-age=5"] - - [WWW-Authenticate, "Basic"] - - proxy-response: - status: 401 - - # Re-request to make sure the previous response was not cached - - client-request: - # Add a delay so ATS has time to finish any caching IO for the - # previous transaction. - delay: 100ms - method: "GET" - version: "1.1" - url: /cc/auth - headers: - fields: - - [uuid, cc-www-auth-response-verify] - - [Host, example.com] - - [Authorization, "Basic ZGVtbzphdHNAc3Ryb25ncHc="] - - server-response: - status: 200 - reason: OK - - # Verify that the new 200 response is returned instead of the 401 - proxy-response: - status: 200 diff --git a/tests/gold_tests/cache/replay/auth-ignored.replay.yaml b/tests/gold_tests/cache/replay/auth-ignored.replay.yaml deleted file mode 100644 index b0361fffcc0..00000000000 --- a/tests/gold_tests/cache/replay/auth-ignored.replay.yaml +++ /dev/null @@ -1,67 +0,0 @@ -# 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 assumes that caching is enabled and -# proxy.config.http.cache.ignore_authentication is set to 1 -# -meta: - version: "1.0" - -sessions: - - transactions: - # Verify that response containing WWW-Authenticate is cached - - client-request: - method: "GET" - version: "1.1" - url: /cc/auth - headers: - fields: - - [uuid, cc-www-auth-response] - - [Host, example.com] - - server-response: - status: 401 - reason: Unauthorized - headers: - fields: - - [Content-Length, 4] - - [Cache-Control, "max-age=5"] - - [WWW-Authenticate, "Basic"] - - proxy-response: - status: 401 - # Re-request to make sure the previous response was not cached - - client-request: - # Add a delay so ATS has time to finish any caching IO for the - # previous transaction. - delay: 100ms - method: "GET" - version: "1.1" - url: /cc/auth - headers: - fields: - - [uuid, cc-www-auth-response-verify] - - [Host, example.com] - - [Authorization, "Basic ZGVtbzphdHNAc3Ryb25ncHc="] - - server-response: - status: 200 - reason: OK - - # Verify that the cached 401 response is returned - proxy-response: - status: 401 diff --git a/tests/gold_tests/cache/replay/cache-control-basic.replay.yaml b/tests/gold_tests/cache/replay/cache-control-basic.replay.yaml new file mode 100644 index 00000000000..6e80c34930e --- /dev/null +++ b/tests/gold_tests/cache/replay/cache-control-basic.replay.yaml @@ -0,0 +1,217 @@ +# 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" + +# Configuration section for autest integration +autest: + description: 'Test basic cache operations: miss, hit, no-cache-control, stale, and only-if-cached' + + dns: + name: 'dns-cache-basic' + + server: + name: 'server-cache-basic' + + client: + name: 'client-cache-basic' + + ats: + name: 'ts-cache-basic' + process_config: + enable_cache: true + + plugin_config: + - 'xdebug.so --enable=x-cache,x-cache-key,via' + + records_config: + proxy.config.diags.debug.enabled: 1 + proxy.config.diags.debug.tags: 'http' + proxy.config.http.response_via_str: 3 + proxy.config.http.insert_age_in_response: 0 + + remap_config: + - from: "http://www.example.com/" + to: "http://backend.example.com:{SERVER_HTTP_PORT}/" + +sessions: +- transactions: + + ############################################################################# + # Test 1: Cache miss - populate cache with max-age=1 + ############################################################################# + - client-request: + method: GET + url: /cacheable + version: '1.1' + headers: + fields: + - [Host, www.example.com] + - [x-debug, "x-cache,x-cache-key,via"] + - [uuid, cache-miss] + + server-response: + status: 200 + reason: OK + headers: + fields: + - [Content-Type, text/plain] + - [Content-Length, "3"] + - [Cache-Control, "max-age=1"] + content: + encoding: plain + data: xxx + + proxy-response: + status: 200 + headers: + fields: + - [Cache-Control, { value: "max-age=1", as: equal }] + - [X-Cache, { value: "miss", as: equal }] + - [X-Cache-Key, { value: "http://", as: contains }] + content: + encoding: plain + data: xxx + verify: { as: equal } + + ############################################################################# + # Test 2: Cache hit-fresh - retrieve from cache + ############################################################################# + - client-request: + delay: 100ms + method: GET + url: /cacheable + version: '1.1' + headers: + fields: + - [Host, www.example.com] + - [x-debug, "x-cache,x-cache-key,via"] + - [uuid, cache-hit] + + # Server should not receive this request (it's cached) + server-response: + status: 404 + reason: Not Found + + # Expect cached 200 response + proxy-response: + status: 200 + headers: + fields: + - [Cache-Control, { value: "max-age=1", as: equal }] + - [X-Cache, { value: "hit-fresh", as: equal }] + content: + encoding: plain + data: xxx + verify: { as: equal } + + ############################################################################# + # Test 3: No cache-control - response without caching directive (cache miss) + ############################################################################# + - client-request: + method: GET + url: /no_cache_control + version: '1.1' + headers: + fields: + - [Host, www.example.com] + - [x-debug, "x-cache,x-cache-key,via"] + - [uuid, no-cache-control] + + server-response: + status: 200 + reason: OK + headers: + fields: + - [Content-Type, text/plain] + - [Content-Length, "14"] + # No Cache-Control header + content: + encoding: plain + data: "the flinstones" + + proxy-response: + status: 200 + headers: + fields: + - [X-Cache, { value: "miss", as: equal }] + content: + encoding: plain + data: "the flinstones" + verify: { as: equal } + + ############################################################################# + # Test 4: Hit stale cache - wait for cache entry to become stale + ############################################################################# + - client-request: + # Wait for the cache entry from Test 1 to become stale + delay: 2s + method: GET + url: /cacheable + version: '1.1' + headers: + fields: + - [Host, www.example.com] + - [x-debug, "x-cache,x-cache-key,via"] + - [uuid, cache-hit-stale] + + # Server should receive revalidation request + server-response: + status: 200 + reason: OK + headers: + fields: + - [Content-Type, text/plain] + - [Content-Length, "3"] + - [Cache-Control, "max-age=1"] + content: + encoding: plain + data: xxx + + proxy-response: + status: 200 + headers: + fields: + - [X-Cache, { value: "hit-stale", as: equal }] + + ############################################################################# + # Test 5: only-if-cached - should return 504 if not in cache + ############################################################################# + - client-request: + method: GET + url: /not_in_cache + version: '1.1' + headers: + fields: + - [Host, www.example.com] + - [Cache-Control, "only-if-cached"] + - [x-debug, "x-cache,x-cache-key,via"] + - [uuid, only-if-cached] + + # Server should not be contacted for only-if-cached requests + server-response: + status: 200 + reason: OK + + # Should get 504 Not Cached + proxy-response: + status: 504 + reason: "Not Cached" + headers: + fields: + - [X-Cache, { value: "miss", as: equal }] + - [Cache-Control, { value: "no-store", as: equal }] diff --git a/tests/gold_tests/cache/replay/cache-control-max-age.replay.yaml b/tests/gold_tests/cache/replay/cache-control-max-age.replay.yaml index d97bf1531d8..2a1fdec6faf 100644 --- a/tests/gold_tests/cache/replay/cache-control-max-age.replay.yaml +++ b/tests/gold_tests/cache/replay/cache-control-max-age.replay.yaml @@ -23,6 +23,35 @@ meta: version: "1.0" +# Configuration section for autest integration +autest: + description: 'Verify correct handling of various max-age directives in both clients and responses' + + dns: + name: 'dns-max_age' + + server: + name: 'proxy-verifier-server' + + client: + name: 'proxy-verifier-client' + + ats: + name: 'ts-for-proxy-verifier' + process_config: + enable_cache: true + + records_config: + proxy.config.diags.debug.enabled: 1 + proxy.config.diags.debug.tags: 'http' + proxy.config.http.insert_age_in_response: 0 + # Disable ignoring max-age in the client request so we can test that behavior too. + proxy.config.http.cache.ignore_client_cc_max_age: 0 + + remap_config: + - from: "http://example.com/" + to: "http://backend.example.com:{SERVER_HTTP_PORT}/" + blocks: - request_for_positive_max_age: &request_for_positive_max_age client-request: diff --git a/tests/gold_tests/cache/replay/cache-control-pragma.replay.yaml b/tests/gold_tests/cache/replay/cache-control-pragma.replay.yaml index 5cd57131789..a691977d091 100644 --- a/tests/gold_tests/cache/replay/cache-control-pragma.replay.yaml +++ b/tests/gold_tests/cache/replay/cache-control-pragma.replay.yaml @@ -23,6 +23,32 @@ meta: version: "1.0" +# Configuration section for autest integration +autest: + description: 'Verify correct interaction between cache-control no-cache and pragma header' + + dns: + name: 'dns-pragma' + + server: + name: 'pragma-server' + + client: + name: 'pragma-client' + + ats: + name: 'ts-cache-control-pragma' + process_config: + enable_cache: true + + records_config: + proxy.config.diags.debug.enabled: 1 + proxy.config.diags.debug.tags: 'http|cache' + + remap_config: + - from: "http://example.com/" + to: "http://backend.example.com:{SERVER_HTTP_PORT}/" + sessions: - transactions: # Pragma: no-cache will prevent caching diff --git a/tests/gold_tests/cache/replay/cache-control-s-maxage.replay.yaml b/tests/gold_tests/cache/replay/cache-control-s-maxage.replay.yaml index f8cd29dbfd6..6bab36d5672 100644 --- a/tests/gold_tests/cache/replay/cache-control-s-maxage.replay.yaml +++ b/tests/gold_tests/cache/replay/cache-control-s-maxage.replay.yaml @@ -21,6 +21,33 @@ meta: version: "1.0" +# Configuration section for autest integration +autest: + description: 'Verify correct handling of various s-maxage directives in responses' + + dns: + name: 'dns-s_maxage' + + server: + name: 's-maxage-server' + + client: + name: 's-maxage-client' + + ats: + name: 'ts-s-maxage' + process_config: + enable_cache: true + + records_config: + proxy.config.diags.debug.enabled: 1 + proxy.config.diags.debug.tags: 'http' + proxy.config.http.insert_age_in_response: 0 + + remap_config: + - from: "http://example.com/" + to: "http://backend.example.com:{SERVER_HTTP_PORT}/" + blocks: - request_for_positive_s_maxage: &request_for_positive_s_maxage client-request: diff --git a/tests/gold_tests/cache/replay/cache-range-response.replay.yaml b/tests/gold_tests/cache/replay/cache-range-response.replay.yaml index 0bb4d2271ef..1399f4f69d0 100644 --- a/tests/gold_tests/cache/replay/cache-range-response.replay.yaml +++ b/tests/gold_tests/cache/replay/cache-range-response.replay.yaml @@ -18,6 +18,34 @@ meta: version: "1.0" +autest: + description: 'Verify correct caching behavior for range requests' + + dns: + name: 'dns-range-response' + + server: + name: 'server-range-response' + + client: + name: 'client-range-response' + + ats: + name: 'ts-range-response' + process_config: + enable_cache: true + + records_config: + proxy.config.diags.debug.enabled: 1 + proxy.config.diags.debug.tags: 'http.*|cache.*' + proxy.config.http.cache.range.write: 1 + proxy.config.http.cache.when_to_revalidate: 4 + proxy.config.http.insert_response_via_str: 3 + + remap_config: + - from: "http://example.com/" + to: "http://backend.example.com:{SERVER_HTTP_PORT}/" + sessions: - transactions: # Populate the cache with a response to a GET request. diff --git a/tests/gold_tests/cache/replay/conditional-get-cache-hit.yaml b/tests/gold_tests/cache/replay/conditional-get-cache-hit.yaml index a1d838f5d08..f5e75382a9d 100644 --- a/tests/gold_tests/cache/replay/conditional-get-cache-hit.yaml +++ b/tests/gold_tests/cache/replay/conditional-get-cache-hit.yaml @@ -17,6 +17,32 @@ meta: version: "1.0" +autest: + description: 'Verify conditional get with cache hit drains client body' + + dns: + name: 'dns-conditional-get' + + server: + name: 'server-conditional-get' + + client: + name: 'client-conditional-get' + + ats: + name: 'ts-conditional-get-caching' + process_config: + enable_cache: true + + records_config: + proxy.config.diags.debug.enabled: 1 + proxy.config.diags.debug.tags: 'http|cache' + proxy.config.http.cache.max_stale_age: 6 + + remap_config: + - from: "http://example.com/" + to: "http://backend.example.com:{SERVER_HTTP_PORT}/" + sessions: - transactions: # Cache a request diff --git a/tests/gold_tests/cache/replay/cookie-all-but-text-with-excp.replay.yaml b/tests/gold_tests/cache/replay/cookie-all-but-text-with-excp.replay.yaml index 77cefbc47fe..cbfe9918376 100644 --- a/tests/gold_tests/cache/replay/cookie-all-but-text-with-excp.replay.yaml +++ b/tests/gold_tests/cache/replay/cookie-all-but-text-with-excp.replay.yaml @@ -23,6 +23,34 @@ meta: version: "1.0" +# Configuration section for autest integration +autest: + dns: + name: 'dns-cookie_all_but_text_with_excp' + description: 'Verify the correct caching behavior when ATS is configured to cache all content types but text, but with a few exceptions for text types which would also be cached' + + server: + name: 'cookie-all-but-text-with-excp-verifier-server' + + client: + name: 'cookie-all-but-text-with-excp-client' + + ats: + name: 'ts-cookie-all-but-text-with-excp' + process_config: + enable_cache: true + + records_config: + proxy.config.diags.debug.enabled: 1 + proxy.config.diags.debug.tags: 'http' + # Cache all content type but text. Text type also gets cached for + # server responses without Set-Cookie or with Cache-Control: public + proxy.config.http.cache.cache_responses_to_cookies: 4 + + remap_config: + - from: "http://example.com/" + to: "http://backend.example.com:{SERVER_HTTP_PORT}/" + sessions: - transactions: # Verify that response containing Set-Cookie with image content type is diff --git a/tests/gold_tests/cache/replay/cookie-all-but-text.replay.yaml b/tests/gold_tests/cache/replay/cookie-all-but-text.replay.yaml index aa8a6e2a56a..a0390c52eb3 100644 --- a/tests/gold_tests/cache/replay/cookie-all-but-text.replay.yaml +++ b/tests/gold_tests/cache/replay/cookie-all-but-text.replay.yaml @@ -22,6 +22,33 @@ meta: version: "1.0" +# Configuration section for autest integration +autest: + dns: + name: 'dns-cookie_all_but_text' + description: 'Verify the correct caching behavior when ATS is configured to cache response to cookie for all but text types' + + server: + name: 'cookie-all-but-text-verifier-server' + + client: + name: 'cookie-all-but-text-client' + + ats: + name: 'ts-cookie-all-but-text' + process_config: + enable_cache: true + + records_config: + proxy.config.diags.debug.enabled: 1 + proxy.config.diags.debug.tags: 'http' + # Cache all content type except text + proxy.config.http.cache.cache_responses_to_cookies: 3 + + remap_config: + - from: "http://example.com/" + to: "http://backend.example.com:{SERVER_HTTP_PORT}/" + sessions: - transactions: # Verify that response containing Set-Cookie with image content type is diff --git a/tests/gold_tests/cache/replay/cookie-bypass-cache.replay.yaml b/tests/gold_tests/cache/replay/cookie-bypass-cache.replay.yaml index eda11285549..9e0ab697ac0 100644 --- a/tests/gold_tests/cache/replay/cookie-bypass-cache.replay.yaml +++ b/tests/gold_tests/cache/replay/cookie-bypass-cache.replay.yaml @@ -22,6 +22,33 @@ meta: version: "1.0" +# Configuration section for autest integration +autest: + dns: + name: 'dns-cookie_bypass_cache' + description: 'Verify the correct caching behavior when ATS is configured to not cache response to cookie for any content type' + + server: + name: 'cookie-bypass-verifier-server' + + client: + name: 'cookie-bypass-client' + + ats: + name: 'ts-cookie-bypass' + process_config: + enable_cache: true + + records_config: + proxy.config.diags.debug.enabled: 1 + proxy.config.diags.debug.tags: 'http' + # Bypass cache for any responses to cookies + proxy.config.http.cache.cache_responses_to_cookies: 0 + + remap_config: + - from: "http://example.com/" + to: "http://backend.example.com:{SERVER_HTTP_PORT}/" + sessions: - transactions: # Verify that response containing Set-Cookie with text content type is not diff --git a/tests/gold_tests/cache/replay/cookie-cache-img-only.replay.yaml b/tests/gold_tests/cache/replay/cookie-cache-img-only.replay.yaml index 2b377eb2322..e95cdc66f2d 100644 --- a/tests/gold_tests/cache/replay/cookie-cache-img-only.replay.yaml +++ b/tests/gold_tests/cache/replay/cookie-cache-img-only.replay.yaml @@ -22,6 +22,33 @@ meta: version: "1.0" +# Configuration section for autest integration +autest: + dns: + name: 'dns-cookie_cache_img_only' + description: 'Verify the correct caching behavior when ATS is configured to cache response to cookie only for image content type' + + server: + name: 'cookie-img-only-verifier-server' + + client: + name: 'cookie-img-only-client' + + ats: + name: 'ts-cookie-img-only' + process_config: + enable_cache: true + + records_config: + proxy.config.diags.debug.enabled: 1 + proxy.config.diags.debug.tags: 'http' + # Cache only for image types + proxy.config.http.cache.cache_responses_to_cookies: 2 + + remap_config: + - from: "http://example.com/" + to: "http://backend.example.com:{SERVER_HTTP_PORT}/" + sessions: - transactions: # Verify that response containing Set-Cookie with text content type is not diff --git a/tests/gold_tests/cache/replay/cookie-default.replay.yaml b/tests/gold_tests/cache/replay/cookie-default.replay.yaml index c9773bc5feb..0f1608f1c26 100644 --- a/tests/gold_tests/cache/replay/cookie-default.replay.yaml +++ b/tests/gold_tests/cache/replay/cookie-default.replay.yaml @@ -16,12 +16,37 @@ # # This replay file assumes that caching is enabled and -# proxy.config.http.cache.cache_responses_to_cookies is set to 1(current +# proxy.config.http.cache.cache_responses_to_cookies is set to 1 (current # default, cache for any content-type) # meta: version: "1.0" +# Configuration section for autest integration +autest: + dns: + name: 'dns-cookie_default' + description: 'Verify the correct caching behavior when ATS is in default configuration' + + server: + name: 'cookie-default-verifier-server' + + client: + name: 'cookie-default-client' + + ats: + name: 'ts-cookie-default' + process_config: + enable_cache: true + + records_config: + proxy.config.diags.debug.enabled: 1 + proxy.config.diags.debug.tags: 'http' + + remap_config: + - from: "http://example.com/" + to: "http://backend.example.com:{SERVER_HTTP_PORT}/" + sessions: - transactions: # Verify the response containing Set-Cookie with text content type is diff --git a/tests/gold_tests/cache/replay/head_with_get_cached.replay.yaml b/tests/gold_tests/cache/replay/head_with_get_cached.replay.yaml index e55b12a7e9a..6f1136ab3cc 100644 --- a/tests/gold_tests/cache/replay/head_with_get_cached.replay.yaml +++ b/tests/gold_tests/cache/replay/head_with_get_cached.replay.yaml @@ -17,6 +17,31 @@ meta: version: "1.0" +# Configuration section for autest integration +autest: + dns: + name: 'dns-head_with_get_cached' + description: 'Verify correct HEAD response handling with cached GET response' + + server: + name: 'server-head' + + client: + name: 'client-head' + + ats: + name: 'ts-cache-head' + process_config: + enable_cache: true + + records_config: + proxy.config.diags.debug.enabled: 1 + proxy.config.diags.debug.tags: 'http.*|cache.*' + proxy.config.http.insert_age_in_response: 0 + + remap_config: + - from: "http://example.com/" + to: "http://backend.example.com:{SERVER_HTTP_PORT}/" sessions: - transactions: @@ -282,4 +307,4 @@ sessions: status: 200 headers: fields: - - [ X-Response, { value: second_get_response, as: equal} ] \ No newline at end of file + - [ X-Response, { value: second_get_response, as: equal} ] diff --git a/tests/gold_tests/cache/replay/ignore_authentication.replay.yaml b/tests/gold_tests/cache/replay/ignore_authentication.replay.yaml new file mode 100644 index 00000000000..186c6d315b5 --- /dev/null +++ b/tests/gold_tests/cache/replay/ignore_authentication.replay.yaml @@ -0,0 +1,157 @@ +# 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 verifies auth-related caching behaviors with both default +# configuration and with ignore_authentication enabled via conf_remap +# +meta: + version: "1.0" + +# Configuration section for autest integration +autest: + dns: + name: 'dns-auth' + description: 'Verify the proper caching behavior for request/response containing auth-related fields in both default and ignore_authentication configurations' + + server: + name: 'auth-verifier-server' + + client: + name: 'auth-client' + + ats: + name: 'ts-auth' + process_config: + enable_cache: true + + records_config: + proxy.config.diags.debug.enabled: 1 + proxy.config.diags.debug.tags: 'http' + # Default behavior: respect WWW-Authenticate (don't cache) + proxy.config.http.cache.ignore_authentication: 0 + + remap_config: + # Default path - uses default ignore_authentication=0 + - from: "http://example.com/default/" + to: "http://backend.example.com:{SERVER_HTTP_PORT}/default/" + # Ignored path - overrides to ignore_authentication=1 via conf_remap + - from: "http://example.com/ignored/" + to: "http://backend.example.com:{SERVER_HTTP_PORT}/ignored/" + plugins: + - name: "conf_remap.so" + args: + - "proxy.config.http.cache.ignore_authentication=1" + + log_validation: + traffic_out: + contains: + - expression: "response has WWW-Authenticate, response is not cacheable" + description: "Verify ATS doesn't store the response with WWW-Authenticate in default config." + +sessions: + - transactions: + ######################################################################### + # Test default behavior: WWW-Authenticate responses are NOT cached + ######################################################################### + - client-request: + method: "GET" + version: "1.1" + url: /default/auth + headers: + fields: + - [uuid, default-www-auth-response] + - [Host, example.com] + + server-response: + status: 401 + reason: Unauthorized + headers: + fields: + - [Content-Length, 4] + - [Cache-Control, "max-age=5"] + - [WWW-Authenticate, "Basic"] + + proxy-response: + status: 401 + + # Re-request to verify the previous response was NOT cached + - client-request: + # Add a delay so ATS has time to finish any caching IO for the + # previous transaction. + delay: 100ms + method: "GET" + version: "1.1" + url: /default/auth + headers: + fields: + - [uuid, default-www-auth-verify] + - [Host, example.com] + - [Authorization, "Basic ZGVtbzphdHNAc3Ryb25ncHc="] + + server-response: + status: 200 + reason: OK + + # Verify that the new 200 response is returned instead of cached 401 + proxy-response: + status: 200 + + ######################################################################### + # Test ignore_authentication=1: WWW-Authenticate responses ARE cached + ######################################################################### + - client-request: + method: "GET" + version: "1.1" + url: /ignored/auth + headers: + fields: + - [uuid, ignored-www-auth-response] + - [Host, example.com] + + server-response: + status: 401 + reason: Unauthorized + headers: + fields: + - [Content-Length, 4] + - [Cache-Control, "max-age=5"] + - [WWW-Authenticate, "Basic"] + + proxy-response: + status: 401 + + # Re-request to verify the previous response WAS cached + - client-request: + # Add a delay so ATS has time to finish any caching IO for the + # previous transaction. + delay: 100ms + method: "GET" + version: "1.1" + url: /ignored/auth + headers: + fields: + - [uuid, ignored-www-auth-verify] + - [Host, example.com] + - [Authorization, "Basic ZGVtbzphdHNAc3Ryb25ncHc="] + + server-response: + status: 200 + reason: OK + + # Verify that the cached 401 response is returned instead of new 200 + proxy-response: + status: 401 diff --git a/tests/gold_tests/cache/replay/negative-caching-customized.replay.yaml b/tests/gold_tests/cache/replay/negative-caching-customized.replay.yaml index 52df653b163..bbdf572aa4c 100644 --- a/tests/gold_tests/cache/replay/negative-caching-customized.replay.yaml +++ b/tests/gold_tests/cache/replay/negative-caching-customized.replay.yaml @@ -23,6 +23,34 @@ meta: version: "1.0" +# Configuration section for autest integration +autest: + dns: + name: 'dns-neg_caching_customized' + description: 'Verify customized negative caching list' + + server: + name: 'server-customized' + + client: + name: 'client-customized' + + ats: + name: 'ts-customized' + process_config: + enable_cache: true + + records_config: + proxy.config.diags.debug.enabled: 1 + proxy.config.diags.debug.tags: 'http' + proxy.config.http.insert_age_in_response: 0 + proxy.config.http.negative_caching_enabled: 1 + proxy.config.http.negative_caching_list: "400" + + remap_config: + - from: "http://example.com/" + to: "http://backend.example.com:{SERVER_HTTP_PORT}/" + blocks: - 200_response: &200_response server-response: diff --git a/tests/gold_tests/cache/replay/negative-caching-default.replay.yaml b/tests/gold_tests/cache/replay/negative-caching-default.replay.yaml index 6b945c30055..71d1f699196 100644 --- a/tests/gold_tests/cache/replay/negative-caching-default.replay.yaml +++ b/tests/gold_tests/cache/replay/negative-caching-default.replay.yaml @@ -22,6 +22,33 @@ meta: version: "1.0" +# Configuration section for autest integration +autest: + dns: + name: 'dns-neg_caching_default' + description: 'Verify default negative caching behavior' + + server: + name: 'server-default' + + client: + name: 'client-default' + + ats: + name: 'ts-default' + process_config: + enable_cache: true + + records_config: + proxy.config.diags.debug.enabled: 1 + proxy.config.diags.debug.tags: 'http' + proxy.config.http.insert_age_in_response: 0 + proxy.config.http.negative_caching_enabled: 1 + + remap_config: + - from: "http://example.com/" + to: "http://backend.example.com:{SERVER_HTTP_PORT}/" + blocks: - 200_response: &200_response server-response: diff --git a/tests/gold_tests/cache/replay/negative-caching-disabled.replay.yaml b/tests/gold_tests/cache/replay/negative-caching-disabled.replay.yaml index 0df4f317cdd..364be65eee4 100644 --- a/tests/gold_tests/cache/replay/negative-caching-disabled.replay.yaml +++ b/tests/gold_tests/cache/replay/negative-caching-disabled.replay.yaml @@ -21,6 +21,33 @@ meta: version: "1.0" +# Configuration section for autest integration +autest: + dns: + name: 'dns-neg_caching_disabled' + description: 'Verify correct behavior without negative caching enabled' + + server: + name: 'server-disabled' + + client: + name: 'client-disabled' + + ats: + name: 'ts-disabled' + process_config: + enable_cache: true + + records_config: + proxy.config.diags.debug.enabled: 1 + proxy.config.diags.debug.tags: 'http' + proxy.config.http.insert_age_in_response: 0 + proxy.config.http.negative_caching_enabled: 0 + + remap_config: + - from: "http://example.com/" + to: "http://backend.example.com:{SERVER_HTTP_PORT}/" + blocks: - request_for_path_200: &request_for_path_200 client-request: diff --git a/tests/gold_tests/cache/replay/negative-revalidating-disabled.replay.yaml b/tests/gold_tests/cache/replay/negative-revalidating-disabled.replay.yaml index cfc3c9b6361..93e3a71a483 100644 --- a/tests/gold_tests/cache/replay/negative-revalidating-disabled.replay.yaml +++ b/tests/gold_tests/cache/replay/negative-revalidating-disabled.replay.yaml @@ -22,6 +22,35 @@ meta: version: "1.0" +# Configuration section for autest integration +autest: + dns: + name: 'dns-neg_revalidating_disabled' + description: 'Verify negative revalidating disabled' + + server: + name: 'server-negative-revalidating-disabled' + + client: + name: 'client-negative-revalidating-disabled' + + ats: + name: 'ts-negative-revalidating-disabled' + process_config: + enable_cache: true + + records_config: + proxy.config.diags.debug.enabled: 1 + proxy.config.diags.debug.tags: 'http|cache' + proxy.config.http.insert_age_in_response: 0 + proxy.config.http.insert_response_via_str: 2 + proxy.config.http.negative_revalidating_enabled: 0 + proxy.config.http.cache.max_stale_age: 6 + + remap_config: + - from: "http://example.com/" + to: "http://backend.example.com:{SERVER_HTTP_PORT}/" + sessions: - transactions: diff --git a/tests/gold_tests/cache/replay/negative-revalidating-enabled.replay.yaml b/tests/gold_tests/cache/replay/negative-revalidating-enabled.replay.yaml index e406dfd6e04..27578517db3 100644 --- a/tests/gold_tests/cache/replay/negative-revalidating-enabled.replay.yaml +++ b/tests/gold_tests/cache/replay/negative-revalidating-enabled.replay.yaml @@ -15,14 +15,44 @@ # limitations under the License. # -# Verify negative_revalidating disabled behavior. This replay file assumes: -# * ATS is configured with negative_revalidating disabled. +# Verify negative_revalidating enabled behavior. This replay file assumes: +# * ATS is configured with negative_revalidating enabled (default). # * max_stale_age is set to 6 seconds. # meta: version: "1.0" +# Configuration section for autest integration +autest: + dns: + name: 'dns-neg_revalidating_enabled' + description: 'Verify negative revalidating enabled' + + server: + name: 'server-negative-revalidating-enabled' + + client: + name: 'client-negative-revalidating-enabled' + + ats: + name: 'ts-negative-revalidating-enabled' + process_config: + enable_cache: true + + records_config: + proxy.config.diags.debug.enabled: 1 + proxy.config.diags.debug.tags: 'http|cache' + proxy.config.http.insert_age_in_response: 0 + proxy.config.http.insert_response_via_str: 2 + # Negative revalidating is on by default. + # proxy.config.http.negative_revalidating_enabled: 1 + proxy.config.http.cache.max_stale_age: 6 + + remap_config: + - from: "http://example.com/" + to: "http://backend.example.com:{SERVER_HTTP_PORT}/" + sessions: - transactions: diff --git a/tests/gold_tests/cache/replay/negative-revalidating-list.replay.yaml b/tests/gold_tests/cache/replay/negative-revalidating-list.replay.yaml index f95dab2d933..af23465b161 100644 --- a/tests/gold_tests/cache/replay/negative-revalidating-list.replay.yaml +++ b/tests/gold_tests/cache/replay/negative-revalidating-list.replay.yaml @@ -15,14 +15,45 @@ # limitations under the License. # -# Verify negative_revalidating disabled behavior. This replay file assumes: -# * ATS is configured with negative_revalidating disabled. +# Verify negative_revalidating_list behavior. This replay file assumes: +# * ATS is configured with negative_revalidating enabled. # * max_stale_age is set to 6 seconds. +# * negative_revalidating_list is set to "403 404" # meta: version: "1.0" +# Configuration section for autest integration +autest: + dns: + name: 'dns-neg_revalidating_list' + description: 'Verify negative_revalidating_list behavior' + + server: + name: 'server-negative-revalidating-list' + + client: + name: 'client-negative-revalidating-list' + + ats: + name: 'ts-negative-revalidating-list' + process_config: + enable_cache: true + + records_config: + proxy.config.diags.debug.enabled: 1 + proxy.config.diags.debug.tags: 'http|cache' + proxy.config.http.insert_age_in_response: 0 + proxy.config.http.insert_response_via_str: 2 + proxy.config.http.cache.max_stale_age: 6 + proxy.config.http.negative_revalidating_enabled: 1 + proxy.config.http.negative_revalidating_list: "403 404" + + remap_config: + - from: "http://example.com/" + to: "http://backend.example.com:{SERVER_HTTP_PORT}/" + sessions: - transactions: diff --git a/tests/gold_tests/cache/replay/post_with_post_caching_disabled.replay.yaml b/tests/gold_tests/cache/replay/post_with_post_caching_disabled.replay.yaml index 84dcabe99c6..13beb51e5c3 100644 --- a/tests/gold_tests/cache/replay/post_with_post_caching_disabled.replay.yaml +++ b/tests/gold_tests/cache/replay/post_with_post_caching_disabled.replay.yaml @@ -17,6 +17,35 @@ meta: version: "1.0" +# Configuration section for autest integration +autest: + dns: + name: 'dns-post_with_post_caching_disabled' + dns: + name: 'dns-post_with_post_caching_disabled' + description: 'Verify correct POST response handling when caching POST responses is disabled' + + server: + name: 'server-post-disabled' + + client: + name: 'client-post-disabled' + + ats: + name: 'ts' + process_config: + enable_cache: true + + records_config: + proxy.config.diags.debug.enabled: 1 + proxy.config.diags.debug.tags: 'http.*|cache.*' + proxy.config.http.insert_age_in_response: 0 + # Caching of POST responses is disabled by default. + # proxy.config.http.cache.post_method: 0 + + remap_config: + - from: "http://example.com/" + to: "http://backend.example.com:{SERVER_HTTP_PORT}/" sessions: - transactions: diff --git a/tests/gold_tests/cache/replay/post_with_post_caching_enabled.replay.yaml b/tests/gold_tests/cache/replay/post_with_post_caching_enabled.replay.yaml index 5f102d23cd9..b5d1d1a23e7 100644 --- a/tests/gold_tests/cache/replay/post_with_post_caching_enabled.replay.yaml +++ b/tests/gold_tests/cache/replay/post_with_post_caching_enabled.replay.yaml @@ -17,6 +17,34 @@ meta: version: "1.0" +# Configuration section for autest integration +autest: + dns: + name: 'dns-post_with_post_caching_enabled' + dns: + name: 'dns-post_with_post_caching_enabled' + description: 'Verify correct POST response handling when caching POST responses is enabled' + + server: + name: 'server-post-enabled' + + client: + name: 'client-post-enabled' + + ats: + name: 'ts-cache-post' + process_config: + enable_cache: true + + records_config: + proxy.config.diags.debug.enabled: 1 + proxy.config.diags.debug.tags: 'http.*|cache.*' + proxy.config.http.insert_age_in_response: 0 + proxy.config.http.cache.post_method: 1 + + remap_config: + - from: "http://example.com/" + to: "http://backend.example.com:{SERVER_HTTP_PORT}/" sessions: - transactions: diff --git a/tests/gold_tests/cache/replay/post_with_post_caching_override.replay.yaml b/tests/gold_tests/cache/replay/post_with_post_caching_override.replay.yaml new file mode 100644 index 00000000000..4c64b273014 --- /dev/null +++ b/tests/gold_tests/cache/replay/post_with_post_caching_override.replay.yaml @@ -0,0 +1,112 @@ +# 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" + +# Configuration section for autest integration +autest: + dns: + name: 'dns-post_with_post_caching_override' + dns: + name: 'dns-post_with_post_caching_override' + description: 'Verify correct POST response handling when caching POST responses is enabled via overridable config' + + server: + name: 'server-post-override' + + client: + name: 'client-post-override' + + ats: + name: 'ts-cache-post-override' + process_config: + enable_cache: true + + records_config: + proxy.config.diags.debug.enabled: 1 + proxy.config.diags.debug.tags: 'http.*|cache.*' + proxy.config.http.insert_age_in_response: 0 + # Override the following in remap.config. + proxy.config.http.cache.post_method: 0 + + remap_config: + - from: "http://example.com/" + to: "http://backend.example.com:{SERVER_HTTP_PORT}/" + plugins: + - name: "conf_remap.so" + args: + - "proxy.config.http.cache.post_method=1" + +# Use the same sessions as post_with_post_caching_enabled.replay.yaml +# since the behavior should be the same (POST caching enabled) +sessions: +- transactions: + + # + # Test 1: Verify caching of a response to a POST request. + # + + # The simple case: perform two POST requests and make sure the second + # is served with the cached response of the first. + - client-request: + method: "POST" + version: "1.1" + url: /simple/post/test + headers: + fields: + - [ Host, example.com ] + - [ Content-Length, 48 ] + - [ uuid, 11 ] + + server-response: + status: 200 + reason: OK + headers: + fields: + - [ Content-Length, 16 ] + - [ Cache-Control, max-age=300 ] + + proxy-response: + status: 200 + + - client-request: + # Add a delay so ATS has time to finish any caching IO for the previous + # transaction. + delay: 100ms + + method: "POST" + version: "1.1" + url: /simple/post/test + headers: + fields: + - [ Host, example.com ] + - [ Content-Length, 48 ] + - [ uuid, 12 ] + + # This should not go through to the server since the previous POST response + # should have been cached. Return a non-200 response to + # verify it is served from cache. + server-response: + status: 400 + reason: "Bad Request" + headers: + fields: + - [ Content-Length, 0 ] + + # Expect the cached 200 response. + proxy-response: + status: 200 diff --git a/tests/gold_tests/cache/replay/request-cache-control-default.replay.yaml b/tests/gold_tests/cache/replay/request-cache-control-default.replay.yaml index 94d3bde4afe..e0a0d91f1ad 100644 --- a/tests/gold_tests/cache/replay/request-cache-control-default.replay.yaml +++ b/tests/gold_tests/cache/replay/request-cache-control-default.replay.yaml @@ -21,6 +21,32 @@ meta: version: "1.0" +# Configuration section for autest integration +autest: + description: 'Verify the proper handling of cache-control directives in requests in default configuration' + + dns: + name: 'dns-req_default' + + server: + name: 'request-cache-control-default-verifier-server' + + client: + name: 'request-cache-control-default-client' + + ats: + name: 'ts-request-cache-control-default' + process_config: + enable_cache: true + + records_config: + proxy.config.diags.debug.enabled: 1 + proxy.config.diags.debug.tags: 'http' + + remap_config: + - from: "http://example.com/" + to: "http://backend.example.com:{SERVER_HTTP_PORT}/" + sessions: - transactions: # Populating the cache diff --git a/tests/gold_tests/cache/replay/request-cache-control-honor-client.replay.yaml b/tests/gold_tests/cache/replay/request-cache-control-honor-client.replay.yaml index 9340ed66538..a5e8faf3153 100644 --- a/tests/gold_tests/cache/replay/request-cache-control-honor-client.replay.yaml +++ b/tests/gold_tests/cache/replay/request-cache-control-honor-client.replay.yaml @@ -22,6 +22,42 @@ meta: version: "1.0" +# Configuration section for autest integration +autest: + description: 'Verify the proper handling of cache-control directives in requests when ATS is configured to honor client requests to bypass the cache' + + dns: + name: 'dns-req_honor_client' + + server: + name: 'request-cache-control-honor-client-verifier-server' + + client: + name: 'request-cache-control-honor-client-client' + + ats: + name: 'ts-request-cache-control-honor-client' + process_config: + enable_cache: true + + records_config: + proxy.config.diags.debug.enabled: 1 + proxy.config.diags.debug.tags: 'http' + # Configured to honor client requests to bypass the cache + proxy.config.http.cache.ignore_client_no_cache: 0 + + remap_config: + - from: "http://example.com/" + to: "http://backend.example.com:{SERVER_HTTP_PORT}/" + + log_validation: + traffic_out: + contains: + - expression: "Revalidate document with server" + description: "Verify that ATS honors the no-cache and performs a revalidation." + - expression: "client does not permit storing, and cache control does not say to ignore client no-cache" + description: "Verify that ATS honors the no-store." + sessions: - transactions: # Populating the cache diff --git a/tests/gold_tests/cache/replay/response-cache-control-default.replay.yaml b/tests/gold_tests/cache/replay/response-cache-control-default.replay.yaml index b87ad86ad56..3ecfa831314 100644 --- a/tests/gold_tests/cache/replay/response-cache-control-default.replay.yaml +++ b/tests/gold_tests/cache/replay/response-cache-control-default.replay.yaml @@ -22,6 +22,40 @@ meta: version: "1.0" +# Configuration section for autest integration +autest: + description: 'Verify the proper handling of cache-control directives in responses in default configuration' + + dns: + name: 'dns-resp_default' + + server: + name: 'response-cache-control-default-verifier-server' + + client: + name: 'response-cache-control-client-default' + + ats: + name: 'ts-response-cache-control-default' + process_config: + enable_cache: true + + records_config: + proxy.config.diags.debug.enabled: 1 + proxy.config.diags.debug.tags: 'http' + + remap_config: + - from: "http://example.com/" + to: "http://backend.example.com:{SERVER_HTTP_PORT}/" + + log_validation: + traffic_out: + contains: + - expression: "Revalidate document with server" + description: "Verify that ATS honors the no-cache in response and performs a revalidation." + - expression: "server does not permit storing and config file does not indicate that server directive should be ignored" + description: "Verify that ATS honors the no-store in response and bypasses the cache." + sessions: - transactions: # Verify Cache-Control: no-cache in response is honored diff --git a/tests/gold_tests/cache/replay/response-cache-control-ignored.replay.yaml b/tests/gold_tests/cache/replay/response-cache-control-ignored.replay.yaml index 2380e4a34de..17fa5d5c408 100644 --- a/tests/gold_tests/cache/replay/response-cache-control-ignored.replay.yaml +++ b/tests/gold_tests/cache/replay/response-cache-control-ignored.replay.yaml @@ -21,6 +21,41 @@ meta: version: "1.0" +# Configuration section for autest integration +autest: + description: 'Verify the proper handling of cache-control directives in responses when ATS is configured to ignore server requests to bypass the cache' + + dns: + name: 'dns-resp_ignored' + + server: + name: 'response-cache-control-ignored-verifier-server' + + client: + name: 'response-cache-control-client-ignored' + + ats: + name: 'ts-response-cache-control-ignored' + process_config: + enable_cache: true + + records_config: + proxy.config.diags.debug.enabled: 1 + proxy.config.diags.debug.tags: 'http' + proxy.config.http.cache.ignore_server_no_cache: 1 + + remap_config: + - from: "http://example.com/" + to: "http://backend.example.com:{SERVER_HTTP_PORT}/" + + log_validation: + traffic_out: + excludes: + - expression: "Revalidate document with server" + description: "Verify that ATS ignores the no-cache in response and therefore doesn't perform a revalidation." + - expression: "server does not permit storing and config file does not indicate that server directive should be ignored" + description: "Verify that ATS ignores the no-store in response and caches the responses despite its presence." + sessions: - transactions: # Verify the no-cache in response is ignored and the response is cached diff --git a/tests/gold_tests/cache/replay/varied_transactions.replay.yaml b/tests/gold_tests/cache/replay/varied_transactions.replay.yaml index ccb35e7210e..94ae9e4ddc5 100644 --- a/tests/gold_tests/cache/replay/varied_transactions.replay.yaml +++ b/tests/gold_tests/cache/replay/varied_transactions.replay.yaml @@ -33,6 +33,37 @@ meta: fields: - [ Content-Length, 0 ] +autest: + description: 'Run traffic with max_alts behavior when set to 4' + + dns: + name: 'dns-vary-handling' + + server: + name: 'server-vary-handling' + + client: + name: 'client-vary-handling' + + ats: + name: 'ts-vary-handling' + process_config: + enable_cache: true + + records_config: + proxy.config.diags.debug.enabled: 1 + proxy.config.diags.debug.tags: 'http' + proxy.config.http.insert_age_in_response: 0 + proxy.config.cache.limits.http.max_alts: 4 + proxy.config.cache.log.alternate.eviction: 1 + + remap_config: + - from: "http://example.com/" + to: "http://backend.example.com:{SERVER_HTTP_PORT}/" + + log_validation: + diags_log: + gold_file: "gold/two_alternates_evicted.gold" sessions: - transactions: diff --git a/tests/gold_tests/cache/vary-handling.test.py b/tests/gold_tests/cache/vary-handling.test.py index 45b51414254..3e27012f99f 100644 --- a/tests/gold_tests/cache/vary-handling.test.py +++ b/tests/gold_tests/cache/vary-handling.test.py @@ -21,23 +21,5 @@ Test correct handling of alternates via the Vary header. ''' -ts = Test.MakeATSProcess("ts") -replay_file = "replay/varied_transactions.replay.yaml" -server = Test.MakeVerifierServerProcess("server", replay_file) -ts.Disk.records_config.update( - { - 'proxy.config.diags.debug.enabled': 1, - 'proxy.config.diags.debug.tags': 'http', - 'proxy.config.http.insert_age_in_response': 0, - 'proxy.config.cache.limits.http.max_alts': 4, - 'proxy.config.cache.log.alternate.eviction': 1, - }) - -ts.Disk.remap_config.AddLine('map / http://127.0.0.1:{0}'.format(server.Variables.http_port)) - -tr = Test.AddTestRun("Run traffic with max_alts behavior when set to 4") -tr.Processes.Default.StartBefore(server) -tr.Processes.Default.StartBefore(ts) -tr.AddVerifierClientProcess("client", replay_file, http_ports=[ts.Variables.port]) - -ts.Disk.diags_log.Content += "gold/two_alternates_evicted.gold" +# Run traffic with max_alts behavior when set to 4. +Test.ATSReplayTest(replay_file="replay/varied_transactions.replay.yaml") diff --git a/tests/gold_tests/proxy_protocol/proxy_serve_stale.test.py b/tests/gold_tests/proxy_protocol/proxy_serve_stale.test.py index 252a50a958e..43c0bebd54c 100644 --- a/tests/gold_tests/proxy_protocol/proxy_serve_stale.test.py +++ b/tests/gold_tests/proxy_protocol/proxy_serve_stale.test.py @@ -20,50 +20,5 @@ Test.testName = "proxy_serve_stale" Test.ContinueOnFail = True - -class ProxyServeStaleTest: - """Verify that stale content is served when the parent is down.""" - - single_transaction_replay = "replay/proxy_serve_stale.replay.yaml" - ts_parent_hostname = "localhost:82" - - def __init__(self): - """Initialize the test.""" - self._configure_server() - self._configure_ts() - - def _configure_server(self): - self.server = Test.MakeVerifierServerProcess("server", self.single_transaction_replay) - self.nameserver = Test.MakeDNServer("dns", default='127.0.0.1') - - def _configure_ts(self): - self.ts_child = Test.MakeATSProcess("ts_child") - # Config child proxy to route to parent proxy - self.ts_child.Disk.records_config.update( - { - 'proxy.config.http.push_method_enabled': 1, - 'proxy.config.http.parent_proxy.fail_threshold': 2, - 'proxy.config.http.parent_proxy.total_connect_attempts': 1, - 'proxy.config.http.cache.max_stale_age': 10, - 'proxy.config.http.parent_proxy.self_detect': 0, - 'proxy.config.diags.debug.enabled': 1, - 'proxy.config.diags.debug.tags': 'cache|http|dns|hostdb|parent_proxy', - 'proxy.config.dns.nameservers': f"127.0.0.1:{self.nameserver.Variables.Port}", - }) - self.ts_child.Disk.parent_config.AddLine( - f'dest_domain=. parent="{self.ts_parent_hostname}" round_robin=consistent_hash go_direct=false') - self.ts_child.Disk.remap_config.AddLine(f'map / http://localhost:{self.server.Variables.http_port}') - - def run(self): - """Run the test cases.""" - - tr = Test.AddTestRun() - tr.AddVerifierClientProcess('client', self.single_transaction_replay, http_ports=[self.ts_child.Variables.port]) - tr.Processes.Default.ReturnCode = 0 - tr.StillRunningAfter = self.ts_child - tr.Processes.Default.StartBefore(self.server) - tr.Processes.Default.StartBefore(self.nameserver) - tr.Processes.Default.StartBefore(self.ts_child) - - -ProxyServeStaleTest().run() +# Verify that stale content is served when the parent is down. +Test.ATSReplayTest(replay_file="replay/proxy_serve_stale.replay.yaml") diff --git a/tests/gold_tests/proxy_protocol/replay/proxy_serve_stale.replay.yaml b/tests/gold_tests/proxy_protocol/replay/proxy_serve_stale.replay.yaml index 152af6ecd8e..b3a84d1b571 100644 --- a/tests/gold_tests/proxy_protocol/replay/proxy_serve_stale.replay.yaml +++ b/tests/gold_tests/proxy_protocol/replay/proxy_serve_stale.replay.yaml @@ -36,6 +36,38 @@ meta: - [ Content-Length, 16 ] - [ X-Response, should_not_see ] +autest: + description: 'Verify that stale content is served when the parent is down' + + dns: + name: 'dns-serve-stale' + + server: + name: 'server-serve-stale' + + client: + name: 'client-serve-stale' + + ats: + name: 'ts_child' + process_config: + enable_cache: true + + records_config: + proxy.config.http.push_method_enabled: 1 + proxy.config.http.parent_proxy.fail_threshold: 2 + proxy.config.http.parent_proxy.total_connect_attempts: 1 + proxy.config.http.cache.max_stale_age: 10 + proxy.config.http.parent_proxy.self_detect: 0 + proxy.config.diags.debug.enabled: 1 + proxy.config.diags.debug.tags: 'cache|http|dns|hostdb|parent_proxy' + + parent_config: + - 'dest_domain=. parent="localhost:82" round_robin=consistent_hash go_direct=false' + + remap_config: + - from: "http://example.com/" + to: "http://localhost:{SERVER_HTTP_PORT}/" sessions: - transactions: