Skip to content

Commit

Permalink
CI: add more quota test (#4102)
Browse files Browse the repository at this point in the history
  • Loading branch information
zhoucheng361 authored Oct 20, 2023
1 parent 6716892 commit c7278ec
Showing 1 changed file with 62 additions and 0 deletions.
62 changes: 62 additions & 0 deletions .github/scripts/command/quota.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit c7278ec

Please sign in to comment.