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 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71
|
summary: Check that auto-refresh works
details: |
Verify the basic functionality for auto-refreshes. Check that a refresh
can be scheduled, it can be put on hold and the snap auto-refresh is
triggered and executed properly.
environment:
SNAP_NAME/regular: test-snapd-tools
SNAP_NAME/parallel: test-snapd-tools_instance
prepare: |
if [[ "$SPREAD_VARIANT" =~ parallel ]]; then
snap set system experimental.parallel-instances=true
fi
restore: |
if [[ "$SPREAD_VARIANT" =~ parallel ]]; then
snap set system experimental.parallel-instances=null
fi
debug: |
# GCE does not always NTP sync, try to figure out why here
# (LP: 1949886)
systemctl status systemd-timedated || true
journalctl -u systemd-timedated || true
timedatectl || true
execute: |
echo "Auto refresh information is shown"
output=$(snap refresh --time)
for expected in ^schedule: ^last: ^next:; do
echo "$output" | MATCH "$expected"
done
if os.query is-core; then
# no holding
echo "$output" | NOMATCH "^hold:"
else
# holding
echo "$output" | MATCH "^hold:"
fi
echo "Install a snap from stable"
snap install "$SNAP_NAME"
snap list | MATCH "$SNAP_NAME +[0-9]+\\.[0-9]+"
snap set core refresh.schedule="0:00-23:59"
# ensure there are no refresh holds, otherwise can't force auto-refresh
snap set system refresh.hold!
systemctl stop snapd.{service,socket}
echo "Modify the snap to track the edge channel"
"$TESTSTOOLS"/snapd-state change-snap-channel "$SNAP_NAME" edge
echo "And force auto-refresh to happen"
"$TESTSTOOLS"/snapd-state force-autorefresh
systemctl start snapd.{service,socket}
echo "wait for auto-refresh to happen"
"$TESTSTOOLS"/snapd-state wait-for-snap-autorefresh "$SNAP_NAME"
echo "Ensure our snap got updated"
snap list|MATCH "$SNAP_NAME +[0-9]+\\.[0-9]+\\+fake1"
echo "Ensure refresh.last is set"
gojq ".data[\"last-refresh\"]" /var/lib/snapd/state.json | MATCH "$(date +%Y)"
echo "No refresh hold at this point"
snap refresh --time | NOMATCH "^hold:"
|