From c7278ec2c40d1d2194c2e8178b2d7012bcab1df3 Mon Sep 17 00:00:00 2001 From: Zhou Cheng Date: Fri, 20 Oct 2023 14:29:28 +0800 Subject: [PATCH] CI: add more quota test (#4102) --- .github/scripts/command/quota.sh | 62 ++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) diff --git a/.github/scripts/command/quota.sh b/.github/scripts/command/quota.sh index 7913e66a9700..c227bfdfa4e0 100755 --- a/.github/scripts/command/quota.sh +++ b/.github/scripts/command/quota.sh @@ -62,6 +62,68 @@ test_total_inodes(){ echo a | tee /jfs/test2001 2>error.log && echo "write should fail on out of inodes" && exit 1 || true } +test_nested_dir(){ + prepare_test + ./juicefs format $META_URL myjfs + ./juicefs mount -d $META_URL /jfs --heartbeat $HEARTBEAT_INTERVAL + file_count=1000 + mkdir -p /jfs/d1/{d1,d2,d3,d4,d5,d6}/{d1,d2,d3,d4,d5,d6}/{d1,d2,d3,d4,d5,d6} + dir_count=$(find /jfs/d1 -type d | wc -l) + echo "dir_count: $dir_count" + ./juicefs quota set $META_URL --path /d1 --inodes $((file_count+dir_count-1)) + sleep $HEARTBEAT_INTERVAL + for i in $(seq 1 $file_count); do + subdir=$(find /jfs/d1/ -type d | shuf -n 1) + echo "touch $subdir/test$i" && touch $subdir/test$i + done + sleep $VOLUME_QUOTA_FLUSH_INTERVAL + subdir=$(find /jfs/d1/ -type d | shuf -n 1) + touch $subdir/test 2>error.log && echo "write should fail on out of inodes" && exit 1 || true + grep -i "Disk quota exceeded" error.log || (echo "grep failed" && exit 1) + + ./juicefs quota set $META_URL --path /d1 --inodes $((file_count+dir_count)) + sleep $HEARTBEAT_INTERVAL + subdir=$(find /jfs/d1/ -type d | shuf -n 1) + touch $subdir/test +} + +test_remove_and_restore(){ + prepare_test + ./juicefs format $META_URL myjfs + ./juicefs mount -d $META_URL /jfs --heartbeat $HEARTBEAT_INTERVAL + mkdir -p /jfs/d + ./juicefs quota set $META_URL --path /d --capacity 1 + sleep $((HEARTBEAT_INTERVAL+1)) + dd if=/dev/zero of=/jfs/d/test1 bs=1G count=1 + sleep $DIR_QUOTA_FLUSH_INTERVAL + ./juicefs quota get $META_URL --path /d 2>&1 | tee quota.log + used=$(cat quota.log | grep "/d" | awk -F'|' '{print $5}' | tr -d '[:space:]') + [[ $used != "100%" ]] && echo "used should be 100%" && exit 1 || true + echo a | tee -a /jfs/d/test1 2>error.log && echo "write should fail on out of space" && exit 1 || true + grep -i "Disk quota exceeded" error.log || (echo "grep failed" && exit 1) + + echo "remove test1" && rm /jfs/d/test1 -rf + sleep $DIR_QUOTA_FLUSH_INTERVAL + ./juicefs quota get $META_URL --path /d 2>&1 | tee quota.log + used=$(cat quota.log | grep "/d" | awk -F'|' '{print $5}' | tr -d '[:space:]') + [[ $used != "0%" ]] && echo "used should be 0%" && exit 1 || true + + trash_dir=$(ls /jfs/.trash) + ./juicefs restore $META_URL $trash_dir --put-back + ./juicefs quota get $META_URL --path /d 2>&1 | tee quota.log + used=$(cat quota.log | grep "/d" | awk -F'|' '{print $5}' | tr -d '[:space:]') + [[ $used != "100%" ]] && echo "used should be 100%" && exit 1 || true + sleep $HEARTBEAT_INTERVAL + echo a | tee -a /jfs/d/test1 2>error.log && echo "write should fail on out of space" && exit 1 || true + grep -i "Disk quota exceeded" error.log || (echo "grep failed" && exit 1) + + echo "remove test1" && rm /jfs/d/test1 -rf + dd if=/dev/zero of=/jfs/d/test2 bs=1M count=1 + trash_dir=$(ls /jfs/.trash) + ./juicefs restore $META_URL $trash_dir --put-back 2>&1 | tee restore.log + grep "disk quota exceeded" restore.log || (echo "check restore log failed" && exit 1) +} + test_dir_capacity(){ prepare_test ./juicefs format $META_URL myjfs