From 7b093f95639e2bf44f469e1fb855e21851f5844e Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Sun, 4 Sep 2016 13:35:01 +0200 Subject: fix race in op-remove-retry --- tests/lib/snaps/test-snapd-tools/bin/block | 2 ++ tests/main/op-remove-retry/task.yaml | 6 ++++++ 2 files changed, 8 insertions(+) (limited to 'tests') diff --git a/tests/lib/snaps/test-snapd-tools/bin/block b/tests/lib/snaps/test-snapd-tools/bin/block index 2c68e4ef68..cf220677a2 100755 --- a/tests/lib/snaps/test-snapd-tools/bin/block +++ b/tests/lib/snaps/test-snapd-tools/bin/block @@ -5,6 +5,8 @@ set -ex cd $SNAP echo "blocking dir $(pwd)" +touch $SNAP_DATA/block + echo "waiting, press ctrl-c to stop" sleep 999999 exit 0 diff --git a/tests/main/op-remove-retry/task.yaml b/tests/main/op-remove-retry/task.yaml index aa087d13cf..5edba91ec6 100644 --- a/tests/main/op-remove-retry/task.yaml +++ b/tests/main/op-remove-retry/task.yaml @@ -21,8 +21,14 @@ execute: | snap install --dangerous test-snapd-tools_1.0_all.snap echo "And its mount point is kept busy" + # we need a marker file, because just using systemd to figure out + # if the service has started is racy, start just means started, + # not that the dir is actually blocked yet + MARKER=/var/snap/test-snapd-tools/current/block + rm -f $MARKER systemd-run --unit unmount-blocker $(which test-snapd-tools.block) wait_for_service unmount-blocker active + while [ ! -f $MARKER ]; do sleep 1; done echo "When we try to remove the snap" snap remove test-snapd-tools & -- cgit v1.2.3