Skip to content

Commit 078c923

Browse files
committed
Test removing an alias
1 parent b8c3d56 commit 078c923

File tree

6 files changed

+84
-3
lines changed

6 files changed

+84
-3
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/client_checks.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@
1212
MAX_WAIT_SECONDS = 180
1313
TIME_PERIOD_INCREMENT = 2
1414

15-
# (2 reccaster.db, 2 somerecords.db, 2 aliases in somerecords.db, 3 in test_base.db)
16-
BASE_IOC_CHANNEL_COUNT = 2 + (2 + 2) + 3
15+
# (2 reccaster.db, 2 somerecords.db, 2 aliases in somerecords.db, 4 and 1 alias in test_base.db)
16+
BASE_IOC_CHANNEL_COUNT = 2 + (2 + 2) + (4 + 1)
1717

1818

1919
def channel_match(channel0, channel1, properties_to_match: list[str]):

server/tests/test_bash_ioc.py

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
encoding="utf-8",
2626
)
2727

28-
BASE_CHANNEL_COUNT = 9
28+
BASE_CHANNEL_COUNT = 11 # one alias
2929
setup_compose = ComposeFixtureFactory(Path("docker") / Path("test-bash-ioc.yml")).return_fixture()
3030

3131

@@ -126,3 +126,28 @@ def test_remove_channel(self, setup_compose: DockerCompose) -> None: # noqa: F8
126126
# Assert
127127
check_channel_property(cf_client, name=base_channel_name)
128128
check_channel_property(cf_client, name=base_channel_test_name, prop=INACTIVE_PROPERTY)
129+
130+
131+
class TestRemoveAlias:
132+
def test_remove_alias(self, setup_compose: DockerCompose) -> None: # noqa: F811
133+
"""
134+
Test that removing an alias works correctly.
135+
"""
136+
# Arrange
137+
docker_ioc = start_ioc(setup_compose)
138+
LOG.info("Waiting for channels to sync")
139+
cf_client = create_client_and_wait(setup_compose, expected_channel_count=BASE_CHANNEL_COUNT)
140+
141+
# Check before alias status
142+
LOG.debug('Checking ioc1-1 has ai:base_pv3 has an Active alias"')
143+
base_channel_name = "IOC1-1:ai:base_pv3:has_alias"
144+
check_channel_property(cf_client, name=base_channel_name)
145+
base_channel_alias_name = "IOC1-1:ai:base_pv3:alias"
146+
check_channel_property(cf_client, name=base_channel_alias_name)
147+
148+
# Act
149+
restart_ioc(docker_ioc, cf_client, base_channel_name, "st_remove_alias")
150+
151+
# Assert
152+
check_channel_property(cf_client, name=base_channel_name)
153+
check_channel_property(cf_client, name=base_channel_alias_name, prop=INACTIVE_PROPERTY)

0 commit comments

Comments
 (0)