This is an automated email from the ASF dual-hosted git repository. cmcfarlen pushed a commit to branch 10.1.x in repository https://gitbox.apache.org/repos/asf/trafficserver.git
commit 4637c026cd57db43d91b1f23e96ccc71410e1517 Author: Brian Neradt <[email protected]> AuthorDate: Thu Nov 13 17:29:06 2025 -0600 remap_reload.test.py: fix override warnings (#12640) remap_reload.test.py updates the remap.config file and issues a `traffic_ctl config reload` to dynamically integrate those changes into the running ATS process. Before this patch, this was done via creating a new tr.Disk.File() object and writing to it. But this resulted in warnings for overriding the already existing remap.config Disk.File from the setup of the ATS process in the first place. This transitions the test to modify the file via a Setup function instead. This achieves the same result without alarming the autest framework about the conflicting Disk.File object. This patch cleans up these warnings: ``` ╰─➤ ./autest.sh --sandbox /tmp/sb --clean=none -f remap_reload Running Test remap_reload:Warning: Overriding file object /tmp/sb/remap_reload/ts/config/remap.config Warning: Overriding file object /tmp/sb/remap_reload/ts/config/remap.config ........ Passed `` (cherry picked from commit a0f4cf537760b0d2b68aa0970db15997cf5b8682) --- tests/gold_tests/remap/remap_reload.test.py | 42 +++++++++++++++++++---------- 1 file changed, 28 insertions(+), 14 deletions(-) diff --git a/tests/gold_tests/remap/remap_reload.test.py b/tests/gold_tests/remap/remap_reload.test.py index 9deba3a8ee..21a4d2328e 100644 --- a/tests/gold_tests/remap/remap_reload.test.py +++ b/tests/gold_tests/remap/remap_reload.test.py @@ -15,6 +15,20 @@ # limitations under the License. import os + +def update_remap_config(path: str, lines: list) -> None: + """Update the remap.config file. + + This is used to update the config file between test runs without + triggering framework warnings about overriding file objects. + + :param path: The path to the remap.config file. + :param lines: The list of lines to write to the file. + """ + with open(path, 'w') as f: + f.write('\n'.join(lines) + '\n') + + Test.Summary = ''' Test remap reloading ''' @@ -54,15 +68,15 @@ tr.Processes.Default.StartBefore(tm) tr.AddVerifierClientProcess("client", replay_file_1, http_ports=[tm.Variables.port]) tr = Test.AddTestRun("Change remap.config to have only two lines") -tr.Processes.Default.Env = tm.Env -tr.Processes.Default.Command = 'echo "Change remap.config, two lines"' -tr.Disk.File(remap_cfg_path).WriteOn("") -tr.Disk.File( - remap_cfg_path, typename="ats:config").AddLines( - [ +p = tr.Processes.Default +p.Env = tm.Env +p.Command = 'echo "Change remap.config, two lines"' +p.Setup.Lambda( + lambda: update_remap_config( + remap_cfg_path, [ f"map http://alpha.ex http://alpha.ex:{pv_port}", f"map http://bravo.ex http://bravo.ex:{pv_port}", - ]) + ])) tr = Test.AddTestRun("remap_config reload, fails") tr.Processes.Default.Env = tm.Env @@ -75,18 +89,18 @@ tr.AddVerifierClientProcess("client_2", replay_file_2, http_ports=[tm.Variables. tr.Processes.Default.StartBefore(await_config_reload) tr = Test.AddTestRun("Change remap.config to have more than three lines") -tr.Processes.Default.Env = tm.Env -tr.Processes.Default.Command = 'echo "Change remap.config, more than three lines"' -tr.Disk.File(remap_cfg_path).WriteOn("") -tr.Disk.File( - remap_cfg_path, typename="ats:config").AddLines( - [ +p = tr.Processes.Default +p.Env = tm.Env +p.Command = 'echo "Change remap.config, more than three lines"' +p.Setup.Lambda( + lambda: update_remap_config( + remap_cfg_path, [ f"map http://echo.ex http://echo.ex:{pv_port}", f"map http://foxtrot.ex http://foxtrot.ex:{pv_port}", f"map http://golf.ex http://golf.ex:{pv_port}", f"map http://hotel.ex http://hotel.ex:{pv_port}", f"map http://india.ex http://india.ex:{pv_port}", - ]) + ])) tr = Test.AddTestRun("remap_config reload, succeeds") tr.Processes.Default.Env = tm.Env
