[CRIU] [PATCH 10/10] test/dedup: auto-dedup test

Andrew Vagin avagin at parallels.com
Tue Nov 19 03:42:28 PST 2013


Can we expand zdtm.sh? I don't like these third party test cases,
because they are too simple and nobody executes it...

On Tue, Nov 19, 2013 at 02:28:29PM +0400, Tikhomirov Pavel wrote:
> add auto-dedup when dumping the last time, and check if size become smaller
> 
> Signed-off-by: Tikhomirov Pavel <snorcht at gmail.com>
> ---
>  test/mem-snap/run-snap-auto-dedup.sh |   86 ++++++++++++++++++++++++++++++++++
>  1 file changed, 86 insertions(+)
>  create mode 100755 test/mem-snap/run-snap-auto-dedup.sh
> 
> diff --git a/test/mem-snap/run-snap-auto-dedup.sh b/test/mem-snap/run-snap-auto-dedup.sh
> new file mode 100755
> index 0000000..b7dac8b
> --- /dev/null
> +++ b/test/mem-snap/run-snap-auto-dedup.sh
> @@ -0,0 +1,86 @@
> +#!/bin/bash
> +
> +source ../env.sh || exit 1
> +
> +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
> +
> +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 snapshots"
> +
> +for SNAP in $(seq 1 $NRSNAP); do
> +	sleep $SPAUSE
> +	mkdir "$IMGDIR/$SNAP/"
> +	if [ $SNAP -eq 1 ] ; then
> +		# First snapshot -- no parent, keep running
> +		args="--track-mem -R"
> +	elif [ $SNAP -eq $NRSNAP ]; then
> +		# Last snapshot -- has parent, kill afterwards
> +		size_first=$(du -sh -BK  dump/2/pages-*.img | grep -Eo '[0-9]+' | head -1)
> +		args="--prev-images-dir=../$((SNAP - 1))/ --auto-dedup"
> +	else
> +		# Other snapshots -- have parent, keep running
> +		args="--prev-images-dir=../$((SNAP - 1))/ --track-mem -R"
> +	fi
> +
> +	if [ $USEPS -eq 1 ]; then
> +		${CRIU} page-server -D "${IMGDIR}/$SNAP/" -o ps.log --auto-dedup --port ${PORT} -v4 &
> +		PS_PID=$!
> +		ps_args="--page-server --address 127.0.0.1 --port=${PORT}"
> +	else
> +		ps_args=""
> +	fi
> +
> +	${CRIU} dump -D "${IMGDIR}/$SNAP/" -o dump.log -t ${PID} -v4 $args $ps_args || fail "Fail to dump"
> +	if [ $USEPS -eq 1 ]; then
> +		wait $PS_PID
> +	fi
> +done
> +
> +size_last=$(du -sh -BK dump/2/pages-*.img | grep -Eo '[0-9]+' | head -1)
> +
> +dedup_ok=1
> +if [ $size_first -gt $size_last ]; then
> +	dedup_ok=0	
> +fi
> +
> +echo "Restoring"
> +${CRIU} restore -D "${IMGDIR}/$NRSNAP/" -o restore.log -d -v4 || fail "Fail to restore server"
> +
> +cd ../zdtm/live/static/
> +make mem-touch.out
> +cat mem-touch.out | fgrep PASS || fail "Test failed"
> +
> +if [ $dedup_ok -ne 0 ]; then
> +	fail "Dedup test failed"
> +fi
> +
> +echo "Test PASSED"
> -- 
> 1.7.9.5
> 
> _______________________________________________
> CRIU mailing list
> CRIU at openvz.org
> https://lists.openvz.org/mailman/listinfo/criu


More information about the CRIU mailing list