Skip to content

Commit e2feb97

Browse files
committed
Add a test remove channel
1 parent c477658 commit e2feb97

File tree

6 files changed

+82
-2
lines changed

6 files changed

+82
-2
lines changed

client/demoApp/Db/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ include $(TOP)/configure/CONFIG
1313
DB += somerecords.db
1414
DB += test_base.db
1515
DB += test_remove_infotag.db
16+
DB += test_remove_channel.db
1617
#----------------------------------------------------
1718
# If <anyname>.db template is not named <anyname>*.template add
1819
# <anyname>_template = <templatename>

client/demoApp/Db/test_base.db

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,9 @@ record(longout, "$(P)lo:base_record") {
99
info("hello", "world")
1010
info("archive", "default")
1111
}
12+
13+
record(longout, "$(P)lo:base_pv2") {
14+
info("test", "testing")
15+
info("hello", "world")
16+
info("archive", "default")
17+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
2+
record(ai, "$(P)ai:base_record") {
3+
info("test", "testing")
4+
info("archive", "MONITOR@1")
5+
}
6+
7+
record(longout, "$(P)lo:base_record") {
8+
info("test", "testing")
9+
info("hello", "world")
10+
info("archive", "default")
11+
}

client/demoApp/Db/test_remove_infotag.db

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,9 @@ record(longout, "$(P)lo:base_record") {
88
info("hello", "world")
99
info("archive", "default")
1010
}
11+
12+
record(longout, "$(P)lo:base_pv2") {
13+
info("test", "testing")
14+
info("hello", "world")
15+
info("archive", "default")
16+
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#!../../bin/linux-x86_64-debug/demo
2+
3+
## You may have to change demo to something else
4+
## everywhere it appears in this file
5+
6+
< envPaths
7+
8+
## Register all support components
9+
dbLoadDatabase("../../dbd/demo.dbd",0,0)
10+
demo_registerRecordDeviceDriver(pdbbase)
11+
12+
var(reccastTimeout, 5.0)
13+
var(reccastMaxHoldoff, 5.0)
14+
15+
epicsEnvSet("IOCNAME", "$(IOCSH_NAME)")
16+
epicsEnvSet("ENGINEER", "myself")
17+
epicsEnvSet("LOCATION", "myplace")
18+
19+
epicsEnvSet("CONTACT", "mycontact")
20+
epicsEnvSet("BUILDING", "mybuilding")
21+
epicsEnvSet("SECTOR", "mysector")
22+
23+
addReccasterEnvVars("CONTACT", "SECTOR")
24+
addReccasterEnvVars("BUILDING")
25+
26+
## Load record instances
27+
dbLoadRecords("../../db/reccaster.db", "P=$(IOCSH_NAME):")
28+
dbLoadRecords("../../db/somerecords.db","P=$(IOCSH_NAME):")
29+
dbLoadRecords("../../db/test_remove_channel.db", "P=$(IOCSH_NAME):")
30+
31+
iocInit()

server/tests/test_bash_ioc.py

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
encoding="utf-8",
2020
)
2121

22+
BASE_CHANNEL_COUNT = 9
2223
setup_compose = ComposeFixtureFactory(Path("docker") / Path("test-bash-ioc.yml")).return_fixture()
2324

2425

@@ -39,7 +40,6 @@ def stream_logs(exec_result, cmd: str):
3940
)
4041
log_thread.start()
4142

42-
4343
def start_ioc(setup_compose: DockerCompose) -> Container:
4444
ioc_container = setup_compose.get_container("ioc1-1")
4545
docker_client = DockerClient()
@@ -75,7 +75,7 @@ def test_remove_infotag(self, setup_compose: DockerCompose) -> None: # noqa: F8
7575
# Arrange
7676
docker_ioc = start_ioc(setup_compose)
7777
LOG.info("Waiting for channels to sync")
78-
cf_client = create_client_and_wait(setup_compose, expected_channel_count=8)
78+
cf_client = create_client_and_wait(setup_compose, expected_channel_count=BASE_CHANNEL_COUNT)
7979

8080
# Check before
8181
LOG.debug('Checking ioc1-1 has ai:base_record with info tag "archive"')
@@ -94,3 +94,28 @@ def get_len_archive_properties(base_channel):
9494
base_channel = cf_client.find(name=base_channel_name)
9595
LOG.debug("archive channel: %s", base_channel)
9696
assert get_len_archive_properties(base_channel) == 0
97+
98+
99+
class TestRemoveChannel:
100+
def test_remove_channel(self, setup_compose: DockerCompose) -> None: # noqa: F811
101+
"""
102+
Test that removing a channel works correctly.
103+
"""
104+
# Arrange
105+
docker_ioc = start_ioc(setup_compose)
106+
LOG.info("Waiting for channels to sync")
107+
cf_client = create_client_and_wait(setup_compose, expected_channel_count=BASE_CHANNEL_COUNT)
108+
109+
# Check ioc1-1 has base channel
110+
LOG.debug('Checking ioc1-1 has ai:base_record2"')
111+
base_channel_name = "IOC1-1:ai:base_record"
112+
base_channel_test_name = "IOC1-1:ai:base_record2"
113+
check_channel_property(cf_client, name=base_channel_name)
114+
check_channel_property(cf_client, name=base_channel_test_name)
115+
116+
# Act
117+
restart_ioc(docker_ioc, cf_client, base_channel_name, "st_remove_channel")
118+
119+
# Assert
120+
check_channel_property(cf_client, name=base_channel_name)
121+
check_channel_property(cf_client, name=base_channel_test_name, prop=INACTIVE_PROPERTY)

0 commit comments

Comments
 (0)