lsyncd/tests/l4-rsync-data.sh

71 lines
1.5 KiB
Bash
Raw Normal View History

2010-11-16 14:27:31 +00:00
#!/bin/bash
2010-11-17 13:58:31 +00:00
RANGE=1
LOG="-log all"
2010-11-16 14:27:31 +00:00
set -e
2010-11-16 20:56:26 +00:00
C1="\E[47;34m"
C0="\033[0m"
echo -e "$C1****************************************************************$C0"
echo -e "$C1 Testing layer 4 default rsync with simulated data activity $C0"
echo -e "$C1****************************************************************$C0"
echo
2010-11-17 11:26:59 +00:00
# root tmp dir
2010-11-16 20:56:26 +00:00
R=$(mktemp -d)
2010-11-17 11:26:59 +00:00
# source dir
2010-11-16 20:56:26 +00:00
S=$R/source
2010-11-17 11:26:59 +00:00
# target dir
2010-11-16 20:56:26 +00:00
T=$R/target
2010-11-17 11:26:59 +00:00
# logfile
L=$R/log
# pidfile
P=$R/pid
2010-11-16 20:56:26 +00:00
echo -e "$C1* using root dir for test $R$C0"
echo -e "$C1* populating the source$C0"
2010-11-17 18:52:55 +00:00
echo -e "$C1* ceating d[x]/e/f1 $C0"
2010-11-17 11:26:59 +00:00
mkdir -p "$S"/d/e
echo 'test' > "$S"/d/e/f1
2010-11-16 20:56:26 +00:00
echo -e "$C1* starting lsyncd$C0"
2010-11-17 11:26:59 +00:00
# lets bash detatch Lsyncd instead of itself; lets it log stdout as well.
2010-11-17 13:58:31 +00:00
echo ./lsyncd $LOG -logfile "$L" -pidfile "$P" -nodaemon -rsync "$S" "$T"
./lsyncd $LOG -logfile "$L" -pidfile "$P" -nodaemon -rsync "$S" "$T" &
2010-11-16 20:56:26 +00:00
echo -e "$C1* waiting for lsyncd to start$C0"
2010-11-16 14:27:31 +00:00
sleep 4s
# cp -r the directory
2010-11-17 18:52:55 +00:00
echo -e "$C1* making some data$C0"
echo -e "$C1* ceating d[x]/e/f2 $C0"
2010-11-17 13:58:31 +00:00
for i in $RANGE; do
2010-11-17 11:26:59 +00:00
cp -r "$S"/d "$S"/d${i}
2010-11-17 18:52:55 +00:00
# echo 'test2' > "$S"/d${i}/e/f2
2010-11-16 14:27:31 +00:00
done
2010-11-17 11:26:59 +00:00
2010-11-17 13:58:31 +00:00
#mkdir -p "$S"/m/n
#echo 'test3' > "$S"/m/n/file
#for i in $RANGE; do
# cp -r "$S"/m "$S"/m$i
# echo 'test4' > "$S"/m${i}/n/another
#done
2010-11-16 14:27:31 +00:00
2010-11-17 13:58:31 +00:00
echo -e "$C1* waiting for Lsyncd to do its job.$C0"
2010-11-17 18:52:55 +00:00
sleep 20s
2010-11-16 14:27:31 +00:00
2010-11-17 13:58:31 +00:00
echo -e "$C1* killing Lsyncd$C0"
2010-11-17 11:26:59 +00:00
PID=$(cat "$P")
if ! kill "$PID"; then
cat "$L"
diff -urN "$S" "$T" || true
2010-11-16 14:27:31 +00:00
echo "kill failed"
exit 1
fi
sleep 1s
2010-11-17 13:58:31 +00:00
echo -e "$C1* differences$C0"
diff -urN "$S" "$T"
2010-11-16 14:27:31 +00:00
2010-11-17 13:58:31 +00:00
#rm -rf "$R"
2010-11-16 14:27:31 +00:00