From 603c58ee286ae88884d912f0d963c7e9732d8125 Mon Sep 17 00:00:00 2001 From: Tom Krizek Date: Mon, 26 Jun 2023 15:18:45 +0200 Subject: [PATCH 1/3] Split shutdown test into separate test cases The shutdown test attempts to shut down the server using two different methods - rndc and sigterm. Use pytest.mark.parametrize to run these as separate test cases for easier identification of failures. --- bin/tests/system/shutdown/tests_shutdown.py | 49 +++++++++++---------- 1 file changed, 26 insertions(+), 23 deletions(-) diff --git a/bin/tests/system/shutdown/tests_shutdown.py b/bin/tests/system/shutdown/tests_shutdown.py index 499dca323a..108c44cbb9 100755 --- a/bin/tests/system/shutdown/tests_shutdown.py +++ b/bin/tests/system/shutdown/tests_shutdown.py @@ -156,7 +156,15 @@ def wait_for_proc_termination(proc, max_timeout=10): return False -def test_named_shutdown(named_port, control_port): +# We test named shutting down using two methods: +# Method 1: using rndc ctop +# Method 2: killing with SIGTERM +# In both methods named should exit gracefully. +@pytest.mark.parametrize("kill_method", [ + "rndc", + "sigtem" +]) +def test_named_shutdown(named_port, control_port, kill_method): # pylint: disable-msg=too-many-locals cfg_dir = os.path.join(os.getcwd(), "resolver") assert os.path.isdir(cfg_dir) @@ -182,25 +190,20 @@ def test_named_shutdown(named_port, control_port): resolver.nameservers = ["10.53.0.3"] resolver.port = named_port - # We test named shutting down using two methods: - # Method 1: using rndc ctop - # Method 2: killing with SIGTERM - # In both methods named should exit gracefully. - for kill_method in ("rndc", "sigterm"): - named_cmdline = [named, "-c", cfg_file, "-f"] - with subprocess.Popen(named_cmdline, cwd=cfg_dir) as named_proc: - try: - assert named_proc.poll() is None, "named isn't running" - assert wait_for_named_loaded(resolver) - do_work( - named_proc, - resolver, - rndc_cmd, - kill_method, - n_workers=12, - n_queries=16, - ) - assert wait_for_proc_termination(named_proc) - assert named_proc.returncode == 0, "named crashed" - finally: # Ensure named is terminated in case of an exception - named_proc.kill() + named_cmdline = [named, "-c", cfg_file, "-f"] + with subprocess.Popen(named_cmdline, cwd=cfg_dir) as named_proc: + try: + assert named_proc.poll() is None, "named isn't running" + assert wait_for_named_loaded(resolver) + do_work( + named_proc, + resolver, + rndc_cmd, + kill_method, + n_workers=12, + n_queries=16, + ) + assert wait_for_proc_termination(named_proc) + assert named_proc.returncode == 0, "named crashed" + finally: # Ensure named is terminated in case of an exception + named_proc.kill() From ceed694659baaffc6e678e680a0dae33d1a07eca Mon Sep 17 00:00:00 2001 From: Tom Krizek Date: Mon, 26 Jun 2023 15:19:35 +0200 Subject: [PATCH 2/3] Use timeout for rndc status in shutdown test Pass 5 second timeout to the rndc status command(s) to avoid hitting the hard 10 second timeout from subprocess.call, which would result in an unwanted exception that would only mask the real issue: if the rndc status times out in this test, it is likely due to the server not stopping as it should. --- bin/tests/system/shutdown/tests_shutdown.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/tests/system/shutdown/tests_shutdown.py b/bin/tests/system/shutdown/tests_shutdown.py index 108c44cbb9..fffc2d1906 100755 --- a/bin/tests/system/shutdown/tests_shutdown.py +++ b/bin/tests/system/shutdown/tests_shutdown.py @@ -105,7 +105,7 @@ def do_work(named_proc, resolver, rndc_cmd, kill_method, n_workers, n_queries): else: # We attempt to send couple rndc commands while named is # being shutdown - futures[executor.submit(launch_rndc, ["status"])] = "status" + futures[executor.submit(launch_rndc, ["-t", "5", "status"])] = "status" ret_code = -1 for future in as_completed(futures): From 5f85f63bf1e044e805b879f5e04437d0f35afb0c Mon Sep 17 00:00:00 2001 From: Tom Krizek Date: Mon, 26 Jun 2023 15:22:32 +0200 Subject: [PATCH 3/3] Mark the test_named_shutdown[rndc] test as xfail It is currently affected by #4060, making the unstable as it occassionally fails. --- bin/tests/system/shutdown/tests_shutdown.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/bin/tests/system/shutdown/tests_shutdown.py b/bin/tests/system/shutdown/tests_shutdown.py index fffc2d1906..2e2bee6c47 100755 --- a/bin/tests/system/shutdown/tests_shutdown.py +++ b/bin/tests/system/shutdown/tests_shutdown.py @@ -160,10 +160,10 @@ def wait_for_proc_termination(proc, max_timeout=10): # Method 1: using rndc ctop # Method 2: killing with SIGTERM # In both methods named should exit gracefully. -@pytest.mark.parametrize("kill_method", [ - "rndc", - "sigtem" -]) +@pytest.mark.parametrize( + "kill_method", + [pytest.param("rndc", marks=pytest.mark.xfail(reason="GL#4060")), "sigtem"], +) def test_named_shutdown(named_port, control_port, kill_method): # pylint: disable-msg=too-many-locals cfg_dir = os.path.join(os.getcwd(), "resolver")