Skip to content

Commit d74c795

Browse files
authored
cache-*.test.py tests to use ATSReplayTest (#12701)
Convert various cache-*.test.py tests to use the new ATSReplayTest extension. These were generally pretty easy to convert because many of them were Proxy Verifier replay file based tests already anyway. To support this, this also adds diags.log and traffic.out log verification support to ATSReplayTest.
1 parent e699cbe commit d74c795

File tree

49 files changed

+1351
-1131
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+1351
-1131
lines changed

tests/gold_tests/autest-site/ats_replay.test.ext

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,17 @@ def configure_ats(obj: 'TestRun', server: 'Process', ats_config: dict, dns: Opti
3636
ts = obj.MakeATSProcess(name, **process_config)
3737
records_config = ats_config.get('records_config', {})
3838
ts.Disk.records_config.update(records_config)
39+
40+
# Configure plugin_config if specified.
41+
plugin_config = ats_config.get('plugin_config', [])
42+
for plugin_line in plugin_config:
43+
ts.Disk.plugin_config.AddLine(plugin_line)
44+
45+
# Configure parent_config if specified.
46+
parent_config = ats_config.get('parent_config', [])
47+
for parent_line in parent_config:
48+
ts.Disk.parent_config.AddLine(parent_line)
49+
3950
remap_config = ats_config.get('remap_config', [])
4051
for remap_entry in remap_config:
4152
if isinstance(remap_entry, str):
@@ -68,6 +79,40 @@ def configure_ats(obj: 'TestRun', server: 'Process', ats_config: dict, dns: Opti
6879
ts.Setup.Copy(src_dir, dst_dir)
6980
else:
7081
ts.Setup.CopyAs(item, ts.Variables.CONFIGDIR)
82+
83+
# Configure log validation if specified.
84+
log_validation = ats_config.get('log_validation', {})
85+
if log_validation:
86+
# traffic_out validation.
87+
traffic_out = log_validation.get('traffic_out', {})
88+
for contains_entry in traffic_out.get('contains', []):
89+
expression = contains_entry['expression']
90+
description = contains_entry.get('description', f'Verify traffic_out contains: {expression}')
91+
ts.Disk.traffic_out.Content += Testers.ContainsExpression(expression, description)
92+
for excludes_entry in traffic_out.get('excludes', []):
93+
expression = excludes_entry['expression']
94+
description = excludes_entry.get('description', f'Verify traffic_out excludes: {expression}')
95+
ts.Disk.traffic_out.Content += Testers.ExcludesExpression(expression, description)
96+
# Gold file validation for traffic_out.
97+
if 'gold_file' in traffic_out:
98+
gold_file = traffic_out['gold_file']
99+
ts.Disk.traffic_out.Content += gold_file
100+
101+
# diags_log validation.
102+
diags_log = log_validation.get('diags_log', {})
103+
for contains_entry in diags_log.get('contains', []):
104+
expression = contains_entry['expression']
105+
description = contains_entry.get('description', f'Verify diags_log contains: {expression}')
106+
ts.Disk.diags_log.Content += Testers.ContainsExpression(expression, description)
107+
for excludes_entry in diags_log.get('excludes', []):
108+
expression = excludes_entry['expression']
109+
description = excludes_entry.get('description', f'Verify diags_log excludes: {expression}')
110+
ts.Disk.diags_log.Content += Testers.ExcludesExpression(expression, description)
111+
# Gold file validation for diags_log.
112+
if 'gold_file' in diags_log:
113+
gold_file = diags_log['gold_file']
114+
ts.Disk.diags_log.Content += gold_file
115+
71116
return ts
72117

73118

tests/gold_tests/cache/alternate-caching.test.py

Lines changed: 2 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -21,28 +21,5 @@
2121
Test the alternate caching feature.
2222
'''
2323

24-
#
25-
# Verify disabled negative_revalidating behavior.
26-
#
27-
ts = Test.MakeATSProcess("ts-alternate-caching")
28-
ts.Disk.records_config.update(
29-
{
30-
'proxy.config.diags.debug.enabled': 1,
31-
'proxy.config.diags.debug.tags': 'http|cache',
32-
'proxy.config.http.cache.max_stale_age': 6,
33-
'proxy.config.cache.select_alternate': 1,
34-
'proxy.config.cache.limits.http.max_alts': 4,
35-
36-
# Try with and without this
37-
'proxy.config.http.negative_revalidating_enabled': 1,
38-
'proxy.config.http.negative_caching_enabled': 1,
39-
'proxy.config.http.negative_caching_lifetime': 30
40-
})
41-
tr = Test.AddTestRun("Verify disabled negative revalidating behavior.")
42-
replay_file = "replay/alternate-caching-update-size.yaml"
43-
server = tr.AddVerifierServerProcess("server1", replay_file)
44-
server_port = server.Variables.http_port
45-
tr.AddVerifierClientProcess("client1", replay_file, http_ports=[ts.Variables.port])
46-
ts.Disk.remap_config.AddLine('map / http://127.0.0.1:{0}'.format(server_port))
47-
tr.Processes.Default.StartBefore(ts)
48-
tr.StillRunningAfter = ts
24+
# Verify disabled negative revalidating behavior.
25+
Test.ATSReplayTest(replay_file="replay/alternate-caching-update-size.yaml")

tests/gold_tests/cache/cache-auth.test.py

Lines changed: 2 additions & 87 deletions
Original file line numberDiff line numberDiff line change
@@ -21,90 +21,5 @@
2121
Test authorization-related caching behaviors
2222
'''
2323

24-
Test.ContinueOnFail = True
25-
26-
# **testname is required**
27-
testName = ""
28-
29-
30-
class AuthDefaultTest:
31-
# Verify the proper caching behavior for request/response containing
32-
# auth-related fields when ATS is in default configuration
33-
authDefaultReplayFile = "replay/auth-default.replay.yaml"
34-
35-
def __init__(self):
36-
self.setupOriginServer()
37-
self.setupTS()
38-
39-
def setupOriginServer(self):
40-
self.server = Test.MakeVerifierServerProcess("auth-default-verifier-server", self.authDefaultReplayFile)
41-
42-
def setupTS(self):
43-
self.ts = Test.MakeATSProcess("ts-auth-default")
44-
self.ts.Disk.records_config.update({
45-
"proxy.config.diags.debug.enabled": 1,
46-
"proxy.config.diags.debug.tags": "http",
47-
})
48-
self.ts.Disk.remap_config.AddLine(f"map / http://127.0.0.1:{self.server.Variables.http_port}/",)
49-
50-
# Verify log for skipping the WWW-Authenticate response
51-
self.ts.Disk.traffic_out.Content += Testers.ContainsExpression(
52-
"response has WWW-Authenticate, response is not cacheable",
53-
"Verify ATS doesn't store the response with WWW-Authenticate.")
54-
55-
def runTraffic(self):
56-
tr = Test.AddTestRun(
57-
"Verify the proper caching behavior for request/response containing auth-related fields when ATS is in default configuration"
58-
)
59-
tr.AddVerifierClientProcess("auth-default-client", self.authDefaultReplayFile, http_ports=[self.ts.Variables.port])
60-
tr.Processes.Default.StartBefore(self.server)
61-
tr.Processes.Default.StartBefore(self.ts)
62-
tr.StillRunningAfter = self.server
63-
tr.StillRunningAfter = self.ts
64-
65-
def run(self):
66-
self.runTraffic()
67-
68-
69-
AuthDefaultTest().run()
70-
71-
72-
class AuthIgnoredTest:
73-
# Verify the proper caching behavior for request/response containing
74-
# auth-related fields when ATS is configured to bypass caching for those
75-
authIgnoredReplayFile = "replay/auth-ignored.replay.yaml"
76-
77-
def __init__(self):
78-
self.setupOriginServer()
79-
self.setupTS()
80-
81-
def setupOriginServer(self):
82-
self.server = Test.MakeVerifierServerProcess("auth-ignored-verifier-server", self.authIgnoredReplayFile)
83-
84-
def setupTS(self):
85-
self.ts = Test.MakeATSProcess("ts-auth-ignored")
86-
self.ts.Disk.records_config.update(
87-
{
88-
"proxy.config.diags.debug.enabled": 1,
89-
"proxy.config.diags.debug.tags": "http",
90-
# Configure ATS to ignore the WWW-Authenticate header in
91-
# response(allow caching of such response)
92-
"proxy.config.http.cache.ignore_authentication": 1
93-
})
94-
self.ts.Disk.remap_config.AddLine(f"map / http://127.0.0.1:{self.server.Variables.http_port}/",)
95-
96-
def runTraffic(self):
97-
tr = Test.AddTestRun(
98-
"Verify the proper caching behavior for request/response containing auth-related fields when ATS is configured to bypass caching for those"
99-
)
100-
tr.AddVerifierClientProcess("auth-ignored-client", self.authIgnoredReplayFile, http_ports=[self.ts.Variables.port])
101-
tr.Processes.Default.StartBefore(self.server)
102-
tr.Processes.Default.StartBefore(self.ts)
103-
tr.StillRunningAfter = self.server
104-
tr.StillRunningAfter = self.ts
105-
106-
def run(self):
107-
self.runTraffic()
108-
109-
110-
AuthIgnoredTest().run()
24+
# Verify proxy.config.http.cache.ignore_authentication behavior.
25+
Test.ATSReplayTest(replay_file="replay/ignore_authentication.replay.yaml")

0 commit comments

Comments
 (0)