Automated testing and auto-refresh

Max Brustkern max.brustkern at canonical.com
Thu Mar 23 14:06:09 UTC 2017


I'm running automated tests the involve refreshing a VM setup using the
released ubuntu-core-16 image with candidate snaps. I install core and
reboot first, since otherwise attempting to refresh a snap with no changes
exits with an error. After the reboot, auto-refresh starts. When the test
script attempts to refresh the kernel snap, we get an error:

nuclearbob at localhost:~$ sudo snap changes
ID   Status  Spawn                 Ready                 Summary
3    Error   2017-02-16T18:05:19Z  2017-02-16T18:05:49Z  Refresh all snaps
in the system
4    Done    2017-03-22T17:00:19Z  2017-03-22T17:00:37Z  Refresh "core"
snap from "candidate" channel
5    Doing   2017-03-22T17:01:34Z  -                     Auto-refresh snap
"pc-kernel"
6    Done    2017-03-22T17:01:37Z  2017-03-22T17:01:37Z  Refresh "pc" snap
from "candidate" channel

nuclearbob at localhost:~$ sudo snap refresh --candidate pc-kernel
error: cannot refresh "pc-kernel": snap "pc-kernel" has changes in progress
nuclearbob at localhost:~$ echo $?
1

This causes the test runner script to exit, as the refresh fails. However,
if I wait a bit, the auto-refresh seems to fail as well, and then if I
retry the manual refresh, it succeeds:
nuclearbob at localhost:~$ sudo snap changes
ID   Status  Spawn                 Ready                 Summary
3    Error   2017-02-16T18:05:19Z  2017-02-16T18:05:49Z  Refresh all snaps
in the system
4    Done    2017-03-22T17:00:19Z  2017-03-22T17:00:37Z  Refresh "core"
snap from "candidate" channel
5    Error   2017-03-22T17:01:34Z  2017-03-22T17:03:04Z  Auto-refresh snap
"pc-kernel"
6    Done    2017-03-22T17:01:37Z  2017-03-22T17:01:37Z  Refresh "pc" snap
from "candidate" channel

nuclearbob at localhost:~$ sudo snap refresh --candidate pc-kernel
[/] Setup snap "pc-kernel" (59) security profiles
Broadcast message from root at localhost.localdomain (Wed 2017-03-22 17:04:02
UTC):

reboot scheduled to update the system - temporarily cancel with 'sudo
shutdown -c'
The system is going down for reboot at Wed 2017-03-22 17:14:02 UTC!

pc-kernel (candidate) 4.4.0-67.88 from 'canonical' refreshed

Is the best way to handle this just grepping the output of snap changes for
"Doing" and "pc-kernel" until there's nothing listed for that, and then
retrying the refresh in case it failed before? Is there a better
programmatic way to interact with the API?

Thanks,
Max



More information about the Snapcraft mailing list