From e490d7778f70e3add42b09ff40bbf1f62ed3e4e8 Mon Sep 17 00:00:00 2001 From: Pavel Emelyanov Date: Tue, 14 May 2013 12:03:18 +0400 Subject: [PATCH] test: Add two tests for pre-dump action The first is similar to existing snapshot test -- it calls several pre-dumps on memory-changing zdtm test, then dumps and check restore goes OK. The second test is aimed at measuring frozen-time -- it takes zdtm test with big mappings, dumps one, then start the test again and calls one pre-dump plus dump. The sum of frozen times in the 2nd dump (well, pre-dump + dump) should be much smaller then the one of the 1st "just dump". Signed-off-by: Pavel Emelyanov --- test/mem-snap/run-predump-2.sh | 66 +++++++++++++++++++++++++++++ test/mem-snap/run-predump.sh | 76 ++++++++++++++++++++++++++++++++++ 2 files changed, 142 insertions(+) create mode 100644 test/mem-snap/run-predump-2.sh create mode 100644 test/mem-snap/run-predump.sh diff --git a/test/mem-snap/run-predump-2.sh b/test/mem-snap/run-predump-2.sh new file mode 100644 index 000000000..71f96017b --- /dev/null +++ b/test/mem-snap/run-predump-2.sh @@ -0,0 +1,66 @@ +#!/bin/bash + +function fail { + echo "$@" + exit 1 +} +set -x + +CRTOOLS="../../crtools" +IMGDIR="dump/" + +rm -rf "$IMGDIR" +mkdir "$IMGDIR" + +function launch_test { + echo "Launching test" + cd ../zdtm/live/static/ + make cleanout + make maps04 + make maps04.pid || fail "Can't start test" + PID=$(cat maps04.pid) + kill -0 $PID || fail "Test didn't start" + cd - +} + +function stop_test { + wtime=1 + cd ../zdtm/live/static/ + make maps04.out + while [ ! -f maps04.out ]; do echo "Wait for maps04.out"; sleep $wtime; ((wtime++)); done + cat maps04.out | fgrep PASS || fail "Test failed" + echo "OK" +} + +launch_test + +echo "Taking plain dump" + +mkdir "$IMGDIR/dump-1/" +${CRTOOLS} dump -D "$IMGDIR/dump-1/" -o dump.log -t ${PID} -v 4 || fail "Fail to dump" + +sleep 1 +echo "Restore to check it works" +${CRTOOLS} restore -D "${IMGDIR}/dump-1/" -o restore.log -d -v 4 || fail "Fail to restore server" + +stop_test + + +launch_test + +echo "Taking pre and plain dumps" + +echo "Pre-dump" +mkdir "$IMGDIR/dump-2/" +mkdir "$IMGDIR/dump-2/pre/" +${CRTOOLS} pre-dump -D "$IMGDIR/dump-2/pre/" -o dump.log -t ${PID} -v 4 || fail "Fail to pre-dump" + +echo "Plain dump" +mkdir "$IMGDIR/dump-2/plain/" +${CRTOOLS} dump -D "$IMGDIR/dump-2/plain/" -o dump.log -t ${PID} -v 4 --prev-images-dir=../pre/ || fail "Fail to dump" + +sleep 1 +echo "Restore" +${CRTOOLS} restore -D "${IMGDIR}/dump-2/plain/" -o restore.log -d -v 4 || fail "Fail to restore server" + +stop_test diff --git a/test/mem-snap/run-predump.sh b/test/mem-snap/run-predump.sh new file mode 100644 index 000000000..c2ced4406 --- /dev/null +++ b/test/mem-snap/run-predump.sh @@ -0,0 +1,76 @@ +#!/bin/bash + +USEPS=0 + +if [ "$1" = "-s" ]; then + echo "Will test via page-server" + USEPS=1 + shift +fi + +NRSNAP=${1:-3} +SPAUSE=${2:-4} +PORT=12345 + +function fail { + echo "$@" + exit 1 +} +set -x + +CRTOOLS="../../crtools" +IMGDIR="dump/" + +rm -rf "$IMGDIR" +mkdir "$IMGDIR" + +echo "Launching test" +cd ../zdtm/live/static/ +make cleanout +make mem-touch +make mem-touch.pid || fail "Can't start test" +PID=$(cat mem-touch.pid) +kill -0 $PID || fail "Test didn't start" +cd - + +echo "Making $NRSNAP pre-dumps" + +for SNAP in $(seq 1 $NRSNAP); do + sleep $SPAUSE + mkdir "$IMGDIR/$SNAP/" + if [ $SNAP -eq 1 ] ; then + # First pre-dump + cmd="pre-dump" + args="--track-mem -R" + elif [ $SNAP -eq $NRSNAP ]; then + # Last dump + cmd="dump" + args="--prev-images-dir=../$((SNAP - 1))/" + else + # Other pre-dumps + cmd="pre-dump" + args="--prev-images-dir=../$((SNAP - 1))/ --track-mem -R" + fi + + if [ $USEPS -eq 1 ]; then + ${CRTOOLS} page-server -D "${IMGDIR}/$SNAP/" -o ps.log --port ${PORT} -v 4 & + PS_PID=$! + ps_args="--page-server --address 127.0.0.1 --port=${PORT}" + else + ps_args="" + fi + + ${CRTOOLS} $cmd -D "${IMGDIR}/$SNAP/" -o dump.log -t ${PID} -v 4 $args $ps_args || fail "Fail to dump" + if [ $USEPS -eq 1 ]; then + wait $PS_PID + fi +done + +echo "Restoring" +${CRTOOLS} restore -D "${IMGDIR}/$NRSNAP/" -o restore.log -t ${PID} -d -v 4 || fail "Fail to restore server" + +cd ../zdtm/live/static/ +make mem-touch.out +cat mem-touch.out | fgrep PASS || fail "Test failed" + +echo "Test PASSED"