From cf1da764653a97ece4bfdac844cfab845351e2ee Mon Sep 17 00:00:00 2001 From: Brian Neradt Date: Mon, 24 Nov 2025 09:24:44 -0600 Subject: [PATCH 1/2] cache-*.test.py tests to use ATSReplayTest (#12694) 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. --- .../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 - .../gold_tests/cache/negative-caching.test.py | 62 +--- .../cache/negative-revalidating.test.py | 79 +--- .../cache/proxy_serve_stale.test.py | 49 +-- .../replay/alternate-caching-update-size.yaml | 28 ++ .../cache/replay/auth-default.replay.yaml | 68 ---- .../cache/replay/auth-ignored.replay.yaml | 67 ---- .../replay/cache-control-basic.replay.yaml | 218 +++++++++++ .../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 | 25 ++ .../replay/conditional-get-cache-hit.yaml | 23 ++ .../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 | 158 ++++++++ .../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 | 113 ++++++ .../replay/proxy_serve_stale.replay.yaml | 32 ++ .../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 | 28 ++ tests/gold_tests/cache/vary-handling.test.py | 22 +- 48 files changed, 1337 insertions(+), 1129 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/negative-caching.test.py b/tests/gold_tests/cache/negative-caching.test.py index bcd0868aefd..0e09ae17bb4 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 e80c577827a..30071d147e4 100644 --- a/tests/gold_tests/cache/negative-revalidating.test.py +++ b/tests/gold_tests/cache/negative-revalidating.test.py @@ -21,78 +21,11 @@ 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 +# Verify negative revalidating enabled +Test.ATSReplayTest(replay_file="replay/negative-revalidating-enabled.replay.yaml") - def __init__(self, name: str, records_config: dict, replay_file: str): - self._tr = Test.AddTestRun(name) - self._replay_file = replay_file - - self.__setupOriginServer() - self.__setupTS(records_config) - self.__setupClient() - - 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)) - - def run(self): - self._tr.Processes.Default.StartBefore(self._ts) - self._tr.StillRunningAfter = self._ts - - -# -# 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").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/proxy_serve_stale.test.py b/tests/gold_tests/cache/proxy_serve_stale.test.py index 252a50a958e..43c0bebd54c 100644 --- a/tests/gold_tests/cache/proxy_serve_stale.test.py +++ b/tests/gold_tests/cache/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/cache/replay/alternate-caching-update-size.yaml b/tests/gold_tests/cache/replay/alternate-caching-update-size.yaml index ddc4a461942..8031f2019c7 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,34 @@ meta: - [ Accept-Language, es_US ] delay: 100ms +autest: + description: 'Verify disabled negative revalidating behavior' + + 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..58b4c974a8a --- /dev/null +++ b/tests/gold_tests/cache/replay/cache-control-basic.replay.yaml @@ -0,0 +1,218 @@ +# 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..0ebde6ac772 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,31 @@ meta: version: "1.0" +autest: + description: 'Verify correct caching behavior for range requests' + + 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..21b052ae88a 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,29 @@ meta: version: "1.0" +autest: + description: 'Verify conditional get with cache hit drains client body' + + 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..eb04957d2ab --- /dev/null +++ b/tests/gold_tests/cache/replay/ignore_authentication.replay.yaml @@ -0,0 +1,158 @@ +# 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 4b320767bff..32c5ad66ebf 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..a50cf05a9f1 --- /dev/null +++ b/tests/gold_tests/cache/replay/post_with_post_caching_override.replay.yaml @@ -0,0 +1,113 @@ +# 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/proxy_serve_stale.replay.yaml b/tests/gold_tests/cache/replay/proxy_serve_stale.replay.yaml index 152af6ecd8e..b3a84d1b571 100644 --- a/tests/gold_tests/cache/replay/proxy_serve_stale.replay.yaml +++ b/tests/gold_tests/cache/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: 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..a7e65c0ac9e 100644 --- a/tests/gold_tests/cache/replay/varied_transactions.replay.yaml +++ b/tests/gold_tests/cache/replay/varied_transactions.replay.yaml @@ -33,6 +33,34 @@ meta: fields: - [ Content-Length, 0 ] +autest: + description: 'Run traffic with max_alts behavior when set to 4' + + 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") From 52a9c8451fb395eb7816c15741447d17064ea426 Mon Sep 17 00:00:00 2001 From: Brian Neradt Date: Mon, 24 Nov 2025 18:49:39 +0000 Subject: [PATCH 2/2] dns fixes --- tests/gold_tests/cache/gold/two_alternates_evicted.gold | 4 ++-- .../cache/replay/alternate-caching-update-size.yaml | 3 +++ .../gold_tests/cache/replay/cache-range-response.replay.yaml | 3 +++ tests/gold_tests/cache/replay/conditional-get-cache-hit.yaml | 3 +++ tests/gold_tests/cache/replay/varied_transactions.replay.yaml | 3 +++ 5 files changed, 14 insertions(+), 2 deletions(-) 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/replay/alternate-caching-update-size.yaml b/tests/gold_tests/cache/replay/alternate-caching-update-size.yaml index 8031f2019c7..ad7fdda5938 100644 --- a/tests/gold_tests/cache/replay/alternate-caching-update-size.yaml +++ b/tests/gold_tests/cache/replay/alternate-caching-update-size.yaml @@ -53,6 +53,9 @@ meta: autest: description: 'Verify disabled negative revalidating behavior' + dns: + name: 'dns-alternate-caching' + server: name: 'server-alternate-caching' 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 0ebde6ac772..1399f4f69d0 100644 --- a/tests/gold_tests/cache/replay/cache-range-response.replay.yaml +++ b/tests/gold_tests/cache/replay/cache-range-response.replay.yaml @@ -21,6 +21,9 @@ meta: autest: description: 'Verify correct caching behavior for range requests' + dns: + name: 'dns-range-response' + server: name: 'server-range-response' 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 21b052ae88a..f5e75382a9d 100644 --- a/tests/gold_tests/cache/replay/conditional-get-cache-hit.yaml +++ b/tests/gold_tests/cache/replay/conditional-get-cache-hit.yaml @@ -20,6 +20,9 @@ meta: autest: description: 'Verify conditional get with cache hit drains client body' + dns: + name: 'dns-conditional-get' + server: name: 'server-conditional-get' diff --git a/tests/gold_tests/cache/replay/varied_transactions.replay.yaml b/tests/gold_tests/cache/replay/varied_transactions.replay.yaml index a7e65c0ac9e..94ae9e4ddc5 100644 --- a/tests/gold_tests/cache/replay/varied_transactions.replay.yaml +++ b/tests/gold_tests/cache/replay/varied_transactions.replay.yaml @@ -36,6 +36,9 @@ meta: autest: description: 'Run traffic with max_alts behavior when set to 4' + dns: + name: 'dns-vary-handling' + server: name: 'server-vary-handling'