Skip to content

Commit 1b6847f

Browse files
authored
Fix flaky filter_body test (#12882)
The filter_body test's Proxy Verifier client can exit with either 0 or 1 depending on timing of connection closure during request body blocking. The ATSReplayTest extension only supported a single scalar return_code value, so the test would intermittently fail when the client happened to exit with 0 instead of the expected 1. Support a list of return codes in the replay YAML by wrapping them in Any() when a list is provided, and update the filter_body test to accept either exit code.
1 parent 9a450eb commit 1b6847f

2 files changed

Lines changed: 11 additions & 5 deletions

File tree

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

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -172,9 +172,11 @@ def ATSReplayTest(obj, replay_file: str):
172172
process_config = server_config.get('process_config', {})
173173
server = tr.AddVerifierServerProcess(name, replay_file, **process_config)
174174

175-
# Set expected return code for server if specified.
175+
# Set expected return code for server if specified. A list of codes is
176+
# wrapped in Any() so that any of the listed values is accepted.
176177
if 'return_code' in server_config:
177-
server.ReturnCode = server_config['return_code']
178+
rc = server_config['return_code']
179+
server.ReturnCode = Any(*rc) if isinstance(rc, list) else rc
178180

179181
# ATS configuration.
180182
if not 'ats' in autest_config:
@@ -193,9 +195,11 @@ def ATSReplayTest(obj, replay_file: str):
193195
client = tr.AddVerifierClientProcess(
194196
name, replay_file, http_ports=[ts.Variables.port], https_ports=https_ports, **process_config)
195197

196-
# Set expected return code if specified.
198+
# Set expected return code if specified. A list of codes is wrapped in
199+
# Any() so that any of the listed values is accepted.
197200
if 'return_code' in client_config:
198-
client.ReturnCode = client_config['return_code']
201+
rc = client_config['return_code']
202+
client.ReturnCode = Any(*rc) if isinstance(rc, list) else rc
199203

200204
if dns:
201205
ts.StartBefore(dns)

tests/gold_tests/pluginTest/filter_body/filter_body.replay.yaml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,9 @@ autest:
2929

3030
client:
3131
name: 'client'
32-
return_code: 1
32+
# There's a race condition for when the connection is droped by ATS - this
33+
# can result in either a 0 or 1 return code.
34+
return_code: [0, 1]
3335

3436
ats:
3537
name: 'ts'

0 commit comments

Comments
 (0)