<div dir="ltr"><br><div class="gmail_extra"><br clear="all"><div><div dir="ltr"><br>Best Regards, Tikhomirov Pavel.</div></div>
<br><br><div class="gmail_quote">2014-01-29 Tikhomirov Pavel <span dir="ltr"><<a href="mailto:snorcht@gmail.com" target="_blank">snorcht@gmail.com</a>></span><br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
Signed-off-by: Tikhomirov Pavel <<a href="mailto:snorcht@gmail.com">snorcht@gmail.com</a>><br>
---<br>
test/mem-snap/run-snap-dedup-on-restore.sh | 87 ++++++++++++++++++++++++++++++<br>
1 file changed, 87 insertions(+)<br>
create mode 100755 test/mem-snap/run-snap-dedup-on-restore.sh<br>
<br>
diff --git a/test/mem-snap/run-snap-dedup-on-restore.sh b/test/mem-snap/run-snap-dedup-on-restore.sh<br>
new file mode 100755<br>
index 0000000..70c9bb8<br>
--- /dev/null<br>
+++ b/test/mem-snap/run-snap-dedup-on-restore.sh<br>
@@ -0,0 +1,87 @@<br>
+#!/bin/bash<br>
+<br>
+source ../env.sh || exit 1<br>
+<br>
+USEPS=0<br>
+<br>
+if [ "$1" = "-s" ]; then<br>
+ echo "Will test via page-server"<br>
+ USEPS=1<br>
+ shift<br>
+fi<br>
+<br>
+NRSNAP=${1:-3}<br>
+SPAUSE=${2:-4}<br>
+PORT=12345<br>
+<br>
+function fail {<br>
+ echo "$@"<br>
+ exit 1<br>
+}<br>
+set -x<br>
+<br>
+IMGDIR="dump/"<br>
+<br>
+rm -rf "$IMGDIR"<br>
+mkdir "$IMGDIR"<br>
+<br>
+echo "Launching test"<br>
+cd ../zdtm/live/static/<br>
+make cleanout<br>
+make mem-touch<br>
+make mem-touch.pid || fail "Can't start test"<br>
+PID=$(cat mem-touch.pid)<br>
+kill -0 $PID || fail "Test didn't start"<br>
+cd -<br>
+<br>
+echo "Making $NRSNAP snapshots"<br>
+<br>
+for SNAP in $(seq 1 $NRSNAP); do<br>
+ sleep $SPAUSE<br>
+ mkdir "$IMGDIR/$SNAP/"<br>
+ if [ $SNAP -eq 1 ] ; then<br>
+ # First snapshot -- no parent, keep running<br>
+ args="--track-mem -R"<br>
+ elif [ $SNAP -eq $NRSNAP ]; then<br>
+ # Last snapshot -- has parent, kill afterwards<br>
+ args="--prev-images-dir=../$((SNAP - 1))/ --track-mem --auto-dedup"<br>
+ else<br>
+ # Other snapshots -- have parent, keep running<br>
+ args="--prev-images-dir=../$((SNAP - 1))/ --track-mem -R"<br></blockquote><div><br></div><div>here i've lost --auto-dedup, need to be:</div><div> args="--prev-images-dir=../$((SNAP - 1))/ --track-mem -R --auto-dedup"</div>
<div>it's needed to make sure that all pages images are of size 0 in the end.</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
+ fi<br>
+<br>
+ if [ $USEPS -eq 1 ]; then<br>
+ ${CRIU} page-server -D "${IMGDIR}/$SNAP/" -o ps.log --auto-dedup --port ${PORT} -v4 &<br>
+ PS_PID=$!<br>
+ ps_args="--page-server --address 127.0.0.1 --port=${PORT}"<br>
+ else<br>
+ ps_args=""<br>
+ fi<br>
+<br>
+ ${CRIU} dump -D "${IMGDIR}/$SNAP/" -o dump.log -t ${PID} -v4 $args $ps_args || fail "Fail to dump"<br>
+ if [ $USEPS -eq 1 ]; then<br>
+ wait $PS_PID<br>
+ fi<br>
+done<br>
+<br>
+echo "Restoring"<br>
+${CRIU} restore -D "${IMGDIR}/$NRSNAP/" -o restore.log --auto-dedup -d -v4 || fail "Fail to restore server"<br>
+<br>
+size_last3=$(du -sh -BK dump/3/pages-*.img | grep -Eo '[0-9]+' | head -1)<br>
+size_last2=$(du -sh -BK dump/2/pages-*.img | grep -Eo '[0-9]+' | head -1)<br>
+size_last1=$(du -sh -BK dump/1/pages-*.img | grep -Eo '[0-9]+' | head -1)<br>
+<br>
+restore_dedup_ok=0<br>
+if [[ $size_last1 -ne 0 || $size_last2 -ne 0 || $size_last3 -ne 0 ]]; then<br>
+ restore_dedup_ok=1<br>
+fi<br>
+<br>
+cd ../zdtm/live/static/<br>
+make mem-touch.out<br>
+cat mem-touch.out | fgrep PASS || fail "Test failed"<br>
+<br>
+if [ $restore_dedup_ok -ne 0 ]; then<br>
+ fail "Dedup test failed"<br>
+fi<br>
+<br>
+echo "Test PASSED"<br>
<span class=""><font color="#888888">--<br>
1.8.3.2<br>
<br>
</font></span></blockquote></div><br></div></div>