1 import ./make-test-python.nix (
4 initiatorName = "iqn.2020-08.org.linux-iscsi.initiatorhost:example";
5 targetName = "iqn.2003-01.org.linux-iscsi.target.x8664:sn.acf8fd9c23af";
10 maintainers = pkgs.lib.teams.deshaw.members
11 ++ (with pkgs.lib.maintainers; [ ajs124 ]);
15 target = { config, pkgs, lib, ... }: {
26 wwn = "92b17c3f-6b40-4168-b082-ceeb7b495522";
37 generate_node_acls = 1;
42 alua_tg_pt_gp_name = "default_tg_pt_gp";
44 storage_object = "/backstores/block/test";
54 write_protect = false;
57 node_wwn = initiatorName;
62 ip_address = "0.0.0.0";
77 networking.firewall.allowedTCPPorts = [ 3260 ];
78 networking.firewall.allowedUDPPorts = [ 3260 ];
80 virtualisation.memorySize = 2048;
81 virtualisation.emptyDiskImages = [ 2048 ];
84 initiatorAuto = { nodes, config, pkgs, ... }: {
85 services.openiscsi = {
87 enableAutoLoginOut = true;
88 discoverPortal = "target";
92 environment.systemPackages = with pkgs; [
96 system.extraDependencies = [ nodes.initiatorRootDisk.config.system.build.toplevel ];
99 substituters = lib.mkForce [];
100 hashed-mirrors = null;
105 initiatorRootDisk = { config, pkgs, modulesPath, lib, ... }: {
106 boot.loader.grub.enable = false;
107 boot.kernelParams = lib.mkOverride 5 (
111 "ip=${config.networking.primaryIPAddress}:::255.255.255.0::ens9:none"
115 # defaults to true, puts some code in the initrd that tries to mount an overlayfs on /nix/store
116 virtualisation.writableStore = false;
118 fileSystems = lib.mkOverride 5 {
122 options = [ "_netdev" ];
126 boot.iscsi-initiator = {
127 discoverPortal = "target";
128 name = initiatorName;
134 testScript = { nodes, ... }: ''
136 target.wait_for_unit("iscsi-target.service")
138 initiatorAuto.start()
140 initiatorAuto.wait_for_unit("iscsid.service")
141 initiatorAuto.wait_for_unit("iscsi.service")
142 initiatorAuto.get_unit_info("iscsi")
144 initiatorAuto.succeed("set -x; while ! test -e /dev/sda; do sleep 1; done")
146 initiatorAuto.succeed("mkfs.xfs /dev/sda")
147 initiatorAuto.succeed("mkdir /mnt && mount /dev/sda /mnt")
148 initiatorAuto.succeed(
149 "nixos-install --no-bootloader --no-root-passwd --system ${nodes.initiatorRootDisk.config.system.build.toplevel}"
151 initiatorAuto.succeed("umount /mnt && rmdir /mnt")
152 initiatorAuto.shutdown()
154 initiatorRootDisk.start()
155 initiatorRootDisk.wait_for_unit("multi-user.target")
156 initiatorRootDisk.wait_for_unit("iscsid")
157 initiatorRootDisk.succeed("touch test")
158 initiatorRootDisk.shutdown()