Commit Graph

118 Commits

Author SHA1 Message Date
Michael Hudson-Doyle 24a4d76e42 skip inappropriate checks in integration tests 2023-08-03 10:02:36 +12: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 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 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
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
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
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
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 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
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
Olivier Gayot e2216c1d53 Run script to validate autoinstall-user-data in integration tests
Signed-off-by: Olivier Gayot <olivier.gayot@canonical.com>
2022-01-21 13:48:43 +01:00
Olivier Gayot 9e7bc5053b Add support for APT preferences through autoinstall in Subiquity
The autoinstall schema for "apt" now supports the "preferences"
configuration. Each preference element should contain the properties
described below, that 1:1 map with the keywords from apt_preferences(5):

  * package      <-> Package:
  * pin          <-> Pin:
  * pin-priority <-> Pin-Priority:

These preferences are forwarded to curtin through
subiquity-curtin-apt.conf. Support for these rules must be added to
curtin as well.

Signed-off-by: Olivier Gayot <olivier.gayot@canonical.com>
2022-01-11 18:42:40 +01:00
Dan Bungert 96a53eff14
Merge pull request #1154 from dbungert/autoinstall-disable-components
apt: fix disable_components w/ autoinstall
2022-01-10 09:45:49 -07:00
Dan Bungert 3d10a71d3c
Merge pull request #1153 from ogayot/ua-with-autoinstall
Add support for ubuntu-advantage with autoinstall
2022-01-07 15:27:41 -07:00
Olivier Gayot 1a079ecddd Fix extraction of default locale when running integration tests
When running integration tests, the LANG variable in
.subiquity/etc/default/locale is unquoted. The pattern that we use
expects quotes so it does not match.

Fixed by making the test work with or without quotes.

In case quotes are not present, the final part of the pipeline will fail
to find a delimiter so it will print the line unchanged

excerpt from cut(1)

   -f, --fields=LIST
          select  only these fields;  also print any line that contains
          no delimiter character, unless the -s option is specified

Signed-off-by: Olivier Gayot <olivier.gayot@canonical.com>
2022-01-07 10:42:53 +01:00
Olivier Gayot 27ac4b43b1 Fix language pack detection when running integration tests
Looking at the logs, we can observe that the below command does
not do what it is intended to do:

  if [ -z "$( ls .subiquity/var/cache/apt/archives/) | grep $lang" ] ; then

  ++ ls .subiquity/var/cache/apt/archives/
  + '[' -z 'language-pack-en:amd64
  wamerican:amd64
  wbritish:amd64 | grep ' ']'

The "| grep $lang" part does not execute because it is outside the $()
construct. Therefore, the -z check is always false.

We can fix it by moving the "| grep $lang" part inside the subshell
construct but I took the opportunity to drop the use of the subshell.

Also added --fixed-strings and --quiet options to grep.

Signed-off-by: Olivier Gayot <olivier.gayot@canonical.com>
2022-01-06 12:05:03 +01:00
Olivier Gayot 81c67780ff Add basics checks for token validity in the autoinstall JSON schema
Signed-off-by: Olivier Gayot <olivier.gayot@canonical.com>
2022-01-06 10:54:08 +01:00
Dan Bungert 5a2a7f5ad6 apt: fix disable_components w/ autoinstall
* The mixture of storage for disable_components in and out of the config
  dict was confusing and caused bugs, depending on the flow
* disable_components now solely lives in the dict, like other items
2022-01-05 10:35:05 -07:00
Olivier Gayot d345cf999a Use autoinstall for ubuntu-advantage in integration tests
Signed-off-by: Olivier Gayot <olivier.gayot@canonical.com>
2022-01-04 17:58:46 +01:00
Carlos Nihelton bad945f5d7 Remove username from wsl.conf
- This is a cleanup for SystemSetup per DEENG-134 and DEENG-139
- Default user should be set by the WSL launcher.
- Shutdown/reboot actions also.
- Added a structured form of communication between OOBE and launcher.
- /run/launcher-command
2021-12-14 12:04:38 -03:00
Carlos Nihelton 37758047f2 Improved control over lang packs on integration
- Dryrun should never return empty packages list unless under failure.
- runtests check if the mimic-installed files match the proper language.
2021-11-22 12:16:01 -03:00