summaryrefslogtreecommitdiff
diff options
authorMichael Vogt <mvo@ubuntu.com>2021-12-06 15:45:27 +0100
committerGitHub <noreply@github.com>2021-12-06 15:45:27 +0100
commit49d5548ec85c17546ec57249906336cf49f80eae (patch)
tree07c5be7be1767d46d360d430b01725afd811c879
parente01fc9592f494f93bf4460257393cadd4dafd79d (diff)
parent116fa26916a32c582066340c73025f50ca5601d4 (diff)
Merge pull request #11131 from bboozzoo/bboozzoo/nested-wait-for-serial
tests/nested/manual/core20-remodel: wait for device to have a serial before starting a remodel
-rw-r--r--tests/lib/nested.sh20
-rw-r--r--tests/nested/manual/core20-remodel/task.yaml3
2 files changed, 20 insertions, 3 deletions
diff --git a/tests/lib/nested.sh b/tests/lib/nested.sh
index 3a6a81cd7d..db8faeea75 100644
--- a/tests/lib/nested.sh
+++ b/tests/lib/nested.sh
@@ -1437,7 +1437,7 @@ nested_fetch_spread() {
mkdir -p "$NESTED_WORK_DIR"
curl -s https://storage.googleapis.com/snapd-spread-tests/spread/spread-amd64.tar.gz | tar -xz -C "$NESTED_WORK_DIR"
# make sure spread really exists
- test -x "$NESTED_WORK_DIR/spread"
+ test -x "$NESTED_WORK_DIR/spread"
fi
echo "$NESTED_WORK_DIR/spread"
}
@@ -1451,7 +1451,21 @@ nested_build_seed_cdrom() {
local ORIG_DIR=$PWD
- pushd "$SEED_DIR" || return 1
+ pushd "$SEED_DIR" || return 1
genisoimage -output "$ORIG_DIR/$SEED_NAME" -volid "$LABEL" -joliet -rock "$@"
- popd || return 1
+ popd || return 1
+}
+
+nested_wait_for_device_initialized_change() {
+ local retry=60
+ local wait=1
+
+ while ! nested_exec "snap changes" | MATCH "Done.*Initialize device"; do
+ retry=$(( retry - 1 ))
+ if [ $retry -le 0 ]; then
+ echo "Timed out waiting for device to be fully initialized. Aborting!"
+ return 1
+ fi
+ sleep "$wait"
+ done
}
diff --git a/tests/nested/manual/core20-remodel/task.yaml b/tests/nested/manual/core20-remodel/task.yaml
index bbf9e91191..1a16c6dca2 100644
--- a/tests/nested/manual/core20-remodel/task.yaml
+++ b/tests/nested/manual/core20-remodel/task.yaml
@@ -23,6 +23,9 @@ execute: |
# conflict with an existing system label
label_base=$(tests.nested exec "date '+%Y%m%d'")
+ # wait until device is initialized and has a serial
+ nested_wait_for_device_initialized_change
+
echo "Refresh model assertion to revision 2"
nested_copy "$TESTSLIB/assertions/valid-for-testing-pc-revno-2-20.model"
REMOTE_CHG_ID="$(tests.nested exec sudo snap remodel --no-wait valid-for-testing-pc-revno-2-20.model)"