We do not yet have tests.nested on release/2.51, so revert this test for that
branch to use the old commands.
Signed-off-by: Ian Johnson <ian.johnson@canonical.com>
* tests/lib/store.sh: allow adding extra bits to snap-declaration via opts
This is needed in order to customize the snap-declaration with i.e. plugs or
slots or other special things granted through the snap-declaration assertion to
the snap.
Signed-off-by: Ian Johnson <ian.johnson@canonical.com>
* tests/lib/nested.sh: add NESTED_FAKESTORE_SNAP_DECL_PC_GADGET env var
This is used add special extra custom snap-declaration bits to the declaration
for tests which use the fakestore but need extra permissions to do things in
hooks or services for the gadget snap.
Signed-off-by: Ian Johnson <ian.johnson@canonical.com>
* o/devicestate/handlers_install.go: add workaround to create dirs for install
For UC20 install mode, we have devices which need to install files into the run
mode system before rebooting into install mode. The temporary solution designed
for this was to use the install-device hook with system-files providing write
access to the /run/mnt/ubuntu-data/system-data/_writable_defaults/... directory
where ubuntu-data is mounted during install mode. That seemed to work fine in
devmode, but the issue in strict mode is that system-files only grants
permissions to create that specific file, it doesn't grant permission to create
any of the parent directories the file lives in.
So, temporarily for this device to be released and shipped, create those
directories at the end of the setup-run-system task, which runs before the
install-device hook, thus ensuring that the hook is successful.
Also add a spread test for this situation.
Signed-off-by: Ian Johnson <ian.johnson@canonical.com>
* tests/core20-install-device-file-install-via-hook-hack: also check dir perms
As suggested by Samuele, also check the permissions of the directories that we
are creating here.
Signed-off-by: Ian Johnson <ian.johnson@canonical.com>
2021-07-15T15:56:05.7126628Z + nested_exec 'cloud-init status --wait'
2021-07-15T15:56:05.7128190Z + sshpass -p ubuntu ssh -p 8022 -o
ConnectTimeout=10 -o UserKnownHostsFile=/dev/null -o
StrictHostKeyChecking=no user1@localhost 'cloud-init status --wait'
2021-07-15T15:56:05.7129863Z Warning: Permanently added
'[localhost]:8022' (ECDSA) to the list of known hosts.
2021-07-15T15:56:05.7130784Z ...Traceback (most recent call last):
2021-07-15T15:56:05.7131722Z File "/usr/bin/cloud-init", line 11, in
<module>
2021-07-15T15:56:05.7132688Z load_entry_point('cloud-init==21.2',
'console_scripts', 'cloud-init')()
2021-07-15T15:56:05.7133815Z File
"/usr/lib/python3/dist-packages/cloudinit/cmd/main.py", line 890, in
main
2021-07-15T15:56:05.7134522Z retval = util.log_time(
2021-07-15T15:56:05.7135483Z File
"/usr/lib/python3/dist-packages/cloudinit/util.py", line 2348, in
log_time
2021-07-15T15:56:05.7136208Z ret = func(*args, **kwargs)
2021-07-15T15:56:05.7137399Z File
"/usr/lib/python3/dist-packages/cloudinit/cmd/status.py", line 60, in
handle_status_args
2021-07-15T15:56:05.7138405Z status, status_detail, time =
_get_status_details(init.paths)
2021-07-15T15:56:05.7139692Z File
"/usr/lib/python3/dist-packages/cloudinit/cmd/status.py", line 123, in
_get_status_details
2021-07-15T15:56:05.7140784Z status_v1 =
load_json(load_file(status_file)).get('v1', {})
2021-07-15T15:56:05.7141944Z File
"/usr/lib/python3/dist-packages/cloudinit/util.py", line 1311, in
load_file
2021-07-15T15:56:05.7142911Z with open(fname, 'rb') as ifh:
2021-07-15T15:56:05.7143952Z FileNotFoundError: [Errno 2] No such file
or directory: '/run/cloud-init/status.json'
These tests suffered from the same problem as the tests for the cloud-init
vulnerability, so fix them too.
Signed-off-by: Ian Johnson <ian.johnson@canonical.com>
Use snapd 2.45 as the baseline snapd version in the image that we build for the
refresh case, since this test variant is about old devices that were built
before the fix was merged.
Additionally, fix the environment variables which were subtly wrong (missing
the _SNAPD_), and also replace the nested_is_core_16_system with the equivalent
os.query call.
Finally, fix the cloud-init journal check to actually fail if we don't see the
message after 60 seconds, and check for the right message (which is lower-case)
Signed-off-by: Ian Johnson <ian.johnson@canonical.com>
* devicestate: add support to save timings from install mode
Using a quick and not super nice way to store debug timings of
the install to the ubuntu-data partition.
* devicestate: rework timing log writing (thanks to Samuele)
* devicestate: rework because we can not call into snapd when snapd tries to reboot
* devicestate: improve unit test
* devicestate: snap debug timings --ensure=seed needs to run on its own
* devicestate: write the logs *after* the timings so that any failure from the timing writing is captured
* devicestate: fix comment
* tests: remove silly debug output
* tests: test install-timings.txt.gz more
* devicestate: add extra \n after each debug change output
* devicestate: move state unlock into writeTimings() and skip the "seed" change, we get the info via "snap debug timings --ensure=seed"
* devicestate: add clear information what is happening in writeTimings (thanks to Maciej)
* devicestate: update test to latest code changes
* tests: remove stray newline
This are the second part of the commands for the tests.nested tool
The new commands are:
copy: copies a file to the vm
wait-for: waits for an specified event (ssh. no-ssh,
snap-command and reboot)
Tests have been updated as well