Commit Graph

292 Commits

Author SHA1 Message Date
Chris Peterson ecfc3a4df0 scripts: support top-level autoinstall in validator 2024-04-04 14:21:02 -07:00
Dan Bungert 12934d7b97 scripts: update for bootstrap 2024-03-28 17:20:43 -06:00
Olivier Gayot cc15d645f4
Merge pull request #1943 from ogayot/curl-timeout
tests: terminate curl processes on timeout
2024-03-19 09:59:57 +01:00
Olivier Gayot 612a8bbfc9 tests: terminate curl processes on timeout
When ensuring that the system-setup process can only be connected to
on the loopback interface, we spawn a bunch of `curl --interface ...`
processes. If the connection times out (which is the expectation in most
scenarios), the curl processes ended up not being terminated. Not only
this is small waste of resources, this is also causing errors on noble:

Exception ignored in: <function BaseSubprocessTransport.__del__ at 0x745692661300>
Traceback (most recent call last):
  File "/usr/lib/python3.12/asyncio/base_subprocess.py", line 126, in __del__
    self.close()
  File "/usr/lib/python3.12/asyncio/base_subprocess.py", line 104, in close
    proto.pipe.close()
  File "/usr/lib/python3.12/asyncio/unix_events.py", line 568, in close
    self._close(None)
  File "/usr/lib/python3.12/asyncio/unix_events.py", line 592, in _close
    self._loop.call_soon(self._call_connection_lost, exc)
  File "/usr/lib/python3.12/asyncio/base_events.py", line 793, in call_soon
    self._check_closed()
  File "/usr/lib/python3.12/asyncio/base_events.py", line 540, in _check_closed
    raise RuntimeError('Event loop is closed')
RuntimeError: Event loop is closed

Fixed by terminating the curl processes (and waiting for them to
terminate) before exiting the script.

Signed-off-by: Olivier Gayot <olivier.gayot@canonical.com>
2024-03-19 09:21:31 +01:00
Chris Peterson 11027c55d6 kvm-test: add --secure-boot option
Adds an option to configure the VM to load SecureBoot enabled firmware.
SecureBoot is a feature of UEFI, which means --boot (for legacy BIOS
boot) is incompatible with this flag. Providing both will result
in an error.

This will be useful for testing MOK enrollment behavior, as on reboot
you can confirm if you are presented with mokmanager or regular first
boot.
2024-03-15 15:16:39 -07:00
Olivier Gayot 1ae2e402b1 kvm-test: add --disk-interface option taking either "nvme" or "virtio"
The local disk that scripts/kvm-test.py creates unconditionally uses the
virtio interface. Recently in Subiquity, we did some work more closely
related to NVMe drives but kvm-test.py did not support that type of
interface.

We now add the possibility to specify the interface using the
--disk-interface option. It can only take two options:

  * --disk-interface nvme
  * --disk-interface virtio    (the default)

This should allow us to spot regressions (such as in LP: #2056730) with
more ease.

Signed-off-by: Olivier Gayot <olivier.gayot@canonical.com>
2024-03-14 10:47:05 +01:00
Dan Bungert 29b3f361d1 scripts: handle cloud-init status 2 2024-01-29 13:52:58 -07:00
Chris Peterson 5350d01715 ai: include link to docs in post-install user data
We write out the autoinstall data to make the install repeatable
but this should also include a reference to the autoinstall
documentation to increase usability.
2024-01-03 16:02:30 -08:00
Olivier Gayot afd6fca8b4 kvm-test: allow kvm-test.yaml to add/modify profiles
Signed-off-by: Olivier Gayot <olivier.gayot@canonical.com>
2023-11-12 22:02:20 +01:00
Olivier Gayot de4e126087 kvm-test: have different profiles for server and desktop
Booting Desktop and server live installer ISOs comes with different
platform requirements. When running kvm-test, we now accept the name of
a profile via the --profile option.

Profiles provide default settings for memory, disk size and extra QEMU
options. For now, two profiles are hard-coded: "server" - which is the
default and "desktop".

For desktop, we use two vCPU, 8 GiB of RAM, a 20 GiB disk and pass the
-device qxl option.

Signed-off-by: Olivier Gayot <olivier.gayot@canonical.com>
2023-11-07 14:36:07 +01:00
Chris Peterson 560b0b24d1
Merge pull request #1851 from Chris-Peterson444/update-apport-logs-FR-5444
Update apport reporting
2023-10-25 16:58:00 -07:00
Chris Peterson e3d06bce6d apt: move subiquity-curtin-apt.conf to curtin-install/ 2023-10-21 00:51:02 -07:00
Olivier Gayot b0e1c57145 snapcraft: use snapcraft pack instead of snapcraft snap
Signed-off-by: Olivier Gayot <olivier.gayot@canonical.com>
2023-10-20 15:41:24 +02:00
Olivier Gayot 01ec1da86f codecs: skip installation when running an offline install
ubuntu-restricted-addons is a multiverse package and is not included in
the pool. Therefore, trying to get it installed when offline leads to an
obvious error.

Instead of making the whole Ubuntu installation fail, we now warn and
skip installation of the package when performing an offline install.
In a perfect world, we should not have offered to install the package in
the first place, but in practice, we can run an offline installation as
the result of failed mirror testing (bad network for instance).

Signed-off-by: Olivier Gayot <olivier.gayot@canonical.com>
2023-09-29 18:20:19 +02:00
Olivier Gayot 5556313652 mirror: do not let curtin decide the URL of the security archive
When the URL of the security archive is unset, curtin will set it to the
URL of the primary archive.

This is not the behavior we want for Ubuntu installations. On amd64 (and
i386), the URL of the security archive should be set to
http://security.ubuntu.com/ubuntu

On other architectures, it should be set to
http://ports.ubuntu.com/ubuntu-ports

Signed-off-by: Olivier Gayot <olivier.gayot@canonical.com>
2023-09-08 10:25:02 +02:00
Dan Bungert 0bbec68bd9 installdeps: use confnew to workaround upgrade 2023-08-28 12:59:24 -06:00
Dan Bungert 6cd151d249 scripts: add bind-patch.sh
scripts/bind-patch.sh is useful for modifying the snap in the live
environment, for quickly testing changes or for things that are too
obscure to test in other ways.
2023-08-21 11:42:24 -06:00
Olivier Gayot 03e9a401b9
Merge pull request #1754 from ogayot/kvm-test-tpm
kvm-test: support emulating a TPM 2.0
2023-08-03 09:36:29 +02:00
Michael Hudson-Doyle 24a4d76e42 skip inappropriate checks in integration tests 2023-08-03 10:02:36 +12:00
Olivier Gayot 5244890c5a kvm-test: support emulating a TPM 2.0
When invoking kvm-test.py, one can pass the --with-tpm2 option so that
we emulate a TPM and make it available in the guest.

This requires the swtpm package which is available in jammy and more
recent versions of Ubuntu.

Signed-off-by: Olivier Gayot <olivier.gayot@canonical.com>
2023-08-02 16:58:25 +02:00
Michael Hudson-Doyle a9828edbb5
Merge pull request #1736 from mwhudson/dump-crash-files-in-ci
runtests.sh: dump crash files to stdout in CI
2023-07-21 12:07:49 +12:00
Michael Hudson-Doyle f08830cd71 fix autoinstalling core boot classic and add integration and unit tests 2023-07-21 11:39:50 +12:00
Michael Hudson-Doyle cab3f072cd runtests.sh: dump crash files to stdout in CI 2023-07-21 11:37:36 +12:00
Michael Hudson-Doyle 55c68b5855 add an integration test to install core and some fixes
Note that it may not be possible to create an fsimage to use as a core
installation source (haven't tried, tbh) but I have upcoming changes to
use a disk image as installation source.
2023-07-19 15:49:32 +12:00
Dan Bungert 872f5cd25b
Merge pull request #1721 from dbungert/runtests-fix-reset-only
runtests: fix "unary operator expected" warning
2023-07-17 10:56:25 -06:00
Dan Bungert 832750297d runtests: fix "unary operator expected" warning 2023-07-17 10:00:55 -06:00
Michael Hudson-Doyle 2c75df0ddf remove now-redundant parts of the file names in examples/ 2023-07-11 22:46:19 +12:00
Michael Hudson-Doyle 6b35e5e4a1 tidy up examples/ directory
Move machine configs, sources, autoinstall files and dry-run configs
into their own subdirectories.
2023-07-11 12:49:22 +12:00
Michael Hudson-Doyle 64ad6514a3 suggestion from review 2023-06-30 16:43:01 +12:00
Michael Hudson-Doyle 283e07a615 add integration test for reset-partition-only
This requires some tweaks to make the test machinery accept an
autoinstall that doesn't do most of the things we usually expect.  Also
set the .target attribute to None when reset-partition-only is true to
catch more issues in the dry-run environment.
2023-06-28 12:21:09 +12:00
Olivier Gayot e56053f2bb ubuntu-drivers: add support for umockdev in dry-run
When running subiquity in dry-run mode with SUBIQUITY_DEBUG=run-drivers,
we now support using a YAML file describing the hardware in a
umockdev-compatible way. This allows to give some control on what
ubuntu-drivers list will reply.

Signed-off-by: Olivier Gayot <olivier.gayot@canonical.com>
2023-06-15 09:37:02 +02:00
Olivier Gayot 3d1ea39e20 scripts: add script to run mypy and compare with output in another revision
The script can be invoked in different ways:

Run mypy in the current working directory and display the output:

 $ scripts/run-mypy.py

Run mypy in a clean copy of the HEAD revision:

 $ scripts/run-mypy.py --checkout-head

Run mypy in the current working directory and compare the result with
another revision (here main):

 $ scripts/run-mypy.py --diff-against main

Run mypy in a clean copy of the HEAD revision and compare with another
revision (here main):

 $ scripts/run-mypy.py --diff-against main --checkout-head

The produced result might be slightly different from what the CI does
because it also clones checks out curtin and probert (at the right
revision). This is something we might want to do in the CI as well.

Signed-off-by: Olivier Gayot <olivier.gayot@canonical.com>
2023-06-01 09:24:05 +02:00
Dan Bungert b72a5397fb scripts: update slimy to handle u-d-i
If the target snap is ubuntu-desktop-installer, put subiquity changes in
the appropriate location.
2023-04-11 14:10:49 -06:00
Olivier Gayot 9b18f45700 snapcraft: upgrade to core22
Signed-off-by: Olivier Gayot <olivier.gayot@canonical.com>
2023-03-16 12:21:44 +01:00
Olivier Gayot 11f66b9129
Merge pull request #1565 from ogayot/debconf-selections-in-apt-config
debconf-selections: pass to curtin's apt-config rather than curthooks
2023-03-01 13:01:45 +01:00
Olivier Gayot f55d3a6056 Revert "Enable tracemalloc in integration tests with at most 3 frames"
This reverts commit 813448683c.
2023-02-24 19:53:57 +01:00
Olivier Gayot 75f6047a6f mirror: in CI, do not run apt-get update on the host
Signed-off-by: Olivier Gayot <olivier.gayot@canonical.com>
2023-02-23 18:12:24 +01:00
Olivier Gayot 03f41c2f60 debconf-selections: pass to curtin's apt-config rather than curthooks
We got multiple bug reports in the past stating that the installer is
not honoring some part of the apt settings; either supplied by means of
autoinstall (e.g., pinning) or via the subiquity UI (e.g., proxy).

What happens under the hood is that curtin overwrites the APT settings
as part of the curthooks stage ; effectively discarding earlier settings
applied in the apt-config stage.

Curtin does so because we pass debconf_selections directives to
curthooks. In the past, curtin used to handle debconf_selections
separately but nowadays it considers that they are part of the APT
config. As a result, it decides to run apt-config again (but with a
close to empty configuration) as part of the curthooks stage.

We now pass debconf_selections as part of the apt-config stage. This
should hint curtin not to run apt-config again as part of curthooks.

Signed-off-by: Olivier Gayot <olivier.gayot@canonical.com>
2023-02-16 12:08:40 +01:00
Dan Bungert cb9c2263e7 runtests: allow longer socket wakeup 2023-02-06 16:39:06 -07:00
Dan Bungert 6f6178c601 requirements: remove
Get em from apt
2023-02-06 16:13:22 -07:00
Olivier Gayot 93f06eeb0f dry-run: add configuration object to control dry-run behavior
Oftentimes, we want to simulate a specific behavior of the application
when running in dry-run mode. To do so, we use either command line
parameters or environment variables.

This patch introduces a configuration object for dry-run executions
only. The object can be automatically loaded from a JSON file specified
via the --dry-run-config CLI argument.

Such a configuration object should help us cover way more test cases.
Going forward, I would like to use this object for things like:

 * drivers - to instruct Subiquity what third-party drivers it should
   suggest ; or if Subiquity should run ubuntu-drivers on the host
   instead.
 * ubuntu-pro - to specify the ua-contracts test environment URL - or
   predefined automatic replies for the server
 * to assume that /var/lib/snapd/seed/systems directory exists on the
   source (or not).
 * to specify the Ubuntu release that is returned by lsb_release ; can
   be used to test behavior on LTS vs non LTS releases.
 *
 * ...

Signed-off-by: Olivier Gayot <olivier.gayot@canonical.com>
2022-11-25 15:49:01 +01:00
Michael Hudson-Doyle 5971541beb use @ogayot's better bash
Co-authored-by: Olivier Gayot <olivier.gayot@sigexec.com>
2022-11-11 14:46:46 +13:00
Michael Hudson-Doyle 5dafdb916d call into snapd to set up encryption when required 2022-11-11 14:46:44 +13:00
Michael Hudson-Doyle cf80463e5b do partitioning based on information from gadget 2022-11-04 11:57:17 +01:00
Michael Hudson-Doyle 27953f794d fix integration test 2022-11-01 15:59:06 +01:00
Michael Hudson-Doyle 8b47359ef2 update filesystem model object paths after curtin runs 2022-10-05 16:52:10 +13:00
Olivier Gayot d5182af065
Merge pull request #1421 from ogayot/kvm-test-cloud-config
kvm-test: allow to specify a cloud-init file not meant for autoinstall
2022-09-29 14:31:47 +02:00
Dan Bungert 2928ab88ce runtests: ensure message shown at end
The second `trap ... EXIT` registration meant that the first one, the
one repsonsible for providing a clear PASS / FAIL at the end, was not
being shown.
2022-09-28 10:02:04 -06:00
Olivier Gayot 62a2f3104c kvm-test: allow to specify a cloud-init file not meant for autoinstall
The --cloud-config option now replaces the old --autoinstall-file
option.

The use of --autoinstall-file always made kvm-test pass the autoinstall
argument to the kernel command line. With the --cloud-config option, we
now determine if the autoinstall argument is needed by reading the cloud
config and checking if an autoinstall section is present.

The two new options --force-autoinstall and --force-no-autoinstall can
be used to override this behaviour.

The --autoinstall option is also dropped. If we want to use the default,
hardcoded cloud-config, one can use --cloud-config-default.

This can be useful to ease debugging of the VM using a config that looks
like:

    #cloud-config
    users:
        - default
        - name: root
          ssh_import_id: lp:ogayot

Signed-off-by: Olivier Gayot <olivier.gayot@canonical.com>
2022-09-22 13:09:59 +02:00
Dan Bungert b9f75059be scripts: add yaml-normalize.py 2022-08-29 13:54:51 -06:00