Commit Graph

266 Commits

Author SHA1 Message Date
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
Dan Bungert 58ab8c5e12 runtests: use trap to ensure backgroun proc killed 2022-08-26 10:52:05 -06:00
Olivier Gayot d182b3bd69 integration: speed up check for listening interfaces in system_setup
Signed-off-by: Olivier Gayot <olivier.gayot@canonical.com>
2022-08-23 18:38:33 +02:00
Olivier Gayot 324ff0bc8f Merge pull request #1372 from ogayot/FR-2475
install: invoke curtin multiple times with different stages
2022-08-11 11:11:51 +02:00
Olivier Gayot 4c70b78fba install: invoke curtin multiple times with different stages
We now invoke curtin install in a step-by-step mode. Before, we would
perform a single invocation of curtin install for the following stages:

 * early (but no early_commands configured)
 * partitioning
 * extract
 * curthooks
 * hook
 * late (but no late_commands configured)

We now run multiple invocations of curtin install, in 5 different steps:

 * initial: does not run any stage per se but prepares curtin
   for the next invocations (this invocation is not strictly necessary
   and could be merged with the next step but having it separate makes
   the flow easier to understand, I think)
 * partitioning: runs the partitioning stage
 * extract: runs the extract stage
 * curthooks: runs the curthooks stage

The early and late stages were dropped since they would act as no-ops.
We also dropped the hook stage since it does nothing in Ubuntu.

The configuration files for each step ends up in
/var/log/installer/curtin-install/subiquity-{step_name}.conf

The log files for each step end up in
/var/log/installer/curtin-install/{step_name}.log

If errors occur, a tarball of the necessary logs end up in
/var/log/installer/curtin-install/{step_name}-error.tar

All files (i.e. configuration files, log files, error-files) are bundled
in the apport report in case of crash.

Signed-off-by: Olivier Gayot <olivier.gayot@canonical.com>
2022-08-11 09:16:06 +02:00
Olivier Gayot 0c73bf9b86 source: add ability to select source in autoinstall
The source autoinstall section now supports the "id" field where the
user can supply the ID of a source, e.g., "ubuntu-server" or
"ubuntu-server-minimal".

If the field is not supplied, the installation will use the source
declared default: true (if any) in the source catalog. Otherwise, it the
first source declared will be used.

Signed-off-by: Olivier Gayot <olivier.gayot@canonical.com>
2022-08-04 10:58:59 +02:00
Olivier Gayot c59a116f5d curtin-replay: update expected syslog identifier for curtin log lines
In the past, curtin log lines had the syslog identifier matching
"curtin_log.xxx". Nowadays, curtin commands are started via
systemd-run so they end up inheriting from the default
"subiquity_log.xxx" syslog identifier.

When updating the examples/curtin-*.json files, one must make sure to
filter out the entries that have the "subiquity_log.xxx" but are not
related to curtin invocations.

In the future, maybe we need to consider overriding the syslog
identifier when invoking curtin commands.

Signed-off-by: Olivier Gayot <olivier.gayot@canonical.com>
2022-08-01 09:26:12 +02:00
Olivier Gayot 3efed0e211 curtin-replay: improve CLI of replay-curtin-log
We now use argparse on replay-curtin-log, which provides the --help
option along with named parameters for what used to be positional
parameters only.

Signed-off-by: Olivier Gayot <olivier.gayot@canonical.com>
2022-08-01 09:26:11 +02:00
Dan Bungert 271a1b2d29 scripts: add keyboard-scraper.sh
This script runs keyboard-configuration.config in a chroot.  By running
interesting locales against it, we can obtain keyboard suggestions.
2022-07-29 13:01:18 -06:00
Carlos Nihelton d7697c0d0f
Without the timeout another kill is necessary
otherwise the process could stay running if the first `exit 1` after its
start was taken.
2022-06-16 17:29:44 -03:00
Carlos Nihelton 97f0f82910
Avoid integration to fail due TCP server timeout
timeout 60 might be too short for someone with lots of network
interfaces.
Since we grab the PID and run the server in the background, the timeout
is not critically necessary.
2022-06-16 16:43:44 -03:00
Carlos Nihelton 0263924386
Adds testing for IPv6.
Currently IPv4 is hardcoded, meaning IPv6 should not work even for
the loopback interface.
2022-06-08 12:17:23 -03:00
Carlos Nihelton 4c9a99e9ce
Asserts that only loopback connections are allowed. 2022-06-08 12:07:58 -03:00
Carlos Nihelton 858241956f
Add a simple test for TCP connectivity. 2022-06-07 14:53:29 -03:00
Olivier Gayot e58d1d00c2 kvm-test: introduce ability to pass -nic options to QEMU
The only way we had to pass -nic options to QEMU was to specify the
number of networks using the --nets option. Depending on its value, the
option would instruct QEMU to:
 * instantiate *n* user host networks if --nets >= 1
 * instantiate no network if --nets is 0
 * instantiate a "dead" network if --nets < 0

To simulate more advanced networks (such as networks where HTTP proxy is
needed), we want to add the possibility to use TAP network interfaces.

This patch adds the ability to pass custom -nic options to QEMU.

Three new options are available:

 * The --nic option passes the argument as-is to QEMU -nic option
 * The --nic-user option passes a user host network -nic option to QEMU
   - with SSH forwarding enabled. This is just like we do when using the
     --nets >= 1 option)
 * The --net-tap takes the name of an existing tap interface and
   generates the following -nic argument:

    tap,id={ifname},ifname={ifname},script=no,downscript=no,model=e1000

In the example below:
 * the first network uses the tap0 interface.
 * the second network uses the tap1 interface (it is syntactically
   equivalent to the first one)
 * the third network uses a user host network (with SSH forwarding)

  $ kvm-test.py \
    --nic tap,id=tap0,ifname=tap0,script=no,downscript=no,model=e1000 \
    --nic-tap tap1 \
    --nic-user

Signed-off-by: Olivier Gayot <olivier.gayot@canonical.com>
2022-04-28 14:48:51 +02:00
Olivier Gayot eb7dee2c9e kvm-test: get rid of unused import random
Signed-off-by: Olivier Gayot <olivier.gayot@canonical.com>
2022-04-27 20:04:33 +02:00
Olivier Gayot 6165c0a423 kvm-test: don't require LIVEFS_EDITOR if not building
Signed-off-by: Olivier Gayot <olivier.gayot@canonical.com>
2022-04-27 19:59:37 +02:00
Olivier Gayot 83dacb8c7c kvm-test: don't execute code if module is imported
Signed-off-by: Olivier Gayot <olivier.gayot@canonical.com>
2022-04-27 19:56:42 +02:00
Olivier Gayot 79326cf2eb source: run answers when only one source is configured
Before, we would not run answers for the source controller if only one
source was specified. The controller would automatically get marked
configured.

Since we're adding a new "search drivers" option in this screen, we need
to make it interactive in integration tests now.

Signed-off-by: Olivier Gayot <olivier.gayot@canonical.com>
2022-04-26 13:43:47 +02:00
Olivier Gayot fdd3ffdfa8 tests: use consistent order for subiquity cmdlines
In order we place:
 * the arguments that are for client & server
 * the arguments for the client only
 * the arguments for the server only

Signed-off-by: Olivier Gayot <olivier.gayot@canonical.com>
2022-04-22 11:41:34 +02:00
Olivier Gayot 5d3e0b4675 tests: pass the subiquity commands directly without sh -c ''
Signed-off-by: Olivier Gayot <olivier.gayot@canonical.com>
2022-04-22 11:34:48 +02:00
Carlos Nihelton ef18564eca
Cleans comments and adresses test.
- Under dry-run apt is run with --simulate.
- That can still fail if a package does not exist, for instance.
- If so, a file will not be written.
2022-03-22 19:41:37 -03:00
Dan Bungert 845b7e42c7 integration: EXIT trap for consistent error msg
The trap on ERR doesn't trigger in all the cases that we want.
The EXIT trap seems to be more robust, albeit with the requirement to
actually check the result code.
2022-03-21 11:11:53 -06:00
Dan Bungert 96082252f7 integration: use output-base=$tmpdir
Move from using .subiquity as output-base to a tmpdir.  This solves
several practical problems, like accidentally running the tests while
dryrun is open in another terminal or any other case where the server
process that is connected to is not the one that is expected.

Also makes cleanup nicer.

On failure, it will show which temporary directory was used to allow for
easy log examination.
2022-03-21 10:50:59 -06:00
Dan Bungert bed7cffe3c
Merge pull request #1164 from maces/patch-1
fixing swap path + support partition size units
2022-03-15 15:38:31 -06:00
Olivier Gayot 813448683c Enable tracemalloc in integration tests with at most 3 frames
Signed-off-by: Olivier Gayot <olivier.gayot@canonical.com>
2022-03-08 12:12:07 +01:00
Olivier Gayot a1df5ea409 Make integration tests fail if anything shows up in server-stderr
Signed-off-by: Olivier Gayot <olivier.gayot@canonical.com>
2022-03-08 12:12:07 +01:00