Skip to content

Commit

Permalink
CI: test load/dump with acl (#4514)
Browse files Browse the repository at this point in the history
Co-authored-by: Sandy Xu <[email protected]>
  • Loading branch information
zhoucheng361 and SandyXSD authored Mar 15, 2024
1 parent 6db75cc commit 6de1bdc
Showing 1 changed file with 48 additions and 0 deletions.
48 changes: 48 additions & 0 deletions .github/scripts/command/load_dump.sh
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,54 @@ test_dump_load_gzip()
do_dump_load dump.json.gz
}

test_dump_load_with_fsrand()
{
prepare_test
./juicefs format $META_URL myjfs --trash-days 0 --enable-acl
./juicefs mount -d $META_URL /jfs --enable-xattr
MAX_EXAMPLE=100 STEP_COUNT=50 PROFILE=generate ROOT_DIR1=/jfs/fsrand ROOT_DIR2=/tmp/fsrand python3 .github/scripts/hypo/fsrand2.py || true

./juicefs dump $META_URL dump.json --fast
./juicefs load sqlite3://test2.db dump.json
./juicefs dump sqlite3://test2.db dump2.json --fast
compare_dump_json
./juicefs mount -d sqlite3://test2.db /jfs2
diff -ur /jfs/fsrand /jfs2/fsrand --no-dereference
compare_stat_acl /jfs/fsrand /jfs2/fsrand
}

compare_dump_json(){
sed -i '/usedSpace/d' dump*.json
sed -i '/usedInodes/d' dump*.json
sed -i '/nextInodes/d' dump*.json
sed -i '/nextChunk/d' dump*.json
sed -i '/nextSession/d' dump*.json
sed -i 's/"inode":[0-9]\+/"inode":0/g' dump*.json
diff -ur dump.json dump2.json
}

compare_stat_acl(){
dir1=$1
dir2=$2
files1=($(find "$dir1" -type f -o -type d -exec stat -c "%n" {} + | sort))
files2=($(find "$dir2" -type f -o -type d -exec stat -c "%n" {} + | sort))
[[ ${#files1[@]} -ne ${#files2[@]} ]] && echo "compare_stat_acl: number of files differs" && exit 1
for i in "${!files1[@]}"; do
stat1=$(stat -c "%F %a %s %h %U %G" "${files1[$i]}")
stat2=$(stat -c "%F %a %s %h %U %G" "${files2[$i]}")
acl1=$(getfacl -p "${files1[$i]}" | tail -n +2)
acl2=$(getfacl -p "${files2[$i]}" | tail -n +2)
# echo $i
# echo $stat1
# echo $stat2
# echo $acl1
# echo $acl2
[[ "$stat1" != "$stat2" ]] && echo "compare_stat_acl: stat for ${files1[$i]} and ${files2[$i]} differs" && echo $stat1 && echo $stat2 && exit 1
[[ "$acl1" != "$acl2" ]] && echo "compare_stat_acl: ACLs for ${files1[$i]} and ${files2[$i]} differs" && echo $acl1 && echo $acl2 && exit 1
done
echo "compare_stat_acl: ACLs and stats are the same"
}

test_load_encrypted_meta_backup()
{
prepare_test
Expand Down

0 comments on commit 6de1bdc

Please sign in to comment.