From 564c917c2a638c48847ec9892e3b3de7b4bad39d Mon Sep 17 00:00:00 2001 From: Jack Doughty Date: Fri, 13 Nov 2026 16:48:21 +0000 Subject: [PATCH 1/2] test blockserver restarts processes --- test_blockserver.py | 46 ++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 45 insertions(+), 1 deletion(-) diff --git a/test_blockserver.py b/test_blockserver.py index e3d882e..0b94bf5 100644 --- a/test_blockserver.py +++ b/test_blockserver.py @@ -3,6 +3,7 @@ import socket import time import unittest +from itertools import product import requests from genie_python import genie as g @@ -10,7 +11,6 @@ from genie_python.utilities import compress_and_hex from hamcrest import assert_that, contains_string, ends_with, is_ from parameterized import parameterized - from utilities import utilities from utilities.utilities import assert_with_timeout, parameterized_list @@ -516,3 +516,47 @@ def test_WHEN_ioc_has_macros_THEN_defaults_handled_correctly( test_pv_with_macro_value(expected_1, "SIMPLE:MACROTEST1", self) test_pv_with_macro_value(expected_2, "SIMPLE:MACROTEST2", self) test_pv_with_macro_value(expected_3, "SIMPLE:MACROTEST3", self) + + @parameterized.expand( + parameterized_list( + list(product( + [ + "RUNCTRL_01", + "BLOCKSVR", + "GWBLOCK", + "ISISDAE_01", + "INSTETC_01", + "DBSVR", + "ALARM", + "ARINST", + "ARBLOCK", + ], + [True, False] + )) + ) + ) + def test_WHEN_restart_service_ioc_pv_written_THEN_restarts_service(self, _, iocname, manager): + utilities.wait_for_iocs_to_be_up([iocname], SECONDS_TO_WAIT_FOR_IOC_STARTS) + start_time_pv = f"CS:IOC:{iocname}:DEVIOS:STARTTOD" + start_time_before = utilities.wait_for_string_pvs_to_not_be_empty( + [start_time_pv], SECONDS_TO_WAIT_FOR_IOC_STARTS, is_local=True + )[start_time_pv] + + g.set_pv("CS:MANAGER", "Yes" if manager else "No", wait=True, is_local=True) + g.set_pv("CS:BLOCKSERVER:RESTART_SERVICE_IOC", compress_and_hex(json.dumps([iocname])), wait=True, is_local=True) + wait_for_server() + + def _restarted(): + utilities.wait_for_iocs_to_be_up([iocname], SECONDS_TO_WAIT_FOR_IOC_STARTS) + start_time_after = utilities.wait_for_string_pvs_to_not_be_empty( + [start_time_pv], SECONDS_TO_WAIT_FOR_IOC_STARTS, is_local=True + )[start_time_pv] + + if manager: + self.assertNotEqual(start_time_before, start_time_after, + f"{iocname} should have restarted") + else: + self.assertEqual(start_time_before, start_time_after, + f"{iocname} should not have restarted") + + assert_with_timeout(_restarted, timeout=SECONDS_TO_WAIT_FOR_IOC_STARTS) From ffbdf4ad54306540c00886584518f7461bf5a75a Mon Sep 17 00:00:00 2001 From: Jack Doughty Date: Fri, 13 Nov 2026 16:51:51 +0000 Subject: [PATCH 2/2] ruff --- test_blockserver.py | 50 +++++++++++++++++++++++++++------------------ 1 file changed, 30 insertions(+), 20 deletions(-) diff --git a/test_blockserver.py b/test_blockserver.py index 0b94bf5..e14105e 100644 --- a/test_blockserver.py +++ b/test_blockserver.py @@ -11,6 +11,7 @@ from genie_python.utilities import compress_and_hex from hamcrest import assert_that, contains_string, ends_with, is_ from parameterized import parameterized + from utilities import utilities from utilities.utilities import assert_with_timeout, parameterized_list @@ -141,7 +142,7 @@ def test_GIVEN_config_changes_by_block_THEN_iocs_do_not_restart_except_for_caenv "CAENV895 ioc should have restarted", ) break - except (Exception, AssertionError) as e: + except AssertionError as e: err = e time.sleep(1) else: @@ -519,20 +520,22 @@ def test_WHEN_ioc_has_macros_THEN_defaults_handled_correctly( @parameterized.expand( parameterized_list( - list(product( - [ - "RUNCTRL_01", - "BLOCKSVR", - "GWBLOCK", - "ISISDAE_01", - "INSTETC_01", - "DBSVR", - "ALARM", - "ARINST", - "ARBLOCK", - ], - [True, False] - )) + list( + product( + [ + "RUNCTRL_01", + "BLOCKSVR", + "GWBLOCK", + "ISISDAE_01", + "INSTETC_01", + "DBSVR", + "ALARM", + "ARINST", + "ARBLOCK", + ], + [True, False], + ) + ) ) ) def test_WHEN_restart_service_ioc_pv_written_THEN_restarts_service(self, _, iocname, manager): @@ -543,7 +546,12 @@ def test_WHEN_restart_service_ioc_pv_written_THEN_restarts_service(self, _, iocn )[start_time_pv] g.set_pv("CS:MANAGER", "Yes" if manager else "No", wait=True, is_local=True) - g.set_pv("CS:BLOCKSERVER:RESTART_SERVICE_IOC", compress_and_hex(json.dumps([iocname])), wait=True, is_local=True) + g.set_pv( + "CS:BLOCKSERVER:RESTART_SERVICE_IOC", + compress_and_hex(json.dumps([iocname])), + wait=True, + is_local=True, + ) wait_for_server() def _restarted(): @@ -553,10 +561,12 @@ def _restarted(): )[start_time_pv] if manager: - self.assertNotEqual(start_time_before, start_time_after, - f"{iocname} should have restarted") + self.assertNotEqual( + start_time_before, start_time_after, f"{iocname} should have restarted" + ) else: - self.assertEqual(start_time_before, start_time_after, - f"{iocname} should not have restarted") + self.assertEqual( + start_time_before, start_time_after, f"{iocname} should not have restarted" + ) assert_with_timeout(_restarted, timeout=SECONDS_TO_WAIT_FOR_IOC_STARTS)