2008-10-08 04:09:02 +00:00
|
|
|
#!/bin/bash
|
|
|
|
# test the case of directory being mv'ed and rm'ed. lsyncd 1.0 didn't handle this case well.
|
|
|
|
|
|
|
|
set -e
|
|
|
|
|
|
|
|
WORKSOURCE=$(mktemp -d)
|
|
|
|
WORKTARGET=$(mktemp -d)
|
|
|
|
PIDFILE=$(mktemp)
|
|
|
|
LOGFILE=$(mktemp)
|
|
|
|
|
2010-05-22 16:24:16 +00:00
|
|
|
echo $WORKSOURCE
|
|
|
|
echo $WORKTARGET
|
|
|
|
echo $PIDFILE
|
2008-10-08 04:09:02 +00:00
|
|
|
|
|
|
|
# populate the filesystem.
|
|
|
|
mkdir "${WORKSOURCE}"/a
|
|
|
|
mkdir "${WORKSOURCE}"/b
|
|
|
|
touch "${WORKSOURCE}"/a/f
|
|
|
|
touch "${WORKSOURCE}"/b/g
|
|
|
|
|
2010-05-22 16:24:16 +00:00
|
|
|
echo ./lsyncd --logfile "${LOGFILE}" --pidfile "${PIDFILE}" "${WORKSOURCE}" "${WORKTARGET}"
|
2008-10-08 04:09:02 +00:00
|
|
|
./lsyncd --logfile "${LOGFILE}" --pidfile "${PIDFILE}" "${WORKSOURCE}" "${WORKTARGET}"
|
2010-05-22 16:24:16 +00:00
|
|
|
LSYNCPID=$(cat "${PIDFILE}")
|
2008-10-08 04:09:02 +00:00
|
|
|
|
2010-05-22 16:24:16 +00:00
|
|
|
# try to wait until lsyncd starts and rsyncs initial file, hope 2s is enough.
|
2008-10-08 04:09:02 +00:00
|
|
|
sleep 2s
|
|
|
|
|
|
|
|
# move a file
|
2010-05-22 16:24:16 +00:00
|
|
|
echo "moving a directory"
|
2008-10-08 04:09:02 +00:00
|
|
|
mv "${WORKSOURCE}"/a "${WORKSOURCE}"/c
|
2010-05-22 16:24:16 +00:00
|
|
|
echo "create a file there"
|
2008-10-08 04:09:02 +00:00
|
|
|
touch "${WORKSOURCE}"/c/h
|
|
|
|
|
2010-05-22 16:24:16 +00:00
|
|
|
echo "and delete a directory"
|
2008-10-08 04:09:02 +00:00
|
|
|
#lsyncd 1.0 dies here
|
|
|
|
rm -r "${WORKSOURCE}"/b
|
|
|
|
|
2010-05-22 16:24:16 +00:00
|
|
|
echo "wait for events to trigger"
|
2008-10-08 04:09:02 +00:00
|
|
|
# try to wait until lsyncd does the job.
|
2010-05-22 16:24:16 +00:00
|
|
|
sleep 10s
|
|
|
|
echo "killing daemon"
|
2008-10-08 04:09:02 +00:00
|
|
|
|
|
|
|
if ! kill "${LSYNCPID}"; then
|
|
|
|
cat "${LOGFILE}"
|
|
|
|
diff -ur "${WORKSOURCE}" "${WORKTARGET}" || true
|
|
|
|
echo "kill failed"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
sleep 1s
|
|
|
|
|
|
|
|
|
|
|
|
echo "log file contents"
|
|
|
|
cat "${LOGFILE}"
|
|
|
|
#this should be grep.
|
|
|
|
|
|
|
|
diff -ur "${WORKSOURCE}" "${WORKTARGET}"
|
|
|
|
|
2010-05-22 16:24:16 +00:00
|
|
|
#rm "${PIDFILE}"
|
|
|
|
#rm "${LOGFILE}"
|
|
|
|
#rm -rf "${WORKTARGET}"
|
|
|
|
#rm -rf "${WORKSOURCE}"
|