traeak commented on code in PR #13843:
URL: https://github.com/apache/trafficserver/pull/13843#discussion_r4288057297
##########
tests/gold_tests/pluginTest/stats_over_http/stats_over_http.test.py:
##########
@@ -415,3 +415,84 @@ def run(self):
StatsOverHttpPluginTest().run()
+
+
+class StatsOverHttpCacheTtlTest:
+ """Verify that --cache-ttl serves a cached response until it goes stale."""
+
+ CACHE_TTL = 3
+
+ def __init__(self):
+ self.ts = Test.MakeATSProcess("ts_cache_ttl")
+ self.ts.Disk.plugin_config.AddLine(f'stats_over_http.so
--cache-ttl={self.CACHE_TTL} _stats')
+ self.ts.Disk.records_config.update(
+ {
+ "proxy.config.diags.debug.enabled": 1,
+ "proxy.config.diags.debug.tags": "stats_over_http",
+ })
+ self.url = f'http://127.0.0.1:{self.ts.Variables.port}/_stats'
+
+ def __epoch(self, curl_args: str = '') -> str:
+ return f"curl -s --http1.1 {curl_args} {self.url} | grep
current_time_epoch_ms"
+
+ def __testCacheHeaders(self):
+ tr = Test.AddTestRun('A cached stats response advertises its max-age
and age')
+ tr.Processes.Default.StartBefore(self.ts)
+ # Use CSV so this cache entry is not shared with the JSON entry the
fresh/stale runs depend on.
+ csv = "-H 'Accept: text/csv'"
+ tr.Processes.Default.Command = (
+ f'curl -s -o /dev/null --http1.1 {csv} {self.url} && sleep 2 && '
+ f'curl -vs -o /dev/null --http1.1 {csv} {self.url}')
+ tr.Processes.Default.ReturnCode = 0
+ tr.Processes.Default.Streams.stderr += Testers.ContainsExpression(
+ r'< Age: [1-9]', 'A cache hit should report the age of the cached
body.')
Review Comment:
With a TTL of 3, a cached response never has Age of 3 or more in this test,
because a body that old gets regenerated and Age resets to 0.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]