]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
test: Run TEST-64-UDEV-STORAGE with mkosi 32766/head
authorDaan De Meyer <daan.j.demeyer@gmail.com>
Sun, 12 May 2024 19:27:58 +0000 (21:27 +0200)
committerDaan De Meyer <daan.j.demeyer@gmail.com>
Tue, 14 May 2024 10:43:28 +0000 (12:43 +0200)
We add a configure script for each subtest to add the required
qemu arguments.

Co-authored-by: Richard Maw <richard.maw@codethink.co.uk>
25 files changed:
mkosi.images/system/mkosi.conf
mkosi.images/system/mkosi.conf.d/10-arch/mkosi.conf
mkosi.images/system/mkosi.conf.d/10-centos-fedora/mkosi.conf
mkosi.images/system/mkosi.conf.d/10-centos/mkosi.conf
mkosi.images/system/mkosi.conf.d/10-debian-ubuntu/mkosi.conf
mkosi.images/system/mkosi.conf.d/10-debian/mkosi.conf
mkosi.images/system/mkosi.conf.d/10-debian/mkosi.conf.d/amd64.conf [deleted file]
mkosi.images/system/mkosi.conf.d/10-debian/mkosi.conf.d/arm64.conf [deleted file]
mkosi.images/system/mkosi.conf.d/10-fedora/mkosi.conf
mkosi.images/system/mkosi.conf.d/10-opensuse/mkosi.conf
mkosi.images/system/mkosi.extra/etc/iscsi/iscsid.conf [new file with mode: 0644]
mkosi.images/system/mkosi.extra/usr/lib/systemd/system/isc-dhcp-server.service [deleted file]
test/TEST-64-UDEV-STORAGE/btrfs_basic.configure [new file with mode: 0755]
test/TEST-64-UDEV-STORAGE/iscsi_lvm.configure [new file with mode: 0755]
test/TEST-64-UDEV-STORAGE/long_sysfs_path.configure [new file with mode: 0755]
test/TEST-64-UDEV-STORAGE/lvm_basic.configure [new file with mode: 0755]
test/TEST-64-UDEV-STORAGE/mdadm_basic.configure [new file with mode: 0755]
test/TEST-64-UDEV-STORAGE/mdadm_lvm.configure [new file with mode: 0755]
test/TEST-64-UDEV-STORAGE/megasas2_basic.configure [new file with mode: 0755]
test/TEST-64-UDEV-STORAGE/meson.build
test/TEST-64-UDEV-STORAGE/multipath_basic_failover.configure [new file with mode: 0755]
test/TEST-64-UDEV-STORAGE/nvme_basic.configure [new file with mode: 0755]
test/TEST-64-UDEV-STORAGE/nvme_subsystem.configure [new file with mode: 0755]
test/TEST-64-UDEV-STORAGE/simultaneous_events.configure [new file with mode: 0755]
test/TEST-64-UDEV-STORAGE/virtio_scsi_identically_named_partitions.configure [new file with mode: 0755]

index 7f1c5f571eec52e7f5d060d9547e6a93ea721404..4d3d2d9aa161a1ee340d2963d7264dfb77f30b41 100644 (file)
@@ -42,7 +42,9 @@ Packages=
         kmod
         knot
         less
+        lvm2
         man
+        mdadm
         mtools
         nano
         nftables
index 0a91f6e2261415a7db07ce23739e99ee1ab40ca8..ee1f02cfae68834290f21f32cb7d8d5bebf063b8 100644 (file)
@@ -30,6 +30,8 @@ Packages=
         iputils
         linux
         man-db
+        multipath-tools
+        open-iscsi
         openbsd-netcat
         openssh
         openssl
@@ -44,6 +46,7 @@ Packages=
         shadow
         squashfs-tools
         stress
+        tgt
         tpm2-tools
         tpm2-tss
         vim
index 37211b0cab77765b83498c01a3072f3780259a95..4efa2b440e42da83721a8c5a24f41b1cc7bb7f2b 100644 (file)
@@ -24,6 +24,8 @@ Packages=
         bind-utils
         bpftool
         cryptsetup
+        device-mapper-event
+        device-mapper-multipath
         dfuzzer
         dhcp-server
         dnf
@@ -35,7 +37,9 @@ Packages=
         iproute
         iproute-tc
         iputils
+        iscsi-initiator-utils
         kernel-core
+        kernel-modules # For squashfs and megasas2
         libasan
         libcap-ng-utils
         libubsan
index 54f8f1c1bd39c67c489c2c9e7690ec5995c54e6f..60ea1cb6a3b21e550009332e00c8fa9fa1b0605c 100644 (file)
@@ -9,4 +9,3 @@ RepartDirectories=mkosi.repart
 [Content]
 Packages=
         rpmautospec-rpm-macros
-        kernel-modules # For squashfs
index c80cd2b839efb325711d1dfce3aa47cfb8d92195..1e70a1b579ba9a6e53f57a837304b6df1115144c 100644 (file)
@@ -54,7 +54,9 @@ Packages=
         libtss2-tcti-device0
         locales
         man-db
+        multipath-tools
         netcat-openbsd
+        open-iscsi
         openssh-client
         openssh-server
         passwd
@@ -66,6 +68,7 @@ Packages=
         sbsigntool
         squashfs-tools
         stress
+        tgt
         tpm2-tools
         tzdata
         xxd
index c6b6155dda343d793f9b1d947746097287303b07..6441096322331b903e54e307faf3eb2c2bb635b9 100644 (file)
@@ -2,3 +2,7 @@
 
 [Match]
 Distribution=debian
+
+[Content]
+Packages=
+        linux-image-generic
diff --git a/mkosi.images/system/mkosi.conf.d/10-debian/mkosi.conf.d/amd64.conf b/mkosi.images/system/mkosi.conf.d/10-debian/mkosi.conf.d/amd64.conf
deleted file mode 100644 (file)
index 615de52..0000000
+++ /dev/null
@@ -1,8 +0,0 @@
-# SPDX-License-Identifier: LGPL-2.1-or-later
-
-[Match]
-Architecture=x86-64
-
-[Content]
-Packages=
-        linux-image-cloud-amd64
diff --git a/mkosi.images/system/mkosi.conf.d/10-debian/mkosi.conf.d/arm64.conf b/mkosi.images/system/mkosi.conf.d/10-debian/mkosi.conf.d/arm64.conf
deleted file mode 100644 (file)
index af923fa..0000000
+++ /dev/null
@@ -1,8 +0,0 @@
-# SPDX-License-Identifier: LGPL-2.1-or-later
-
-[Match]
-Architecture=arm64
-
-[Content]
-Packages=
-        linux-image-cloud-arm64
index 838c8314c40c3930cadc2ee70a7fdf58f1ed0eb6..75d2e400ce2e1459935536ededc5669698fbd8ca 100644 (file)
@@ -7,8 +7,9 @@ Distribution=fedora
 Packages=
         btrfs-progs
         compsize
-        f2fs-tools
         dnf5
+        f2fs-tools
+        scsi-target-utils
 
 InitrdPackages=
         btrfs-progs
index 10cbd21a8feb9ccf81cc95306b1d0eac43f8b312..33d3fe6950faa72c77e44566a88c500b5b1d8dab 100644 (file)
@@ -50,6 +50,8 @@ Packages=
         libasan8
         libkmod2
         libubsan1
+        multipath-tools
+        open-iscsi
         openssh-clients
         openssh-server
         pam
@@ -65,6 +67,7 @@ Packages=
         sed
         shadow
         squashfs
+        tgt
         timezone
         tpm2.0-tools
         user(bin)
diff --git a/mkosi.images/system/mkosi.extra/etc/iscsi/iscsid.conf b/mkosi.images/system/mkosi.extra/etc/iscsi/iscsid.conf
new file mode 100644 (file)
index 0000000..fcf4cd9
--- /dev/null
@@ -0,0 +1,3 @@
+# SPDX-License-Identifier: LGPL-2.1-or-later
+
+iscsid.startup = /usr/bin/systemctl start iscsid.socket
diff --git a/mkosi.images/system/mkosi.extra/usr/lib/systemd/system/isc-dhcp-server.service b/mkosi.images/system/mkosi.extra/usr/lib/systemd/system/isc-dhcp-server.service
deleted file mode 100644 (file)
index e69de29..0000000
diff --git a/test/TEST-64-UDEV-STORAGE/btrfs_basic.configure b/test/TEST-64-UDEV-STORAGE/btrfs_basic.configure
new file mode 100755 (executable)
index 0000000..8ef58a9
--- /dev/null
@@ -0,0 +1,26 @@
+#!/usr/bin/python3
+# SPDX-License-Identifier: LGPL-2.1-or-later
+
+import json
+import sys
+
+
+config = json.load(sys.stdin)
+
+config["QemuArgs"] += ["-device", "virtio-scsi-pci,id=scsi0"]
+
+for i in range(4):
+    id = f"drivebtrfsbasic{i}"
+    config["QemuDrives"] += [
+        {
+            "Id": id,
+            "Size": "350M" if i == 0 else "128M",
+            "Options": "cache=unsafe",
+        }
+    ]
+    config["QemuArgs"] += [
+        "-device",
+        f"scsi-hd,drive={id},vendor=systemd,product=foobar,serial=deadbeefbtrfs{i}",
+    ]
+
+json.dump(config, sys.stdout)
diff --git a/test/TEST-64-UDEV-STORAGE/iscsi_lvm.configure b/test/TEST-64-UDEV-STORAGE/iscsi_lvm.configure
new file mode 100755 (executable)
index 0000000..ca23e33
--- /dev/null
@@ -0,0 +1,26 @@
+#!/usr/bin/python3
+# SPDX-License-Identifier: LGPL-2.1-or-later
+
+import json
+import sys
+
+
+config = json.load(sys.stdin)
+
+config["QemuArgs"] += ["-device", "virtio-scsi-pci,id=scsi0"]
+
+for i in range(4):
+    id = f"driveiscsibasic{i}"
+    config["QemuDrives"] += [
+        {
+            "Id": id,
+            "Size": "150M" if i == 0 else "70M",
+            "Options": "cache=unsafe",
+        }
+    ]
+    config["QemuArgs"] += [
+        "-device",
+        f"scsi-hd,drive={id},vendor=systemd,product=foobar,serial=deadbeefiscsi{i}",
+    ]
+
+json.dump(config, sys.stdout)
diff --git a/test/TEST-64-UDEV-STORAGE/long_sysfs_path.configure b/test/TEST-64-UDEV-STORAGE/long_sysfs_path.configure
new file mode 100755 (executable)
index 0000000..6108bdb
--- /dev/null
@@ -0,0 +1,32 @@
+#!/usr/bin/python3
+# SPDX-License-Identifier: LGPL-2.1-or-later
+
+import json
+import sys
+
+
+config = json.load(sys.stdin)
+
+config["QemuDrives"] += [
+    {
+        "Id": "drive0",
+        "Size": "64M",
+        "Options": "cache=unsafe",
+    }
+]
+config["QemuArgs"] += ["-device", "pci-bridge,id=pci_bridge0,chassis_nr=64"]
+
+# Create 25 additional PCI bridges, each one connected to the previous one
+# (basically a really long extension cable), and attach a virtio drive to
+# the last one. This should force udev into attempting to create a device
+# unit with a _really_ long name.
+for bridge in range(1, 26):
+    config["QemuArgs"] += [
+        "-device",
+        f"pci-bridge,id=pci_bridge{bridge},bus=pci_bridge{bridge - 1},"
+        f"chassis_nr={64 + bridge}"
+    ]
+
+config["QemuArgs"] += ["-device", f"virtio-blk-pci,drive=drive0,scsi=off,bus=pci_bridge25"]
+
+json.dump(config, sys.stdout)
diff --git a/test/TEST-64-UDEV-STORAGE/lvm_basic.configure b/test/TEST-64-UDEV-STORAGE/lvm_basic.configure
new file mode 100755 (executable)
index 0000000..9387b83
--- /dev/null
@@ -0,0 +1,25 @@
+#!/usr/bin/python3
+# SPDX-License-Identifier: LGPL-2.1-or-later
+
+import json
+import sys
+
+
+config = json.load(sys.stdin)
+
+config["QemuArgs"] += ["-device", "virtio-scsi-pci,id=scsi0"]
+
+for i in range(4):
+    id = f"drivelvmbasic{i}"
+    config["QemuDrives"] += [
+        {
+            "Id": id,
+            "Size": "32M",
+            "Options": "cache=unsafe",
+        }
+    ]
+    config["QemuArgs"] += [
+        "-device", f"scsi-hd,drive={id},vendor=systemd,product=foobar,serial=deadbeeflvm{i}",
+    ]
+
+json.dump(config, sys.stdout)
diff --git a/test/TEST-64-UDEV-STORAGE/mdadm_basic.configure b/test/TEST-64-UDEV-STORAGE/mdadm_basic.configure
new file mode 100755 (executable)
index 0000000..3f00afa
--- /dev/null
@@ -0,0 +1,25 @@
+#!/usr/bin/python3
+# SPDX-License-Identifier: LGPL-2.1-or-later
+
+import json
+import sys
+
+
+config = json.load(sys.stdin)
+
+config["QemuArgs"] += ["-device", "virtio-scsi-pci,id=scsi0"]
+
+for i in range(5):
+    id = f"drivemdadmbasic{i}"
+    config["QemuDrives"] += [
+        {
+            "Id": id,
+            "Size": "64M",
+            "Options": "cache=unsafe",
+        }
+    ]
+    config["QemuArgs"] += [
+        "-device", f"scsi-hd,drive={id},vendor=systemd,product=foobar,serial=deadbeefmdadm{i}",
+    ]
+
+json.dump(config, sys.stdout)
diff --git a/test/TEST-64-UDEV-STORAGE/mdadm_lvm.configure b/test/TEST-64-UDEV-STORAGE/mdadm_lvm.configure
new file mode 100755 (executable)
index 0000000..b7661d9
--- /dev/null
@@ -0,0 +1,25 @@
+#!/usr/bin/python3
+# SPDX-License-Identifier: LGPL-2.1-or-later
+
+import json
+import sys
+
+
+config = json.load(sys.stdin)
+
+config["QemuArgs"] += ["-device", "virtio-scsi-pci,id=scsi0"]
+
+for i in range(5):
+    id = f"drivemdadmlvm{i}"
+    config["QemuDrives"] += [
+        {
+            "Id": id,
+            "Size": "64M",
+            "Options": "cache=unsafe",
+        }
+    ]
+    config["QemuArgs"] += [
+        "-device", f"scsi-hd,drive={id},vendor=systemd,product=foobar,serial=deadbeefmdadmlvm{i}",
+    ]
+
+json.dump(config, sys.stdout)
diff --git a/test/TEST-64-UDEV-STORAGE/megasas2_basic.configure b/test/TEST-64-UDEV-STORAGE/megasas2_basic.configure
new file mode 100755 (executable)
index 0000000..632e2de
--- /dev/null
@@ -0,0 +1,36 @@
+#!/usr/bin/python3
+# SPDX-License-Identifier: LGPL-2.1-or-later
+
+import json
+import os
+import subprocess
+import sys
+
+
+config = json.load(sys.stdin)
+
+qemu = f"qemu-system-{os.environ["QEMU_ARCHITECTURE"]}"
+result = subprocess.run([qemu, '-device', 'help'], check=True, text=True, stdout=subprocess.PIPE)
+if 'name "megasas-gen2"' not in result.stdout:
+    print("megasas-gen2 device driver is not available, skipping test...", file=sys.stderr)
+    exit(77)
+
+for i in range(4):
+    config["QemuArgs"] += ['-device', f"megasas-gen2,id=scsi{i}"]
+
+for i in range(128):
+    id = f"drive{i}"
+    config["QemuDrives"] += [
+        {
+            "Id": id,
+            "Size": "1M",
+            "Options": "cache=unsafe",
+        }
+    ]
+    config["QemuArgs"] += [
+        '-device',
+        f"scsi-hd,drive={id},bus=scsi{i // 32}.0,channel=0,"
+        f"scsi-id={i % 32},lun=0",
+    ]
+
+json.dump(config, sys.stdout)
index d53dbe562c5bc84ce37286a9d2b3536d48ecb428..ba1d1f8ed3cbc78df96279f39757bc2ce02ba1d3 100644 (file)
@@ -1,8 +1,37 @@
 # SPDX-License-Identifier: LGPL-2.1-or-later
 
-integration_tests += [
-        integration_test_template + {
-                'name' : fs.name(meson.current_source_dir()),
-                'enabled' : false,
-        },
+name = fs.name(meson.current_source_dir())
+unit = configure_file(
+        input : files('../test.service.in'),
+        output : '@0@.service'.format(name),
+        configuration : integration_test_template['configuration'],
+)
+
+foreach testcase : [
+        'btrfs_basic',
+        'iscsi_lvm',
+        'long_sysfs_path',
+        'lvm_basic',
+        'mdadm_basic',
+        'mdadm_lvm',
+        'megasas2_basic',
+        'multipath_basic_failover',
+        'nvme_basic',
+        'nvme_subsystem',
+        'simultaneous_events',
+        'virtio_scsi_identically_named_partitions',
 ]
+        integration_tests += [
+                integration_test_template + {
+                        'name' : '@0@-@1@'.format(name, testcase),
+                        # Make sure the service is still named TEST-64-UDEV-STORAGE.service.
+                        'unit' : unit,
+                        'cmdline' : integration_test_template['cmdline'] + [
+                                'systemd.setenv=TEST_FUNCTION_NAME=testcase_@0@'.format(testcase)
+                        ],
+                        'mkosi-args' : integration_test_template['mkosi-args'] + [
+                                '--configure-script', files('@0@.configure'.format(testcase)),
+                        ],
+                },
+        ]
+endforeach
diff --git a/test/TEST-64-UDEV-STORAGE/multipath_basic_failover.configure b/test/TEST-64-UDEV-STORAGE/multipath_basic_failover.configure
new file mode 100755 (executable)
index 0000000..5f323b8
--- /dev/null
@@ -0,0 +1,31 @@
+#!/usr/bin/python3
+# SPDX-License-Identifier: LGPL-2.1-or-later
+
+import json
+import sys
+
+
+config = json.load(sys.stdin)
+
+# Add 16 multipath devices, each backed by 4 paths
+# We don't use --qemu-drive for this since they have to share the file.
+for ndisk in range(16):
+    wwn = f"0xDEADDEADBEEF{ndisk:04d}"
+    if ndisk == 0:
+        size = "16M"
+    else:
+        size = "1M"
+
+    for nback in range(4):
+        id = f"drive{ndisk}x{nback}"
+        config["QemuDrives"] += [
+            {
+                "Id": id,
+                "Size": size,
+                "Options": "cache=unsafe",
+                "FileId": str(ndisk),
+            }
+        ]
+        config["QemuArgs"] += ["-device", f"scsi-hd,drive={id},serial=MPIO{ndisk},wwn={wwn}"]
+
+json.dump(config, sys.stdout)
diff --git a/test/TEST-64-UDEV-STORAGE/nvme_basic.configure b/test/TEST-64-UDEV-STORAGE/nvme_basic.configure
new file mode 100755 (executable)
index 0000000..68cbd72
--- /dev/null
@@ -0,0 +1,42 @@
+#!/usr/bin/python3
+# SPDX-License-Identifier: LGPL-2.1-or-later
+
+import json
+import os
+import subprocess
+import sys
+
+
+config = json.load(sys.stdin)
+
+qemu = f"qemu-system-{os.environ["QEMU_ARCHITECTURE"]}"
+result = subprocess.run([qemu, '-device', 'help'], check=True, text=True, stdout=subprocess.PIPE)
+if 'name "nvme"' not in result.stdout:
+    print("nvme device driver is not available, skipping test...", file=sys.stderr)
+    exit(77)
+
+for i in range(4):
+    config["QemuArgs"] += ["-device", f"megasas-gen2,id=scsi{i}"]
+
+def add_drive(i: int, serial: str) -> None:
+    global config
+    id = f"nvme{i}"
+    config["QemuDrives"] += [
+        {
+            "Id": id,
+            "Size": "1M",
+            "Options": "cache=unsafe",
+        }
+    ]
+    config["QemuArgs"] += ["-device", f"nvme,drive={id},serial={serial},num_queues=8"]
+
+for i in range(5):
+    add_drive(i, serial=f"deadbeef{i}")
+for i in range(5, 10):
+    add_drive(i, serial=f"    deadbeef  {i}   ")
+for i in range(10, 15):
+    add_drive(i, serial=f"    dead/beef/{i}   ")
+for i in range(15, 20):
+    add_drive(i, serial=f"dead/../../beef/{i}")
+
+json.dump(config, sys.stdout)
diff --git a/test/TEST-64-UDEV-STORAGE/nvme_subsystem.configure b/test/TEST-64-UDEV-STORAGE/nvme_subsystem.configure
new file mode 100755 (executable)
index 0000000..eb601a6
--- /dev/null
@@ -0,0 +1,39 @@
+#!/usr/bin/python3
+# SPDX-License-Identifier: LGPL-2.1-or-later
+
+import json
+import os
+import subprocess
+import sys
+
+
+config = json.load(sys.stdin)
+
+qemu = f"qemu-system-{os.environ["QEMU_ARCHITECTURE"]}"
+result = subprocess.run([qemu, '-device', 'help'], check=True, text=True, stdout=subprocess.PIPE)
+if 'name "nvme"' not in result.stdout:
+    print("nvme device driver is not available, skipping test...", file=sys.stderr)
+    exit(77)
+
+for id in ("nvme0", "nvme1"):
+    config["QemuDrives"] += [
+        {
+            "Id": id,
+            "Size": "1M",
+            "Options": "cache=unsafe",
+        }
+
+    ]
+
+config["QemuArgs"] += [
+    # Create an NVM Subsystem Device
+    "-device", "nvme-subsys,id=nvme-subsys-64,nqn=subsys64",
+    # Attach two NVM controllers to it
+    "-device", "nvme,subsys=nvme-subsys-64,serial=deadbeef",
+    "-device", "nvme,subsys=nvme-subsys-64,serial=deadbeef",
+    # And create two shared namespaces attached to both controllers
+    "-device", "nvme-ns,drive=nvme0,nsid=16,shared=on",
+    "-device", "nvme-ns,drive=nvme1,nsid=17,shared=on",
+]
+
+json.dump(config, sys.stdout)
diff --git a/test/TEST-64-UDEV-STORAGE/simultaneous_events.configure b/test/TEST-64-UDEV-STORAGE/simultaneous_events.configure
new file mode 100755 (executable)
index 0000000..a0edb01
--- /dev/null
@@ -0,0 +1,21 @@
+#!/usr/bin/python3
+# SPDX-License-Identifier: LGPL-2.1-or-later
+
+import json
+import sys
+
+
+config = json.load(sys.stdin)
+
+for i in range(10):
+    id = f"drivesimultaneousevents{i}"
+    config["QemuDrives"] += [
+        {
+            "Id": id,
+            "Size": "128M",
+            "Options": "cache=unsafe",
+        }
+    ]
+    config["QemuArgs"] += ["-device", f"scsi-hd,drive={id},serial=deadbeeftest{i}"]
+
+json.dump(config, sys.stdout)
diff --git a/test/TEST-64-UDEV-STORAGE/virtio_scsi_identically_named_partitions.configure b/test/TEST-64-UDEV-STORAGE/virtio_scsi_identically_named_partitions.configure
new file mode 100755 (executable)
index 0000000..de22c1a
--- /dev/null
@@ -0,0 +1,33 @@
+#!/usr/bin/python3
+# SPDX-License-Identifier: LGPL-2.1-or-later
+
+import json
+import os
+import subprocess
+import sys
+
+
+config = json.load(sys.stdin)
+
+qemu = f"qemu-system-{os.environ["QEMU_ARCHITECTURE"]}"
+result = subprocess.run([qemu, '-device', 'help'], check=True, text=True, stdout=subprocess.PIPE)
+if 'name "virtio-scsi-pci"' not in result.stdout:
+    print("virtio-scsi-pci device driver is not available, skipping test...", file=sys.stderr)
+    exit(77)
+
+num_disk = 16
+
+config["QemuArgs"] += ["-device", "virtio-scsi-pci,id=scsi0,num_queues=4"]
+
+for i in range(0, num_disk):
+    id = f"drivenamedpart{i}"
+    config["QemuDrives"] += [
+        {
+            "Id": id,
+            "Size": "40M",
+            "Options": "cache=unsafe"
+        }
+    ]
+    config["QemuArgs"] += ["-device", f"scsi-hd,drive={id},bus=scsi0.0,channel=0,scsi-id=0,lun={i}"]
+
+json.dump(config, sys.stdout)