towards a test script

This commit is contained in:
Axel Kittenberger 2010-11-17 11:26:59 +00:00
parent 8ba756ade0
commit dd2273ea20

View File

@ -7,42 +7,50 @@ echo -e "$C1****************************************************************$C0"
echo -e "$C1 Testing layer 4 default rsync with simulated data activity $C0"
echo -e "$C1****************************************************************$C0"
echo
#root tmp dir
# root tmp dir
R=$(mktemp -d)
#source dir
# source dir
S=$R/source
#target dir
# target dir
T=$R/target
# logfile
L=$R/log
# pidfile
P=$R/pid
echo -e "$C1* using root dir for test $R$C0"
echo -e "$C1* populating the source$C0"
mkdir -p "$S"/d1/d11
echo 'test' > "$S"/d1/d11/f1
mkdir -p "$S"/d/e
echo 'test' > "$S"/d/e/f1
echo -e "$C1* starting lsyncd$C0"
./lsyncd --logfile "${LOGFILE}" --pidfile "${PIDFILE}" --verbose --no-daemon "${WORKSOURCE}" "${WORKTARGET}"&
# lets bash detatch Lsyncd instead of itself; lets it log stdout as well.
./lsyncd -logfile "$L" -pidfile "$P" -rsync -nodaemon "$S" "$T" &
echo -e "$C1* waiting for lsyncd to start$C0"
sleep 4s
# cp -r the directory
echo -e "$CON* making a lot of data$COFF"
for A in 1 2 3 4 5 6 7 8 9 10; do
cp -r "${WORKSOURCE}"/a "${WORKSOURCE}"/b${A}
echo 'test2' > "${WORKSOURCE}"/b${A}/a/another
done
mkdir -p "${WORKSOURCE}"/c/a
echo 'test3' > "${WORKSOURCE}"/c/a/file
for A in 1 2 3 4 5 6 7 8 9 10; do
cp -r "${WORKSOURCE}"/c "${WORKSOURCE}"/d${A}
echo 'test2' > "${WORKSOURCE}"/d${A}/a/another
echo -e "$C1* making some data$CO"
for i in 1 2 3 4 5 6 7 8 9 10; do
cp -r "$S"/d "$S"/d${i}
echo 'test2' > "$S"/d${i}/e/f2
done
echo -e "$CON* waiting for lsyncd to do the job.$COFF"
mkdir -p "$S"/m/n
echo 'test3' > "$S"/m/n/file
for i in 1 2 3 4 5 6 7 8 9 10; do
cp -r "$S"/m "$S"/m$i
echo 'test4' > "$S"/m${i}/n/another
done
echo -e "$C1* waiting for lsyncd to do its job.$C0"
sleep 10s
echo -e "$CON* killing lsyncd$COFF"
LSYNCPID=$(cat "${PIDFILE}")
if ! kill "${LSYNCPID}"; then
cat "${LOGFILE}"
diff -urN "${WORKSOURCE}" "${WORKTARGET}" || true
PID=$(cat "$P")
if ! kill "$PID"; then
cat "$L"
diff -urN "$S" "$T" || true
echo "kill failed"
exit 1
fi