Commit Graph

26 Commits

Author SHA1 Message Date
Will Fancher
a923cc53e7 nixos/tests/hibernate: Simplify and always set resumeDevice 2023-07-29 14:21:28 -04:00
nikstur
0bdba6c99b nixos/qemu-vm: use persistent block device names
This change removes the bespoke logic around identifying block devices.
Instead of trying to find the right device by iterating over
`qemu.drives` and guessing the right partition number (e.g.
/dev/vda{1,2}), devices are now identified by persistent names provided
by udev in /dev/disk/by-*.

Before this change, the root device was formatted on demand in the
initrd. However, this makes it impossible to use filesystem identifiers
to identify devices. Now, the formatting step is performed before the VM
is started. Because some tests, however, rely on this behaviour, a
utility function to replace this behaviour in added in
/nixos/tests/common/auto-format-root-device.nix.

Devices that contain neither a partition table nor a filesystem are
identified by their hardware serial number which is injecetd via QEMU
(and is thus persistent and predictable). PCI paths are not a reliably
way to identify devices because their availability and numbering depends
on the QEMU machine type.

This change makes the module more robust against changes in QEMU and the
kernel (non-persistent device naming) and by decoupling abstractions
(i.e. rootDevice, bootPartition, and bootLoaderDevice) enables further
improvement down the line.
2023-06-16 19:36:03 +02:00
Anderson Torres
d1a2a4cbcc nixos/tests/hibernate.nix: get rid of with lib 2023-05-12 22:29:26 -03:00
Raito Bezarius
58f4c3944d nixos/tests(treewide): vdb → vda, vdc → vdb, vdd → vdc, … / bootDevice → rootDevice 2023-04-21 13:00:19 +02:00
Will Fancher
23b3add0e3 nixos: Fix hibernate test with systemd stage 1 2022-11-20 21:01:51 -05:00
Janne Heß
aeb75b3b69
nixos/stage-1-systemd: Implement hibernation + test 2022-04-13 23:02:13 +01:00
Martin Weinelt
bc4b9eef3c
Merge pull request #167061 from Artturin/fixtestevalhib 2022-04-03 20:54:34 +02:00
Artturin
65725c1637 nixos/tests/hibernate: fix eval
by removing duplicate `nodes`
2022-04-03 21:35:05 +03:00
Lassulus
e65b825672
Merge pull request #165684 from helsinki-systems/clean/stage-2-init
nixos/stage-2-init: Clean up legacy commands
2022-04-03 14:12:52 +02:00
Robert Hensing
aa0f27abb0 treewide: machine -> nodes.machine 2022-03-28 14:11:58 +02:00
Janne Heß
452102db8f
nixos/stage-2-init: Clean up legacy commands
We can perform most of the mkdir/ln/rm using systemd-tmpfiles
instead which cleans up the script.

/bin and /home are created by their activation script snippets

usbfs is deprecated and unused.

hwclock seems to be automatically executed by systemd on startup.

The mkswap to prevent hibernation cycles seems to be executed by systemd
as well since the provided regression tests succeeds.
2022-03-27 13:51:02 +02:00
polykernel
4a9d9928dc nixos/nix-daemon: use structural settings
The `nix.*` options, apart from options for setting up the
daemon itself, currently provide a lot of setting mappings
for the Nix daemon configuration. The scope of the mapping yields
convience, but the line where an option is considered essential
is blurry. For instance, the `extra-sandbox-paths` mapping is
provided without its primary consumer, and the corresponding
`sandbox-paths` option is also not mapped.

The current system increases the maintenance burden as maintainers have to
closely follow upstream changes. In this case, there are two state versions
of Nix which have to be maintained collectively, with different options
avaliable.

This commit aims to following the standard outlined in RFC 42[1] to
implement a structural setting pattern. The Nix configuration is encoded
at its core as key-value pairs which maps nicely to attribute sets, making
it feasible to express in the Nix language itself. Some existing options are
kept such as `buildMachines` and `registry` which present a simplified interface
to managing the respective settings. The interface is exposed as `nix.settings`.

Legacy configurations are mapped to their corresponding options under `nix.settings`
for backwards compatibility.

Various options settings in other nixos modules and relevant tests have been
updated to use structural setting for consistency.

The generation and validation of the configration file has been modified to
use `writeTextFile` instead of `runCommand` for clarity. Note that validation
is now mandatory as strict checking of options has been pushed down to the
derivation level due to freeformType consuming unmatched options. Furthermore,
validation can not occur when cross-compiling due to current limitations.

A new option `publicHostKey` was added to the `buildMachines`
submodule corresponding to the base64 encoded public host key settings
exposed in the builder syntax. The build machine generation was subsequently
rewritten to use `concatStringsSep` for better performance by grouping
concatenations.

[1] - https://github.com/NixOS/rfcs/blob/master/rfcs/0042-config-option.md
2022-01-26 21:04:50 -05:00
Artturi
c4851c0d71
Revert msize related commits (#147180) 2021-11-24 02:33:53 +02:00
Artturin
471183f245 nixos/tests/hibernate: set memorySize to 2G 2021-11-20 22:21:39 +02:00
Robert Hensing
739c51ae4e nixosTests: Redirect stdout to stderr when detaching
Avoids blocking on stdout.
2021-11-05 02:41:26 +01:00
Janne Heß
1640359f33
nixos/test-runner: Fix execute() flakiness
Instead of using the magic string, we now just base64-encode everything
and check for a newline.
2021-10-28 11:51:20 +02:00
Anders Kaseorg
97e39fcafa nixosTests.hibernate: Make sure machines are shut down when finished
Co-authored-by: Janne Heß <janne@hess.ooo>
Signed-off-by: Anders Kaseorg <andersk@mit.edu>
2021-10-26 16:45:36 -07:00
Luke Granger-Brown
32d80aaaa5 nixos/tests/hibernate: install a system instead
Rather than relying on carefully avoiding touching the 9P-mounted
/nix/store, we instead install a small NixOS system, similar to
the installer tests, and boot from that.

This avoids the various pitfalls associated with trying to unsuspend
properly and trades off a bunch of boilerplate for what will hopefully
be a more reliable test.

Additionally, this test now actually tests booting the system using a
bootloader, rather than the previous method of just booting the kernel
directly.
2021-04-23 01:30:38 +00:00
Jan Hrnko
66c9911264 nixos/hibernate: port test to python 2019-11-22 20:38:56 +01:00
xeji
beb8ca2887
nixos/tests/hibernate: prevent non-deterministic failure (#46882)
... that occurred mostly on i686. Improve timing.
With this, the failures are no longer reproducible on my machine.
2018-09-19 16:19:45 +02:00
volth
2e979e8ceb [bot] nixos/*: remove unused arguments in lambdas 2018-07-20 20:56:59 +00:00
aszlig
146cb02542
nixos/tests/hibernate: Fix netcat flags
I'm not sure why 024b501907 used -q 0
because even netcat-openbsd has the -N flag which IMO is the better way
to shutdown the socket on EOF.

Our default netcat implementation has changed once again[1] in
3c3b82234a and we're now using LibreSSL's
implementation, which doesn't have a -q flag.

See https://github.com/NixOS/nixpkgs/pull/39634 for the pull request
introducing the switch.

[1]: https://github.com/NixOS/nixpkgs/pull/19982

Signed-off-by: aszlig <aszlig@nix.build>
Cc: @matthewbauer, @dtzWill, @Mic92
2018-04-29 23:46:47 +02:00
Tim Steinbach
024b501907
tests: Fix hibernate 2017-09-06 22:01:48 -04:00
Tuomas Tynkkynen
affce1e246 nixos hibernate test: Use waitForOpenPort
There was one confusing recent failure of this:

http://cache.nixos.org/log/myla8bc17j8spmifdxmrz9jswxwsf5w6-vm-test-run-hibernate.drv

I don't have any real ideas on what could cause the problem but there is
at least one theoretical one: the system starts hibernating before the
listener process manages to open the TCP port for listening, and it can't
open it after resuming because not enough pages from the netcat binary
have been paged in (and as the 9p filesystem holding it is now toast,
they can't be loaded anymore).
2017-04-02 02:33:21 +03:00
sternenseemann
e2372502d3 netcat: make netcat-openbsd the default netcat (#19411)
The motivation for this change is the following: As gnu-netcat,
e. g. does not support ipv6, it is not suitable as default netcat.

This commit also fixes all obvious build issues caused by this change.
2016-10-30 15:06:04 +01:00
Nikolay Amiantov
9cc70b419c nixos/tests: add hibernation test 2016-07-19 05:20:02 +03:00