dcavalca / rpms / systemd

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