ryantimwilson / rpms / systemd

Forked from rpms/systemd a month ago
Clone
ac3a84
From 0894f502ad5a89a98a0a88ee739c0c5f516338c2 Mon Sep 17 00:00:00 2001
ac3a84
From: Yu Watanabe <watanabe.yu+github@gmail.com>
ac3a84
Date: Wed, 1 Feb 2023 21:25:40 +0900
ac3a84
Subject: [PATCH] test: add a testcase for lvextend
ac3a84
ac3a84
For RHBZ#2158628 (https://bugzilla.redhat.com/show_bug.cgi?id=2158628)
ac3a84
ac3a84
(cherry picked from commit d60e3482613d26e559fc4dc5a56b8edaa765a318)
ac3a84
ac3a84
Related: #2138081
ac3a84
---
ac3a84
 test/units/testsuite-64.sh | 20 ++++++++++++++++++++
ac3a84
 1 file changed, 20 insertions(+)
ac3a84
ac3a84
diff --git a/test/units/testsuite-64.sh b/test/units/testsuite-64.sh
ac3a84
index c572671c20..4017f61f59 100755
ac3a84
--- a/test/units/testsuite-64.sh
ac3a84
+++ b/test/units/testsuite-64.sh
ac3a84
@@ -425,6 +425,26 @@ testcase_lvm_basic() {
ac3a84
     helper_check_device_symlinks "/dev/disk" "/dev/$vgroup"
ac3a84
     helper_check_device_units
ac3a84
 
ac3a84
+    # Mount mypart1 through by-label devlink
ac3a84
+    mkdir -p /tmp/mypart1-mount-point
ac3a84
+    mount /dev/disk/by-label/mylvpart1 /tmp/mypart1-mount-point
ac3a84
+    timeout 30 bash -c "while ! systemctl -q is-active /tmp/mypart1-mount-point; do sleep .2; done"
ac3a84
+    # Extend the partition and check if the device and mount units are still active.
ac3a84
+    # See https://bugzilla.redhat.com/show_bug.cgi?id=2158628
ac3a84
+    # Note, the test below may be unstable with LVM2 without the following patch:
ac3a84
+    # https://github.com/lvmteam/lvm2/pull/105
ac3a84
+    # But, to reproduce the issue, udevd must start to process the first 'change' uevent
ac3a84
+    # earlier than extending the volume has been finished, and in most case, the extension
ac3a84
+    # is hopefully fast.
ac3a84
+    lvm lvextend -y --size 8M "/dev/$vgroup/mypart1"
ac3a84
+    udevadm wait --settle --timeout="$timeout" "/dev/disk/by-label/mylvpart1"
ac3a84
+    timeout 30 bash -c "while ! systemctl -q is-active '/dev/$vgroup/mypart1'; do sleep .2; done"
ac3a84
+    timeout 30 bash -c "while ! systemctl -q is-active /tmp/mypart1-mount-point; do sleep .2; done"
ac3a84
+    # Umount the partition, otherwise the underlying device unit will stay in
ac3a84
+    # the inactive state and not be collected, and helper_check_device_units() will fail.
ac3a84
+    systemctl show /tmp/mypart1-mount-point
ac3a84
+    umount /tmp/mypart1-mount-point
ac3a84
+
ac3a84
     # Rename partitions (see issue #24518)
ac3a84
     lvm lvrename "/dev/$vgroup/mypart1" renamed1
ac3a84
     lvm lvrename "/dev/$vgroup/mypart2" renamed2