Skip to content

Commit

Permalink
CI: test list with follow link (#3953)
Browse files Browse the repository at this point in the history
  • Loading branch information
zhijian-pro authored Aug 1, 2023
1 parent 2a4c738 commit d6edc27
Show file tree
Hide file tree
Showing 2 changed files with 72 additions and 20 deletions.
78 changes: 64 additions & 14 deletions .github/scripts/command/sync.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,27 @@ source .github/scripts/start_meta_engine.sh
start_meta_engine $META
META_URL=$(get_meta_url $META)

generate_source_dir(){
rm -rf jfs_source
git clone https://github.com/juicedata/juicefs.git jfs_source --depth 1
chmod 777 jfs_source
mkdir jfs_source/empty_dir
dd if=/dev/urandom of=jfs_source/file bs=5M count=1
chmod 777 jfs_source/file
ln -sf file jfs_source/symlink_to_file
ln -f jfs_source/file jfs_source/hard_link_to_file
id -u juicefs && sudo userdel juicefs
sudo useradd -u 1101 juicefs
sudo -u juicefs touch jfs_source/file2
ln -s ../cmd jfs_source/pkg/symlink_to_cmd
}

generate_source_dir

generate_fsrand(){
seed=$(date +%s)
python3 .github/scripts/fsrand.py -a -c 2000 -s $seed fsrand
}

test_sync_with_mount_point(){
do_sync_with_mount_point
Expand All @@ -24,7 +45,6 @@ test_sync_without_mount_point(){
do_sync_without_mount_point(){
prepare_test
options=$@
generate_source_dir
./juicefs format $META_URL myjfs
meta_url=$META_URL ./juicefs sync jfs_source/ jfs://meta_url/jfs_source/ $options --links

Expand All @@ -39,7 +59,6 @@ do_sync_without_mount_point(){
do_sync_with_mount_point(){
prepare_test
options=$@
generate_source_dir
./juicefs format $META_URL myjfs
./juicefs mount -d $META_URL /jfs
./juicefs sync jfs_source/ /jfs/jfs_source/ $options --links
Expand All @@ -51,19 +70,50 @@ do_sync_with_mount_point(){
diff -ur --no-dereference jfs_source/ /jfs/jfs_source/
}

test_sync_with_loop_link(){
prepare_test
options="--dirs --update --perms --check-all --list-threads 10 --list-depth 5"
./juicefs format $META_URL myjfs
./juicefs mount -d $META_URL /jfs
ln -s looplink jfs_source/looplink
./juicefs sync jfs_source/ /jfs/jfs_source/ $options > err.log 2>&1 || true
grep "Failed to handle 1 objects" err.log
rm -rf jfs_source/looplink
}

generate_source_dir(){
[[ ! -d jfs_source ]] && git clone https://github.com/juicedata/juicefs.git jfs_source
[[ -d jfs_source/empty_dir ]] && rm jfs_source/empty_dir -rf
chmod 777 jfs_source
mkdir jfs_source/empty_dir
dd if=/dev/urandom of=jfs_source/file bs=5M count=1
chmod 777 jfs_source/file
ln -sf file jfs_source/symlink_to_file
ln -f jfs_source/file jfs_source/hard_link_to_file
id -u juicefs && sudo userdel juicefs
sudo useradd -u 1101 juicefs
sudo -u juicefs touch jfs_source/file2
test_sync_with_deep_link(){
prepare_test
options="--dirs --update --perms --check-all --list-threads 10 --list-depth 5"
./juicefs format $META_URL myjfs
./juicefs mount -d $META_URL /jfs
touch jfs_source/symlink_1
for i in {1..41}; do
ln -s symlink_$i jfs_source/symlink_$((i+1))
done
./juicefs sync jfs_source/ /jfs/jfs_source/ $options 2>&1 | tee err.log || true
grep "Failed to handle 1 objects" err.log
rm -rf jfs_source/symlink_*
}

skip_test_sync_fsrand_with_mount_point(){
generate_fsrand
do_test_sync_fsrand_with_mount_point
do_test_sync_fsrand_with_mount_point --list-threads 10 --list-depth 5
do_test_sync_fsrand_with_mount_point --dirs --update --perms --check-all
do_test_sync_fsrand_with_mount_point --dirs --update --perms --check-all --list-threads 10 --list-depth 5
}

do_test_sync_fsrand_with_mount_point(){
prepare_test
options=$@
./juicefs format $META_URL myjfs
./juicefs mount -d $META_URL /jfs
./juicefs sync fsrand/ /jfs/fsrand/ $options --links

if [[ ! "$options" =~ "--dirs" ]]; then
find jfs_source -type d -empty -delete
fi
diff -ur --no-dereference fsrand/ /jfs/fsrand/
}

test_sync_randomly(){
Expand Down
14 changes: 8 additions & 6 deletions .github/workflows/command.yml
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,13 @@ jobs:

- name: Build
uses: ./.github/actions/build
# with:
# useBeta: true

- name: Test Sync
timeout-minutes: 30
run: |
sudo META=${{matrix.meta}} .github/scripts/command/sync.sh
- name: Test Sync with mino
timeout-minutes: 30
Expand All @@ -182,11 +189,6 @@ jobs:
random_type=${types[$RANDOM % ${#types[@]}]}
sudo CI=true META=${{matrix.meta}} KEY_TYPE=$random_type .github/scripts/command/sync_cluster.sh
- name: Test Sync
timeout-minutes: 30
run: |
sudo META=${{matrix.meta}} .github/scripts/command/sync.sh
- name: Log
if: ${{ always() }}
run: |
Expand Down Expand Up @@ -222,4 +224,4 @@ jobs:

- name: Success
if: ${{ success() }}
run: echo "All Done"
run: echo "All Done"

0 comments on commit d6edc27

Please sign in to comment.