1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43
|
summary: Ensure `snap debug changes|tasks|task` commands work
details: |
The command `snap debug state` should report change state from a given
"state.json" file. It should be able to list changes, show changes,
tasks. It should be able to provide a Graphviz output. This test
verifies the command line for all these operations.
prepare: |
snap install hello-world
# The debug commands access state.json directly, snapd should be stopped
systemctl stop snapd.{socket,service}
if [[ "$SPREAD_SYSTEM" == ubuntu-1* ]]; then
apt install -y graphviz
fi
restore: |
systemctl start snapd.{socket,service}
execute: |
echo "Changes can be listed"
snap debug state --changes /var/lib/snapd/state.json | MATCH "seed .*Initialize system state"
snap debug state /var/lib/snapd/state.json | MATCH "seed .*Initialize system state"
echo "Snap changes defaults to state.json in the current directory"
cd /var/lib/snapd
snap debug state --changes | MATCH "install-snap .*Install \"hello-world\" snap"
echo "Tasks can be listed"
snap debug state --change=1 /var/lib/snapd/state.json | MATCH "mark-seeded .*Mark system seeded"
# find the id of mark-seeded task
TASK_ID=$(snap debug state --change=1 /var/lib/snapd/state.json | grep "mark-seeded" | awk '{print $2}')
echo "Individual task can be examined"
snap debug state --task="$TASK_ID" /var/lib/snapd/state.json | MATCH "kind: mark-seeded"
snap debug state --task="$TASK_ID" /var/lib/snapd/state.json | MATCH "summary: Mark system seeded"
# precondition check, dot shouldn't fail
if [[ "$SPREAD_SYSTEM" == ubuntu-1* ]]; then
snap debug state --change=1 --dot /var/lib/snapd/state.json | dot -Tpng > out.png
fi
|