From 0a64cb265e50cd30ebe879360de6b2904a2d18b2 Mon Sep 17 00:00:00 2001 From: Mark Laing Date: Wed, 31 Jul 2024 10:56:26 +0100 Subject: [PATCH 1/2] bin: Add an optional timeout argument to waitSnapdSeed. Signed-off-by: Mark Laing --- bin/helpers | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/bin/helpers b/bin/helpers index dffe20cea..c933e1001 100644 --- a/bin/helpers +++ b/bin/helpers @@ -1,12 +1,14 @@ # shellcheck disable=SC2148 # waitSnapdSeed: wait for snapd to be seeded. +# Optional argument: timeout in seconds, defaults to 60. waitSnapdSeed() ( + waitSecs="${1:-60}" set +x - if timeout 60 snap wait system seed.loaded; then + if timeout "${waitSecs}" snap wait system seed.loaded; then return 0 # Success. fi - echo "snapd not seeded after 60s" + echo "snapd not seeded after ${waitSecs}s" return 1 # Failed. ) From 645c38456bef1343b9458219ff8f600bd0a3736d Mon Sep 17 00:00:00 2001 From: Mark Laing Date: Mon, 5 Aug 2024 09:34:12 +0100 Subject: [PATCH 2/2] tests/devlxd-container: Wait indefinitely for snap seed. This follows the pattern used in the `cluster` tests of calling `waitInstanceBooted` and then waiting for the snap seed indefinitely. Signed-off-by: Mark Laing --- tests/devlxd-container | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/devlxd-container b/tests/devlxd-container index 6c2b32eba..c780c3cfa 100755 --- a/tests/devlxd-container +++ b/tests/devlxd-container @@ -85,6 +85,7 @@ if hasNeededAPIExtension instance_ready_state; then [ "$(lxc config get c1 volatile.last_state.ready)" = "false" ] lxc start c1 + waitInstanceBooted c1 else echo "Skipping instance Ready state tests, not supported" fi @@ -99,7 +100,7 @@ fi # We need snapd to be ready before the next tests. Finagle the waitSnapdSeed function definition into the container and run it. # shellcheck disable=SC3044 # Ignore "declare is undefined" shellcheck error. -lxc exec c1 -- sh -c "$(declare -f waitSnapdSeed); waitSnapdSeed" +lxc exec c1 -- snap wait system seed.loaded lxc exec c1 -- snap remove --purge lxd || true lxc exec c1 -- snap install lxd --channel="${LXD_SNAP_CHANNEL}" lxc exec c1 -- /snap/bin/lxd init --auto