]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
test: add test case for homed rebalancing logic
authorLennart Poettering <lennart@poettering.net>
Thu, 25 Nov 2021 09:48:52 +0000 (10:48 +0100)
committerLennart Poettering <lennart@poettering.net>
Thu, 25 Nov 2021 17:28:44 +0000 (18:28 +0100)
test/units/testsuite-46.sh

index 1ca5f033022db6a16ee4dd892e5aaa96d689c3f7..be70a39485a613f77f0f9bb5426e0ac439fdd8db 100755 (executable)
@@ -22,6 +22,8 @@ inspect() {
     # diff uses the grep BREs for pattern matching
     diff -I '^\s*Disk \(Size\|Free\|Floor\|Ceiling\):' /tmp/{a,b}
     rm /tmp/{a,b}
+
+    homectl inspect --json=pretty "$USERNAME"
 }
 
 systemd-analyze log-level debug
@@ -29,8 +31,8 @@ systemd-analyze log-target console
 systemctl service-log-level systemd-homed debug
 
 # Create a tmpfs to use as backing store for the home dir. That way we can enforce a size limit nicely.
-mkdir -p /home-pool
-mount -t tmpfs tmpfs /home-pool -o size=290M
+mkdir -p /home
+mount -t tmpfs tmpfs /home -o size=290M
 
 # we enable --luks-discard= since we run our tests in a tight VM, hence don't
 # needlessly pressure for storage. We also set the cheapest KDF, since we don't
@@ -38,7 +40,7 @@ mount -t tmpfs tmpfs /home-pool -o size=290M
 NEWPASSWORD=xEhErW0ndafV4s homectl create test-user \
            --disk-size=min \
            --luks-discard=yes \
-           --image-path=/home-pool/test-user.home \
+           --image-path=/home/test-user.home \
            --luks-pbkdf-type=pbkdf2 \
            --luks-pbkdf-time-cost=1ms
 inspect test-user
@@ -110,8 +112,38 @@ if ! systemd-detect-virt -cq ; then
     PASSWORD=xEhErW0ndafV4s homectl resize test-user 256M
     inspect test-user
 
-    homectl deactivate test-user
+    # minimize again
+    PASSWORD=xEhErW0ndafV4s homectl resize test-user min
+    inspect test-user
+
+    # Increase space, so that we can reasonably rebalance free space between to home dirs
+    mount /home -o remount,size=800M
+
+    # create second user
+    NEWPASSWORD=uuXoo8ei homectl create test-user2 \
+           --disk-size=min \
+           --luks-discard=yes \
+           --image-path=/home/test-user2.home \
+           --luks-pbkdf-type=pbkdf2 \
+           --luks-pbkdf-time-cost=1ms
+    inspect test-user2
+
+    # activate second user
+    PASSWORD=uuXoo8ei homectl activate test-user2
+    inspect test-user2
+
+    # set second user's rebalance weight to 100
+    PASSWORD=uuXoo8ei homectl update test-user2 --rebalance-weight=100
+    inspect test-user2
+
+    # set first user's rebalance weight to quarter of that of the second
+    PASSWORD=xEhErW0ndafV4s homectl update test-user --rebalance-weight=25
+    inspect test-user
+
+    # synchronously rebalance
+    homectl rebalance
     inspect test-user
+    inspect test-user2
 fi
 
 PASSWORD=xEhErW0ndafV4s homectl with test-user -- test ! -f /home/test-user/xyz