Skip to content

Commit aaa3f72

Browse files
committed
Test restarting channelfinder works ok
1 parent e663296 commit aaa3f72

File tree

2 files changed

+28
-1
lines changed

2 files changed

+28
-1
lines changed

server/tests/docker.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,3 +47,9 @@ def restart_container(compose: DockerCompose, host_name: str) -> None:
4747
docker_client = DockerClient()
4848
docker_client.containers.get(container.ID).stop()
4949
docker_client.containers.get(container.ID).start()
50+
51+
52+
def shutdown_container(compose: DockerCompose, host_name: str) -> None:
53+
container = compose.get_container(host_name)
54+
docker_client = DockerClient()
55+
docker_client.containers.get(container.ID).stop()

server/tests/test_restart.py

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
from testcontainers.compose import DockerCompose
66

77
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
99

1010
PROPERTIES_TO_MATCH = ["pvStatus", "recordType", "recordDesc", "alias", "hostName", "iocName", "recceiverID"]
1111

@@ -45,3 +45,24 @@ def test_manual_channels_same_after_restart(
4545
channels_end = cf_client.find(name="*")
4646
assert len(channels_begin) == len(channels_end)
4747
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

Comments
 (0)