|
5 | 5 | from testcontainers.compose import DockerCompose |
6 | 6 |
|
7 | 7 | from .client_checks import channels_match, check_channel_property, create_client_and_wait, wait_for_sync |
8 | | -from .docker import restart_container, setup_compose # noqa: F401 |
| 8 | +from .docker import restart_container, setup_compose, shutdown_container # noqa: F401 |
9 | 9 |
|
10 | 10 | PROPERTIES_TO_MATCH = ["pvStatus", "recordType", "recordDesc", "alias", "hostName", "iocName", "recceiverID"] |
11 | 11 |
|
@@ -45,3 +45,24 @@ def test_manual_channels_same_after_restart( |
45 | 45 | channels_end = cf_client.find(name="*") |
46 | 46 | assert len(channels_begin) == len(channels_end) |
47 | 47 | channels_match(channels_begin, channels_end, PROPERTIES_TO_MATCH + ["test_property"]) |
| 48 | + |
| 49 | + |
| 50 | +def check_connection_active(cf_client: ChannelFinderClient) -> bool: |
| 51 | + try: |
| 52 | + cf_client.find(name="*") |
| 53 | + return True |
| 54 | + except Exception: |
| 55 | + return False |
| 56 | + |
| 57 | + |
| 58 | +class TestRestartChannelFinder: |
| 59 | + def test_channels_same_after_restart(self, setup_compose: DockerCompose, cf_client: ChannelFinderClient) -> None: # noqa: F811 |
| 60 | + channels_begin = cf_client.find(name="*") |
| 61 | + restart_container(setup_compose, "cf") |
| 62 | + assert wait_for_sync(cf_client, check_connection_active) |
| 63 | + channels_end = cf_client.find(name="*") |
| 64 | + assert len(channels_begin) == len(channels_end) |
| 65 | + channels_match(channels_begin, channels_end, PROPERTIES_TO_MATCH) |
| 66 | + shutdown_container(setup_compose, "ioc1-1") |
| 67 | + channels_inactive = cf_client.find(property=[("iocName", "IOC1-1")]) |
| 68 | + assert all(ch["pvStatus"] == "Inactive" for ch in channels_inactive) |
0 commit comments