Skip to content

Commit 82a4f6a

Browse files
committed
Test removing an alias
1 parent e2feb97 commit 82a4f6a

File tree

5 files changed

+83
-1
lines changed

5 files changed

+83
-1
lines changed

client/demoApp/Db/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ DB += somerecords.db
1414
DB += test_base.db
1515
DB += test_remove_infotag.db
1616
DB += test_remove_channel.db
17+
DB += test_remove_alias.db
1718
#----------------------------------------------------
1819
# If <anyname>.db template is not named <anyname>*.template add
1920
# <anyname>_template = <templatename>

client/demoApp/Db/test_base.db

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,7 @@ record(longout, "$(P)lo:base_pv2") {
1515
info("hello", "world")
1616
info("archive", "default")
1717
}
18+
19+
record(longout, "$(P)lo:base_pv3") {
20+
alias("$(P)lo:base_pv3:alias")
21+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
2+
record(ai, "$(P)ai:base_pv") {
3+
info("test", "testing")
4+
info("archive", "MONITOR@1")
5+
}
6+
7+
record(longout, "$(P)lo:base_pv") {
8+
info("test", "testing")
9+
info("hello", "world")
10+
info("archive", "default")
11+
}
12+
13+
record(longout, "$(P)lo:base_pv2") {
14+
info("test", "testing")
15+
info("hello", "world")
16+
info("archive", "default")
17+
}
18+
19+
record(longout, "$(P)lo:base_pv3") {
20+
}
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_alias.db", "P=$(IOCSH_NAME):")
30+
31+
iocInit()

server/tests/test_bash_ioc.py

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

22-
BASE_CHANNEL_COUNT = 9
22+
BASE_CHANNEL_COUNT = 11 # one alias
2323
setup_compose = ComposeFixtureFactory(Path("docker") / Path("test-bash-ioc.yml")).return_fixture()
2424

2525

@@ -40,6 +40,7 @@ def stream_logs(exec_result, cmd: str):
4040
)
4141
log_thread.start()
4242

43+
4344
def start_ioc(setup_compose: DockerCompose) -> Container:
4445
ioc_container = setup_compose.get_container("ioc1-1")
4546
docker_client = DockerClient()
@@ -119,3 +120,28 @@ def test_remove_channel(self, setup_compose: DockerCompose) -> None: # noqa: F8
119120
# Assert
120121
check_channel_property(cf_client, name=base_channel_name)
121122
check_channel_property(cf_client, name=base_channel_test_name, prop=INACTIVE_PROPERTY)
123+
124+
125+
class TestRemoveAlias:
126+
def test_remove_alias(self, setup_compose: DockerCompose) -> None: # noqa: F811
127+
"""
128+
Test that removing an alias works correctly.
129+
"""
130+
# Arrange
131+
docker_ioc = start_ioc(setup_compose)
132+
LOG.info("Waiting for channels to sync")
133+
cf_client = create_client_and_wait(setup_compose, expected_channel_count=BASE_CHANNEL_COUNT)
134+
135+
# Check before alias status
136+
LOG.debug('Checking ioc1-1 has ai:base_pv3 has an Active alias"')
137+
base_channel_name = "IOC1-1:ai:base_pv3:has_alias"
138+
check_channel_property(cf_client, name=base_channel_name)
139+
base_channel_alias_name = "IOC1-1:ai:base_pv3:alias"
140+
check_channel_property(cf_client, name=base_channel_alias_name)
141+
142+
# Act
143+
restart_ioc(docker_ioc, cf_client, base_channel_name, "st_remove_alias")
144+
145+
# Assert
146+
check_channel_property(cf_client, name=base_channel_name)
147+
check_channel_property(cf_client, name=base_channel_alias_name, prop=INACTIVE_PROPERTY)

0 commit comments

Comments
 (0)