-# Test 1 - test basic operations
-test_1() {
- init_src
- init_changelog
- local xattr=$(check_xattr $TGT/foo)
-
- # Directory create
- mkdir $DIR/$tdir/d1
- mkdir $DIR/$tdir/d2
-
- # File create
- touch $DIR/$tdir/file1
- cp /etc/hosts $DIR/$tdir/d1/
- touch $DIR/$tdir/d1/"space in filename"
- touch $DIR/$tdir/d1/file2
-
- # File rename
- mv $DIR/$tdir/d1/file2 $DIR/$tdir/d2/file3
-
- # File and directory delete
- touch $DIR/$tdir/d1/file4
- mkdir $DIR/$tdir/d1/del
- touch $DIR/$tdir/d1/del/del1
- touch $DIR/$tdir/d1/del/del2
- rm -rf $DIR/$tdir/d1/del
- rm $DIR/$tdir/d1/file4
-
- #hard and soft links
- cat /etc/hosts > $DIR/$tdir/d1/link1
- ln $DIR/$tdir/d1/link1 $DIR/$tdir/d1/link2
- ln -s $DIR/$tdir/d1/link1 $DIR/$tdir/d1/link3
-
- # Device files
- #mknod $DIR/$tdir/dev1 b 8 1
-
- # Replicate
- echo "Replication #1"
- $LRSYNC -s $DIR -t $TGT -t $TGT2 -m $MDT0 -u $CL_USER -l $LREPL_LOG
-
- # Set attributes
- chmod 000 $DIR/$tdir/d2/file3
- chown nobody:nobody $DIR/$tdir/d2/file3
-
- # Set xattrs
- if [[ "$xattr" != "no" ]]; then
- local value
- touch $DIR/$tdir/file5
- [[ "$xattr" = "large" ]] &&
- value="$(generate_string $(max_xattr_size))" || value="bar"
- setfattr -n user.foo -v $value $DIR/$tdir/file5
- fi
-
- echo "Replication #2"
- $LRSYNC -l $LREPL_LOG
-
- if [[ "$xattr" != "no" ]]; then
- local xval1=$(get_xattr_value user.foo $TGT/$tdir/file5)
- local xval2=$(get_xattr_value user.foo $TGT2/$tdir/file5)
- fi
-
- RC=0
-
- # fid2path and path2fid aren't implemented for block devices
- #if [[ ! -b $TGT/$tdir/dev1 ]] || [[ ! -b $TGT2/$tdir/dev1 ]]; then
- # ls -l $DIR/$tdir/dev1 $TGT/$tdir/dev1 $TGT2/$tdir/dev1
- # error "Error replicating block devices"
- # RC=1
-
- if [[ "$xattr" != "no" ]] &&
- [[ "$xval1" != "$value" || "$xval2" != "$value" ]]; then
- error "Error in replicating xattrs."
- RC=1
- fi
-
- # Use diff to compare the source and the destination
- check_diff $DIR/$tdir $TGT/$tdir 1
- check_diff $DIR/$tdir $TGT2/$tdir 1
-
- fini_changelog
- cleanup_src_tgt
- return $RC
-}
-run_test 1 "Simple Replication"