|
4 | 4 | from channelfinder import ChannelFinderClient |
5 | 5 | from testcontainers.compose import DockerCompose |
6 | 6 |
|
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 |
| 7 | +from .client_checks import ( |
| 8 | + INACTIVE_PROPERTY, |
| 9 | + channels_match, |
| 10 | + check_channel_property, |
| 11 | + create_client_and_wait, |
| 12 | + wait_for_sync, |
| 13 | +) |
| 14 | +from .docker import restart_container, setup_compose, shutdown_container # noqa: F401 |
9 | 15 |
|
10 | 16 | PROPERTIES_TO_MATCH = ["pvStatus", "recordType", "recordDesc", "alias", "hostName", "iocName", "recceiverID"] |
11 | 17 |
|
@@ -45,3 +51,27 @@ def test_manual_channels_same_after_restart( |
45 | 51 | channels_end = cf_client.find(name="*") |
46 | 52 | assert len(channels_begin) == len(channels_end) |
47 | 53 | channels_match(channels_begin, channels_end, PROPERTIES_TO_MATCH + ["test_property"]) |
| 54 | + |
| 55 | + |
| 56 | +def check_connection_active(cf_client: ChannelFinderClient) -> bool: |
| 57 | + try: |
| 58 | + cf_client.find(name="*") |
| 59 | + return True |
| 60 | + except Exception: |
| 61 | + return False |
| 62 | + |
| 63 | + |
| 64 | +class TestRestartChannelFinder: |
| 65 | + def test_channels_same_after_restart(self, setup_compose: DockerCompose, cf_client: ChannelFinderClient) -> None: # noqa: F811 |
| 66 | + channels_begin = cf_client.find(name="*") |
| 67 | + restart_container(setup_compose, "cf") |
| 68 | + assert wait_for_sync(cf_client, check_connection_active) |
| 69 | + channels_end = cf_client.find(name="*") |
| 70 | + assert len(channels_begin) == len(channels_end) |
| 71 | + channels_match(channels_begin, channels_end, PROPERTIES_TO_MATCH) |
| 72 | + shutdown_container(setup_compose, "ioc1-1") |
| 73 | + assert wait_for_sync( |
| 74 | + cf_client, lambda cf_client: check_channel_property(cf_client, "IOC1-1:Msg-I", INACTIVE_PROPERTY) |
| 75 | + ) |
| 76 | + channels_inactive = cf_client.find(property=[("iocName", "IOC1-1")]) |
| 77 | + assert all(INACTIVE_PROPERTY in ch["properties"] for ch in channels_inactive) |
0 commit comments