Skip to content

Commit

Permalink
nixos/tests/ca-gateway: init test with pvlist and cip
Browse files Browse the repository at this point in the history
  • Loading branch information
minijackson committed Oct 11, 2023
1 parent dffccae commit 4105226
Show file tree
Hide file tree
Showing 2 changed files with 82 additions and 0 deletions.
1 change: 1 addition & 0 deletions nixos/tests/all-tests.nix
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
handleTest = path: args: nixosTesting.simpleTest (import path (pkgs // args));
in {
archiver-appliance = handleTest ./archiver-appliance {};
ca-gateway = handleTest ./ca-gateway.nix {};
phoebus-alarm = handleTest ./phoebus/alarm.nix {};
phoebus-olog = handleTest ./phoebus/olog.nix {};
}
81 changes: 81 additions & 0 deletions nixos/tests/ca-gateway.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
{
epnixLib,
pkgs,
...
}: {
name = "ca-gateway-simple-check";
meta.maintainers = with epnixLib.maintainers; [minijackson];

nodes = let
softIoc = db: let
dbfile = pkgs.writeText "softIoc.db" db;
in {
systemd.services.ioc = {
wantedBy = ["multi-user.target"];
wants = ["network-online.target"];
after = ["network-online.target"];

serviceConfig = {
ExecStart = "${pkgs.epnix.epics-base}/bin/softIoc -S -d ${dbfile}";
DynamicUser = true;
};
};
environment.systemPackages = [pkgs.epnix.epics-base];

networking.firewall.allowedTCPPorts = [5064 5065];
networking.firewall.allowedUDPPorts = [5064 5065];

virtualisation.vlans = [1];
};
in {
ioc = softIoc ''
record(ai, "PV_CLIENT") { }
record(ai, "PV_CLIENT_IGNORED") { }
'';
invisible_ioc = softIoc ''
record(ai, "PV_INVISIBLE_CLIENT") { }
'';

gateway = {
environment.systemPackages = [pkgs.epnix.epics-base];
services.ca-gateway = {
enable = true;
openFirewall = true;
settings = {
cip = ["ioc"];
pvlist = pkgs.writeText "gateway.pvlist" ''
EVALUATION ORDER DENY, ALLOW
.* DENY
PV_CLIENT ALLOW
'';
};
};

# Put 2 first here so that the /etc/hosts file in VMs
# has the gateway IP from vlan 2
virtualisation.vlans = [2 1];
};

client = {
environment.systemPackages = [pkgs.epnix.epics-base];
virtualisation.vlans = [2];
};
};

testScript = ''
start_all()
gateway.wait_for_unit("ca-gateway.service")
ioc.wait_for_unit("ioc.service")
invisible_ioc.wait_for_unit("ioc.service")
client.wait_for_unit("multi-user.target")
def caget(pv: str) -> str:
return f"EPICS_CA_AUTO_ADDR_LIST=NO EPICS_CA_ADDR_LIST=gateway caget {pv}"
client.wait_until_succeeds(caget("PV_CLIENT"))
client.fail(caget("PV_INVISIBLE_CLIENT"))
client.fail(caget("PV_CLIENT_IGNORED"))
'';
}

0 comments on commit 4105226

Please sign in to comment.