Skip to content

Commit

Permalink
Adapt quota test to systemd 256 templated service
Browse files Browse the repository at this point in the history
  • Loading branch information
volodymyrkatkalov committed Dec 19, 2024
1 parent 7c85092 commit 0e25496
Showing 1 changed file with 19 additions and 7 deletions.
26 changes: 19 additions & 7 deletions tests/console/quota.pm
Original file line number Diff line number Diff line change
Expand Up @@ -35,27 +35,37 @@ sub run {

# install requirements
zypper_call 'in quota quota-nfs';
my $systemd_version = int(script_output('systemctl --version | grep systemd | awk \'{print $2}\''));
my $use_templated_service = ($systemd_version >= 256);
record_info('Systemd Version', "Detected systemd version: $systemd_version");

# restart quota service
systemctl "restart quotaon";
systemctl "restart quotaon" unless $use_templated_service;

# create filesystem image to use
assert_script_run "dd if=/dev/zero of=/tmp/quota.img bs=10M count=10";
assert_script_run "mkfs.ext3 -m0 /tmp/quota.img";
assert_script_run "mkdir /tmp/quota";

#mount disk image
assert_script_run "mount -o loop,rw,usrquota,grpquota /tmp/quota.img /tmp/quota/";
assert_script_run "mount -o loop,rw,usrquota,grpquota /tmp/quota.img /tmp/quota";
# Escape the mount point for systemd service naming
my $escaped_mount = "";
if ($use_templated_service) {
$escaped_mount = script_output("systemd-escape -p /tmp/quota");
chomp($escaped_mount);
}

#creating some dir
assert_script_run "cd /tmp/quota/ ; mkdir test-directory ; chmod 77 test-directory ; ls -l";
assert_script_run "mkdir /tmp/quota/test-directory; chmod 777 /tmp/quota/test-directory";

#testing quota commands:
assert_script_run "quotacheck -cug /tmp/quota";
#setquota to user
assert_script_run "setquota -u $username 100 200 6 10 /tmp/quota";
#enable quota
assert_script_run "quotaon /tmp/quota";
assert_script_run("systemctl start quotaon@" . $escaped_mount) if $use_templated_service;
assert_script_run("quotaon /tmp/quota") unless $use_templated_service;
# run user to use all quota
ensure_serialdev_permissions;
select_console 'user-console';
Expand All @@ -65,15 +75,17 @@ sub run {
assert_script_run 'echo {1..6} | xargs touch';
#quota return 1 when user exceed quota limte. Line bellow accept when return is 1.
die 'Quota should report failure' if script_run('quota') == 0;
assert_script_run "cd";
assert_script_run "cd" unless $use_templated_service;

select_console 'root-console';
#quota report
assert_script_run "repquota /tmp/quota";

#Clean configurations, stop quota, dismount disc image
systemctl "stop quotaon";
assert_script_run "cd ; umount /tmp/quota";
assert_script_run("systemctl stop quotaon@" . $escaped_mount) if $use_templated_service;
systemctl "stop quotaon" unless $use_templated_service;
script_retry("umount -l /tmp/quota", timeout => 180, retry => 3) if $use_templated_service;
assert_script_run "cd ; umount /tmp/quota" unless $use_templated_service;
assert_script_run "rm /tmp/quota.img";
}

Expand Down

0 comments on commit 0e25496

Please sign in to comment.