Skip to content

Commit 76c2dac

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

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-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: 13 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,15 @@ 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+
class TestRestartChannelFinder:
51+
def test_channels_same_after_restart(self, setup_compose: DockerCompose, cf_client: ChannelFinderClient) -> None: # noqa: F811
52+
channels_begin = cf_client.find(name="*")
53+
restart_container(setup_compose, "cf")
54+
channels_end = cf_client.find(name="*")
55+
assert len(channels_begin) == len(channels_end)
56+
channels_match(channels_begin, channels_end, PROPERTIES_TO_MATCH)
57+
shutdown_container(setup_compose, "ioc1-1")
58+
channels_inactive = cf_client.find(property=[("iocName", "IOC1-1")])
59+
assert all(ch["pvStatus"] == "Inactive" for ch in channels_inactive)

0 commit comments

Comments
 (0)