873 Commits

Author SHA1 Message Date
Andrew Phelps
1af45be1ab tests: fix recovery-system-reboot install test that was being interrupted by a system reboot (#13736)
* tests/nested/manual/recovery-system-reboot: fix test that was being interrupted by a system reboot

In the case of an auto-refresh, the system would reboot. This resulted
in some cryptic failures. Make sure to wait for an auto-refresh to
happen before removing the recovery system, and make sure to wait for
the system to reboot once the auto-refresh has finished.

* tests/nested/manual/recovery-system-reboot: add an extra wait to continue waiting after reboot
2024-03-21 22:23:27 +02:00
Ernest Lotter
7058be67b5 tests: use snapcraft and lxd with latest fixes where possible (#13724)
* spread.yaml: use lxd edge with shmounts fix

* tests: use snapcraft edge with fix to handle lxd version naming change

* tests: use lxd 5.20/stable with snapcraft 4.x that cannot handle lxd version naming change

* tests: added details for nested/manual/devmode-snaps-can-run-other-snaps
2024-03-18 15:07:36 +02:00
Alfonso Sánchez-Beato
2e61edfb3b tests/nested/manual/fde-on-classic: wait for abort
snap abort does not wait until the change is finally aborted, which
caused some false positive test failures.
2024-03-14 13:12:54 +00:00
Valentin David
0315809c3e tests: add test to check update of boot chain 2024-03-13 12:41:32 +01:00
Andrew Phelps
c57901e705 many: add API routes for creating/removing recovery systems (#13651)
* o/assertstate, o/devicestate: add more general function for fetching validation set assertions

* daemon, client: add API routes for creating/removing recovery system

* daemon, o/snapstate: add .snap file extension to snaps from forms

The seed writer will fail to consider files as snaps if their filenames
do not end in .snap.

* tests: test creating a recovery system

* tests: add spread test for offline creation of recovery system

* tests: update offline recovery system test to reboot into new system

* tests/nested/manual/recovery-system-reboot: add variants for factory-reset and install modes

* tests: replace usage of default-recovery-system with default-recovery

* o/devicestate: enable offline creation of recovery system entirely from pre-installed snaps

* daemon, client: test that offline API works without providing snaps or validation sets

* tests/nested/manual/recovery-system-offline: test offline remodel with only pre-installed snaps

* tests/nested/manual/recovery-system-reboot: modify test to create system with new set of essential snaps

* tests: disable shellcheck printf check

* daemon: rename functions for working with form values and add one for working with booleans

* daemon: acquire state lock later in postSystemActionCreateOffline

* daemon: cleanup form files if we fail to make change to create a recovery system

* daemon: rename parseValidationSets to assertionsFromValidationSetStrings for clarity

* client, daemon, tests: add "offline" field to create recovery system JSON api

* daemon: convert TODO about comma-delimited list into explanation of why we use a comma delimited list

* NEWS.md: add mention of create/remove recovery systems API

* tests/nested/manual/recovery-system-offline: explicitly disable network from nested vm

* tests/nested/manual/recovery-system-reboot: do not use new gadget in recovery system for now

* tests/lib/nested.sh: add variable NESTED_FORCE_MS_KEYS to force using microsoft keys

* tests/nested/manual/recovery-system-reboot: add back gadget snap swap to test

* tests/nested/manual/recovery-system-reboot: retry POST to remove since there might be an auto-refresh happening
2024-03-10 22:35:04 +02:00
Sergio Cazzolato
8996c3602b tests: allow running edge/beta validation in google instances (#13639)
* new full-run test

* update tests to support pre-built images

* Squashed 'tests/lib/external/snapd-testing-tools/' changes from 1c8efb77e1..74082c0c34

74082c0c34 Tests improve remote wait (#49)
5121bfb659 remove support for opensuse leap 15.4 (#48)
30df700d08 Add new systems support (#47)
1f08938925 Support check amazon linux version (#46)
43533bdd97 Change the exit value checking for test formats (#45)
3c88244c04 Update check-test-format to support a dir and a list of files (#44)
510d95f429 add extra check for error in auto-refresh detection function
3289d4031b Try open the log with latin-1 encoding when utf-8 is not working
9db785499f improved how the tools are waiting for system reboot
2a5c4414a3 fix shellcheck errors
5e7b63883d Fixes for osquery and tests pkgs (#43)
4c9145e2ac support reboot waiting for auto-refresh
45768f5188 show changes in unknown status after refresh
8013c30c2a Remove support for ubuntu 22.10
b32b80bf54 Fix remote.rait-for test in bionic
5675c625e9 Enable fedora 38
55f4471957 Support for new oss
f2e88b357c New tool used to query spread json reports
cacd35ede0 utils/spread-shellcheck: explain disabled warnings (#42)
c82afb2dee Support --no-install-recommends parameter when installing dependencies with tests.pkgs
b84eea92e2 spread-shellcheck: fix quotes in environment variables (#41)
ab1e51c29f New comparison in os-query for core systems (#40)
e5ae22a5d4 systemd units can be overwritten
63540b845a Fix error messages in remote pull and push
75e8a426a5 make sure the unit is removed in tests.systemd test
9089ff5c02 Update tests to use the new tests.systemd stop-unit
44ecd5e56a Move tests.systemd stop-units to stop-unit
01a2a83b4b Update tests.systemd to have stop units as systemd.sh
162e93bd35 update tests.systemd CLI options to be the same than retry command
14aa43a405 new feature to re-run failed spread tests (#39)
604cb782db Fix shellcheck in systemd tool
bfc71082c8 Update the tests.systemd to allow parameters waiting for service status
8a2d0a99df Adding quiet tool and removing set +-x from tests.pkgs
d90935d2a4 A comment explaining about the default values for wait-for
3232c5dba7 Add support for ubuntu 23.04
a7164fba07 remove fedora 35 support, add fedora 37 support
89b9eb5301 Update systems supported
92bb6a0664 Include snap-sufix in the snaps.name tool

git-subtree-dir: tests/lib/external/snapd-testing-tools
git-subtree-split: 74082c0c345a7707ca360d2177a23ee958c880bd

* Squashed 'tests/lib/external/snapd-testing-tools/' changes from 74082c0c34..5ef5dcbe8f

5ef5dcbe8f Tests use artifacts in spread tests (#51)

git-subtree-dir: tests/lib/external/snapd-testing-tools
git-subtree-split: 5ef5dcbe8f376e3958019fffcd54fd6add8117a4

* update args order in new test

* Squashed 'tests/lib/external/snapd-testing-tools/' changes from 5ef5dcbe8f..b89b4f8647

b89b4f8647 fix artifacts name
d30cee6da0 Merge remote-tracking branch 'upstream/main'
555c43d2ab Support auto-refresh with Do instead of Doing
96c2b0c19c remove tests support for ubuntu 23.04 (EoL)

git-subtree-dir: tests/lib/external/snapd-testing-tools
git-subtree-split: b89b4f86471b76eae9d5ac1b1f55728598da544e

* improbe checks in nested.sh

* Squashed 'tests/lib/external/snapd-testing-tools/' changes from b89b4f8647..4cf8e635bf

4cf8e635bf fix os.query test after merge

git-subtree-dir: tests/lib/external/snapd-testing-tools
git-subtree-split: 4cf8e635bf65f974dbcc5b303f890ac9078ed78a

* removing duplicated debian-11

* remove another merge error

* Squashed 'tests/lib/external/snapd-testing-tools/' changes from 4cf8e635bf..3a0fc57e1e

3a0fc57e1e add explanation about why we check for ( Do | Doing )

git-subtree-dir: tests/lib/external/snapd-testing-tools
git-subtree-split: 3a0fc57e1eaf13b189a83982835cf289b3dfad3c

* Squashed 'tests/lib/external/snapd-testing-tools/' changes from 3a0fc57e1e..2e4a3153a2

2e4a3153a2 1 more comment

git-subtree-dir: tests/lib/external/snapd-testing-tools
git-subtree-split: 2e4a3153a27529092156fbe723cdfef221467bd4

* increase limit waiting for log changes because check to ntp server breaks

* increase time to wait for log changes

* wait more time waiting for changes in the log

It gets stuck more than 60 seconds waiting for ntp sync
2024-02-29 15:09:56 +02:00
Andrew Phelps
8c247eaf5a overlord, o/devicestate: support remodeling on hybrid models (#13464)
* o/snapstatetest, o/devicestate, overlord: add param to InstallSnap and InstallEssentialSnaps for setting up gadget files

* o/devicestate: allow remodeling on hybrid models

When remodeling on a hybrid model, check to make sure that we have a
seed partition before creating a new recovery system as a part of the
remodel. Creating the new system is skipped if we don't see a seed
partition.

* tests/nested/manual/hybrid-remodel: new test for remodeling on a hybrid model

* o/snapstate/snapstatetest: forward gadget files to InstallSnap for gadget

* o/devicestate: add check for if the system is core-boot in undoCreateRecoverySystem

* gadget: add Info.HasRole method that checks for a role in an Info struct

* o/devicestate: replace manual role lookup with gadget.Info.HasRole incovation

* tests/nested/manual/hybrid-remodel: add TODO about testing system seeds on hybrid systems

* tests/nested/manual/hybrid-remodel: properly wait for reboot

* tests/nested/manual/hybrid-remodel: use change_id to make assertions more specific

* o/devicestate: do not attempt to finalize seed install when there is no seed partition

* tests: put muinstaller use into script for use in multiple tests

* o/devicestate: add comment explaining reason for explicitly checking classic systems

* tests: rename muinstaller.sh to setup_nested_hybrid_system.sh to clarify functionality

* tests/lib/tools/setup_nested_hybrid_system.sh: tell shellcheck where to find sourced files

* tests/lib/tools: rename --fake-disk to --disk in setup_nested_hybrid_system.sh

* tests/nested/manual/muinstaller-real: fix missing usage of $label variable in setup_nested_hybrid_system.sh

* tests/nested/manual/muinstaller-real: fix check for pre-existing gpt partition

* tests/nested/manual/muinstaller-real: use proper quoting on path with escaped chars
2024-02-22 07:47:52 +01:00
Andrew Phelps
1f3bab14bd tests/nested/manual/remodel-offline: fix misspelling 2024-02-15 15:54:06 +01:00
Andrew Phelps
4e8c178bfc tests/nested/manual/remodel-offline: test that offline remodeling will use previously installed revision of snap 2024-02-15 15:54:06 +01:00
Andrew Phelps
a4569125b1 tests/nested/manual/muinstaller-core: do not re-label seed for muinstaller
We don't need to do this any more, as muinstaller does not need it.
Additionally, this was preventing us from booting into the installed
recovery system, as some files (grubenv) that are part of the seed
reference the seed's label, but they were not updated.
2024-02-15 15:36:19 +01:00
Alfonso Sánchez-Beato
36f1c61477 tests/nested/manual/remodel-offline: wait for kernel refresh change
Wait for the kernel change to be fully done before proceeding,
otherwise we can have a race condition and remodel will fail with
message:

error: cannot do offline remodel: cannot remodel device: snap
"pc-kernel" has "refresh-snap" change in progress
2024-02-15 15:28:31 +01:00
alfonsosanchezbeato
68d402519f o/devicestate: copy seed on finish install API call, for UC (#13296)
Copy the seed on Ubuntu Core installations.

* tests/muinstaller: do not copy seed anymore

This job is done by snapd now.

* o/devicestate: update installer API to use seed.Copy interface rather than a manual copy

* tests/nested/manual/muinstaller-core: update test to check for properly installed seed after installation

* o/devicestate: use temporary db when loading assertions

* o/devicestate: refactor to only open seed once in doInstallFinish

* o/devicestate: consider seed not implementing seed.Copier as an internal error

* o/devicestate: use timings.Measurer from task

* o/devicestate: pack return values from loadSystemAndEssentialSnaps into systemAndEssentialSnaps struct

* o/devicestate: convert loadSystemAndEssentialSnaps return parameter into a pointer

* o/devicestate: add TODO about optionally returning seed from loadSystemAndEssentialSnaps

---------

Co-authored-by: Andrew Phelps <andrew.phelps@canonical.com>
2024-02-12 20:02:25 +01:00
Andrew Phelps
ee19396bce tests/nested/manual/remodel-validation-sets-invalid: update error string 2024-02-08 15:34:34 +01:00
Andrew Phelps
c2fa898925 c/snap-bootstrap: lift requirement of fde-setup hook for single-boot install (#13525)
* c/snap-bootstrap: lift requirement for fde-setup hook for single-boot-install

* tests/nested/manual/uc20-install-in-initrd: test various systems that support single-boot install

* c/snap-bootstrap: add test for single-boot install without a fde-setup hook

* tests/nested/manual/uc20-install-in-initrd: use "not" rather than "!" in spread test
2024-02-06 15:39:43 +01:00
Andrew Phelps
935b84f5f0 client, cmd/snap, daemon: api level changes for introducing offline flag to remodel (#13507)
* daemon: add offline field to remodeling JSON payload

* client, cmd/snap: add offline boolean option for remodeling to client and cli interface

* daemon: make snap files optional in the "multipart/form-data" remodel api

* tests/nested/manual/remodel-offline: add variants to test different combinations of installed/local snaps/assertions

* client: update comment on RemodelWithLocalSnaps to mention not contacting the store

* c/snap: remove unneeded var declaration

* tests/nested/manual/remodel-offline: clarify section that acks/adds the validation set assertion

* tests/nested/manual/remodel-offline: fix shellcheck warning on test's -a flag

* client: verify that normal (online) remodel does not set offline field in JSON payload
2024-02-02 11:41:55 +02:00
Sergio Cazzolato
7baa3cac6f tests: use load generator to generate load in perf tests (#13417)
* tests: use load generator to generate load in perf tests

Also it is included a new test to check snap connections for snap
provided interfaces and another to check many installations in parallel.

* fix shellchecks

* fix misspelling

* update parallel install numbers

* Target the perf tests for ubuntu core >=18
2024-01-03 05:31:01 +02:00
Valentin David
7cb5ea59d9 tests/nested/manual/uc20-install-in-initrd: remove core-initrd tweaks
Before changes in core-initrd for install in initrd feature were
merged, we needed to tweak it in the test. Now we can remove those
tweaks.
2023-12-15 10:17:37 +01:00
Andrew Phelps
154d46b46c many: take into account validation sets during remodel (#13243)
This PR makes remodels take into account revision constraints from validation sets on the new model. Additionally, snaps that are marked as invalid in validation sets are checked for in the model.

* a/snapasserts: add methods for extracting more information out of ValidationSets type

* o/assertstate: add ValidationSetsFromModel function for extracting a snapasserts.ValidationSets from an asserts.Model

* o/snapstate: prevent installing/updating a snap from a local file that does not match requested revision

* o/devicestate: consider validation sets during remodeling

* tests/nested/manual: add remodel test that downgrades a snap because of a validation set

* tests/nested/manual: add remodel test that fails to remodel because of an invalid snap in a validation set

* tests/nested/manual: extend offline remodel test to also include a validation set

* tests/lib/assertions: fix timestamps on assertions

* asserts: add Key method to ValidationSet and ModelValidationSet

* o/devicestate: use new Key methods

* o/devicestate: maybe enforce validation sets during doSetModel

* o/devicestate: add test for enforcing validation sets in doSetModel

* a/snapasserts: simplify TestCanBePresent with loop

* tests/lib/assertions: add bluez snap to offline remodel test

* o/devicestate: remove done TODO

* o/snapstate: if remodeling, do not install prereq if link-snap task is present

* tests/nested/manual/remodel-offline: extend test to verify that validation sets are accounted for

* Revert "o/snapstate: if remodeling, do not install prereq if link-snap task is present"

This reverts commit 57c7725a2513df51be7ac1c06c492aaed07a6e3b.

This change is independent and will be included in another PR.

* a/snapasserts: add methods for extracting more information out of ValidationSets type

* o/assertstate: add ValidationSetsFromModel function for extracting a snapasserts.ValidationSets from an asserts.Model

* o/devicestate: add test for ValidationSetsConflictError.Is

* a/snapasserts: move methods after New function

* a/snapasserts: add test for ValidationSets.Revisions to verify ValidationSetsConflictError is returned

* o/assertstate: change ValidationSetsFromModel to take in a DeviceContext, rather than a StoreService

* o/assertstate: rename ValidationSetsModelFlags to ValidationSetsModelOptions

* o/devicestate: add type to export_test to make testing simpler

* tests: add details to new spread tests

* asserts: rename ModelValidationSet.Key and ValidationSet.Key to .SequenceName and add unit tests for them

* o/snapstate: update snap revision mismatch error message to be more clear

* o/devicestate: introduce helper for setting ValidationSets on snapstate.RevisionOptions if Revision is set

* o/devicestate: verify the parameters that fakeSequenceStore receives

* o/devicestate: fix revisions not being respected for essential snaps (and add a test for it)

* o/devicestate: extend TestRemodelUC20EssentialSnapsAlreadyInstalledAndLocal to also exercise case where a validation set requires a revision but the currently installed version is unasserted

* s/seedtest: update retrieveSeq to handle unconstrained sequence forming assertions

* a/snapasserts: add ValidationSets.Sets method

* o/assertstate: add deviceContext to ForgetValidationSet function so that change can happen during remodel

* o/devicestate: attempt to handle rollback of validation sets during failed remodel

* overlord: test for replacing conflicting validation sets during remodel

* o/assertstate: update ForgetValidationSet to take in a DeviceContext and to allow for forcing removal even if the validation set is in use by the model

* o/devicestate: roll back validation set changes on remodel failure

* o/devicestate: make sure that validation sets unrelated to the model survive a remodel

* o/devicestate: rename param in installedSnapRevisionChanged

* o/devicestate: rename field newSnapRevision to newRequiredRevision in modelSnapsForRemodel

* o/devicestate: simplify loops in checkForInvalidSnapsInModel

* o/devicestate: compare validation sets using SequenceName methods

* o/devicestate: fail remodel if we attempt to use an unasserted snap as a specific revision

* tests/nested/manual/remodel-offline: fix test to actually use validation set

* o/devicestate: create helper for creating snapstate.RevisionOptions during remodel

* o/devicestate: name param literals for clarity

* o/devicestate: invert logic to eliminate double negative

* o/devicestate: fix missed inversion of logic

* o/assertstate: update comment on ForgetValidationSetOpts.ForceForget

* overlord, o/devicestate: update remodel test to change models that contain the same validation set

* o/assertstate: test ForceForget functionality in ForgetValidationSet

* o/devicestate: rename function newRevisionOptionsForRemodel to revisionOptionsForRemodel

* o/assertstate, o/devicestate, daemon: remove unneeded DeviceContext param from ForgetValidationSet

* o/devicestate: remove println

* o/devicestate: clarify comment in rollback of adding validation sets

* o/devicestate: rename variable in enforceValidationSetsForRemodel

* o/snapstate: clarify error when attempting to install/refresh local snap with different revision than requested

* o/devicestate: naming consistency

* o/devicestate: simplify error when model is missing snap that is required in validation set

* asserts, overlord, o/devicestate: rename SequenceName to SequenceKey and prefix the series to the string that is returned
2023-12-12 10:00:48 +01:00
Sergio Cazzolato
4343fc8bb9 tests: revert the skip for change in nested test core20-to-core22 (#11923)
* Revert the skip for change in nested test core20-to-core22

* update test details
2023-12-07 20:13:42 +02:00
Sergio Cazzolato
51521365b6 tests: add new performance and load test suite (#13371)
* tests: add new performance and load test suite

This is the initial change to support performance tests.

These new tests have to be able to run either in nested vms and in
external devices.
The idea is to run nightly and on demand on nested vms and also as part
of regular runs on specific devices.

The initial test is about connecting and disconnecting interfaces,
covering a specific percentage of those and also test how the system
behaves when all are connected together.

* fix shellcheck

* fix minimal-smoke test

* add details to minimal-smoke test

* use ubuntu-image snap in xenial
2023-12-06 20:06:50 +02:00
Valentin David
f452754699 test/nested/manual: fix some yq expressions (#13407) 2023-12-06 16:12:52 +02:00
Andrew Phelps
b7383cf2d3 o/snapstate, o/devicestate: fix ordering of installation of snaps during remodel (#13358) 2023-11-29 18:08:15 -05:00
Sergio Cazzolato
cd060bd4d8 tests: fix core20-to-core22 test (#13255)
The command has a typo which is fixed
2023-11-15 19:20:59 +02:00
Valentin David
1786bc076f tests: add spread test for append/remove cmdline from gadget.yaml 2023-10-26 09:34:20 +02:00
Alfonso Sánchez-Beato
4c84ca4533 tests/kernel-revert-after-boot: modify installed kernel
Modify installed kernel instead of downloading it, this will speed up
the tests. Also, we cannot use pc-kernel from the edge channel anymore
as it is not signed now with Canonical keys.
2023-10-17 10:05:50 +01:00