482 Commits

Author SHA1 Message Date
Michael Vogt
109639b126 Revert "tests/core20-install-device-file-install-via-hook-hack: adjust test for 2.51"
This reverts commit b3de1dc15c.
2021-08-17 18:48:36 +02:00
Michael Vogt
fccd80e8d3 Merge remote-tracking branch 'upstream/release/2.51' into update-2.52 2021-08-17 08:25:53 +02:00
Ian Johnson
b3de1dc15c tests/core20-install-device-file-install-via-hook-hack: adjust test for 2.51
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>
2021-08-16 12:15:39 -05:00
Ian Johnson
5bf1610f72 o/devicestate/handlers_install.go: add workaround to create dirs for install (#10608)
* 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-08-16 12:13:50 -05:00
Sergio Cazzolato
2e6c121050 Fix error creating snaps 2021-07-15 15:56:31 -03:00
Sergio Cazzolato
dbe80eaced Fix error when preparing the vm related to cloud init
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'
2021-07-15 14:03:19 -03:00
Sergio Cazzolato
cb985fb9ee Update core20-early-config after merge 2021-07-15 08:38:14 -03:00
Sergio Cazzolato
f8dc7a5e0a Wait for snap command after build core image 2021-07-14 21:07:58 -03:00
Sergio Cazzolato
7b5ee025b1 Fix core20-early-config test 2021-07-14 19:03:32 -03:00
Sergio Cazzolato
357e4e00bc fix shell check error 2021-07-14 17:20:11 -03:00
Sergio Cazzolato
a7657b5b10 use retry with "tests.nested exec" instead of "tests.nested retry" 2021-07-14 16:57:43 -03:00
Sergio Cazzolato
c779c7f77a Repack core to avoid auto-refresh 2021-07-14 15:33:16 -03:00
Sergio Cazzolato
0143cf29a6 Hold core refresh 2021-07-14 14:16:00 -03:00
Sergio Cazzolato
dd30c6f071 Fix how test-tools dir is created 2021-07-14 12:12:06 -03:00
Sergio Cazzolato
d59b3b8886 Merge remote-tracking branch 'upstream/master' into tests-add-nested-retry 2021-07-14 12:07:11 -03:00
Sergio Cazzolato
d4aed10485 Fix merge 2021-07-14 00:07:25 -03:00
Sergio Cazzolato
2c4521a8e3 Merge remote-tracking branch 'upstream/master' into tests-add-nested-retry 2021-07-13 23:46:21 -03:00
Ian Johnson
7fea6f86cb tests/nested/manual: fix other cloud-init test checks too
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>
2021-07-13 15:49:34 -05:00
Ian Johnson
6150b9132d tests/nested/cloud-init-{never-used,nocloud}-not-vuln: fix tests, use 2.45
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>
2021-07-13 15:44:53 -05:00
Michael Vogt
3df1298203 devicestate: add support to save timings from install mode
* 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
2021-07-13 22:41:32 +02:00
Sergio Cazzolato
5c60a91bb7 New tests.nested commands copy and wait-for
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
2021-07-12 18:12:18 -03:00
Sergio Cazzolato
d004c2cf50 reverto || true when checking "cloud-init reported" message 2021-07-12 17:53:41 -03:00
Sergio Cazzolato
e4049750fc Fix how retry command is executed on tested tests 2021-07-12 13:36:31 -03:00
Sergio Cazzolato
bb69bde2e7 Merge remote-tracking branch 'upstream/master' into tests-add-nested-retry 2021-07-12 13:07:02 -03:00
Sergio Cazzolato
ad79522656 Reverting the cloud init status check
This was removed by mistake. Reverting it
2021-07-08 16:14:22 -03:00