Commit Graph

687 Commits

Author SHA1 Message Date
Marijan Petričević
03c90974a7 add tmp_dir access check 2022-01-25 11:14:57 +01:00
Marijan Petričević
e17fcbc966 introduce writeable_dir argparse type 2022-01-25 10:21:33 +01:00
Marijan Petričević
7765670c8a make output_directory an optional parameter 2022-01-25 01:18:52 +01:00
Marijan Petričević
f9b5f9dba7 nixos/test-driver: use an argument instead of the out env-var 2022-01-25 01:17:29 +01:00
Alyssa Ross
1a60dd2adc
Merge remote-tracking branch 'nixpkgs/staging-next' into staging
Conflicts:
	pkgs/development/python-modules/cupy/default.nix
	pkgs/development/python-modules/staticjinja/default.nix
2022-01-24 15:39:34 +00:00
Samuel Dionne-Riel
18ebd1c330
Merge pull request #153409 from tpwrules/fix-nonx86-iso-reproducibility
installer/cd-dvd/iso-image: avoid leaking build timestamps on non-x86
2022-01-23 21:15:26 -05:00
github-actions[bot]
aeb6db8171
Merge staging-next into staging 2022-01-20 18:01:55 +00:00
Alyssa Ross
464d6108b0 Revert "qemu, runInLinuxVM: change default cpu to qemu64"
This reverts commit af180d554b.

The bug we were working around with this change has been fixed in QEMU
6.2.0.
2022-01-20 15:29:33 +00:00
Robert Hensing
98ae5a9298
Merge pull request #153211 from hercules-ci/minimal-nixos
Add minimal NixOS entrypoint
2022-01-20 14:42:46 +01:00
Jörg Thalheim
f472e52aa6 nixos/tests: add prompt to shell_interact()
Example session:

>>> start_all()
>>> machines[0].shell_interact()
client: waiting for the VM to finish booting
client: connected to guest root shell
client: (connecting took 0.00 seconds)
(finished: waiting for the VM to finish booting, in 0.05 seconds)
client: Terminal is ready (there is no initial prompt):
$ ls -la
total 39
drwxrwxrwt 11 root root 4096 Jan 15 06:06 .
drwxr-xr-x 17 root root 4096 Jan 15 06:06 ..
drwxrwxrwt  2 root root 4096 Jan 15 06:06 .font-unix
drwxrwxrwt  2 root root 4096 Jan 15 06:06 .ICE-unix
drwx------  2 root root    2 Jan 12 20:19 shared
drwx------  3 root root 4096 Jan 15 06:06 systemd-private-b8f21699ea684491926859758de41975-nscd.service-txgYVZ
drwx------  3 root root 4096 Jan 15 06:06 systemd-private-b8f21699ea684491926859758de41975-systemd-logind.service-U3GmlL
drwxrwxrwt  2 root root 4096 Jan 15 06:06 .Test-unix
drwxrwxrwt  2 root root 4096 Jan 15 06:06 .X11-unix
drwxr-xr-x  2 root root    2 Jan 15 06:06 xchg
drwxrwxrwt  2 root root 4096 Jan 15 06:06 .XIM-unix
2022-01-15 07:07:06 +01:00
Robert Hensing
2bf5958169
Merge pull request #151082 from hercules-ci/nixos-cleanup-vmWithBootLoader
nixos: turn vmWithBootLoader into option (`nixos-rebuild build-vm`)
2022-01-14 18:49:27 +01:00
Robert Hensing
3168017b90 nixos/lib: Clarify that nixos.evalModules impl is NOT experimental 2022-01-10 12:36:57 +01:00
Robert Hensing
d3f956aba3 nixos/lib: Add featureFlags, use it for minimal modules 2022-01-10 12:36:57 +01:00
Robert Hensing
25caf736d5 nixos/eval-config: Layer on top of nixos/eval-config-minimal 2022-01-10 12:26:59 +01:00
Robert Hensing
e31e096b66 nixos/lib: Move evalModules into its own file 2022-01-10 12:26:59 +01:00
Zhaofeng Li
9e97ef794a lib/qemu-common: Add serial device name for RISC-V 2022-01-09 15:29:52 -08:00
github-actions[bot]
b40a01817b
Merge master into staging-next 2022-01-08 18:01:00 +00:00
Jacek Galowicz
048fd95f10
Merge pull request #146905 from Synthetica9/failure_mode
nixos/test-driver: add polling_condition
2022-01-08 18:28:25 +01:00
Jonathan Ringer
86f9a32c4c
Merge remote-tracking branch 'origin/master' into staging-next
Conflicts:
	pkgs/development/python-modules/hydra/default.nix
2022-01-07 10:31:29 -08:00
Patrick Hilhorst
0c3f1cf420
Merge pull request #153273 from Synthetica9/passthru-driverInteractive 2022-01-07 16:04:43 +01:00
Robert Hensing
fbd038eca2 nixos/lib: init (experimental) 2022-01-07 01:21:07 +01:00
Thomas Watson
450ce00ec4 installer/cd-dvd/iso-image: avoid leaking build timestamps on non-x86 2022-01-05 12:05:15 -06:00
github-actions[bot]
89a0a771b6
Merge master into staging-next 2022-01-05 00:01:52 +00:00
Patrick Hilhorst
d4dc638d77
nixos/test-driver: also passthru driverInteractive 2022-01-04 14:52:37 +01:00
Patrick Hilhorst
793a2f50f1
nixos/test-driver: remove unused imports, add pylint unused-import check 2022-01-02 23:12:21 +01:00
Patrick Hilhorst
a2f5092867
nixos/test-driver: simplify logic, reduce interaction surface 2022-01-02 22:52:17 +01:00
Patrick Hilhorst
7830f000c5
nixos/test-driver: simplify coopmulti 2022-01-02 22:20:04 +01:00
pennae
50954ad1c5 nixos/make-options-doc: treat missing descriptions as errors by default
this partially solves the problem of "missing description" warnings of the
options doc build being lost by nix build, at the cost of failing builds that
previously ran. an option to disable this behaviour is provided.
2022-01-02 19:46:13 +01:00
pennae
1301bdb185 nixos/make-options-doc: turn relatedPackages into links
link to search.nixos.org instead of pulling package metadata out of pkgs. this
lets us cache docs of a few more modules and provides easier access to package
info from the HTML manual, but makes the manpage slightly less useful since
package description are no longer rendered.
2022-01-02 19:46:13 +01:00
pennae
b92a47c87c nixos/make-options-doc: add type annotations to mergeJSON.py 2022-01-02 19:46:13 +01:00
pennae
fc614c37c6 nixos/documentation: split options doc build
most modules can be evaluated for their documentation in a very
restricted environment that doesn't include all of nixpkgs. this
evaluation can then be cached and reused for subsequent builds, merging
only documentation that has changed into the cached set. since nixos
ships with a large number of modules of which only a few are used in any
given config this can save evaluation a huge percentage of nixos
options available in any given config.

in tests of this caching, despite having to copy most of nixos/, saves
about 80% of the time needed to build the system manual, or about two
second on the machine used for testing. build time for a full system
config shrank from 9.4s to 7.4s, while turning documentation off
entirely shortened the build to 7.1s.
2022-01-02 19:46:13 +01:00
Patrick Hilhorst
ac6c06c549
nixos/test-driver: bump version 2022-01-01 23:17:37 +01:00
Patrick Hilhorst
4e1556ed4d
nixos/test-driver: add polling_condition 2022-01-01 23:17:32 +01:00
github-actions[bot]
129083edcf
Merge master into staging-next 2021-12-29 06:01:11 +00:00
Julien Moutinho
8b842173d0 nixos/make-options-doc: fix invalid ':' in XML NCName (non-colonized name) 2021-12-28 22:18:16 -05:00
Guillaume Girol
2a37dd8ab3 nixos/systemd: validate the values of systemd.services.<name>.after
and similar option. Notably check that they end with one of .service,
.target, etc.
2021-12-27 12:00:00 +00:00
wucke13
121e2f7e15 honor sdImage.compressImage in intermediate build steps 2021-12-21 21:31:44 +01:00
Robert Hensing
9fd9c617a9 nixos/lib/eval-config.nix: Return all of evalModules return attrs
We were exposing everything pointwise anyway.
If any new attrs are added, there's a good chance we'll want to
expose them anyway.
2021-12-17 14:07:47 +01:00
Robert Hensing
8fd49c116b nixos/default.nix: Use extendModules 2021-12-17 13:17:37 +01:00
github-actions[bot]
a292b5fe68
Merge staging-next into staging 2021-12-14 12:02:00 +00:00
pennae
a70b1eb630 nixos/lib/make-options-doc: fix with nix 2.3 2021-12-14 03:41:09 +01:00
Dmitry Kalinkin
07a8ae0c5a
Merge branch 'staging-next' into staging
Conflicts:
	pkgs/development/libraries/log4cplus/default.nix
2021-12-11 14:01:19 -05:00
Jacek Galowicz
b6bf1ca717
Merge pull request #149329 from marijanp/test-driver-restructuring
nixos/test-driver: make the test-driver a python package
2021-12-10 18:41:49 +00:00
Marijan Petričević
ab693de868 nixos/test-driver: make the test-driver a python package 2021-12-10 12:27:45 +00:00
Silvan Mosberger
2f2b60dd87 lib/nixos/eval-config.nix: Fix extraArgs
Fixes a mistake in https://github.com/NixOS/nixpkgs/pull/148315 that
caused https://github.com/NixOS/nixpkgs/issues/148343#issuecomment-990881216
2021-12-10 12:55:30 +01:00
Silvan Mosberger
15c41e1d54
Merge pull request #147265 from pennae/option-docs-build
put all option docs build flavors on equal footing
2021-12-08 21:27:02 +01:00
Artturi
3fe92b45cb
Merge pull request #149665 from Artturin/squashfscores 2021-12-08 20:20:32 +02:00
Artturin
eea6baad50 make-squashfs: use $NIX_BUILD_CORES or 48 cores if above 48
by default all cores are used

hoping this will fix the hydra i686 squashfs build issues as all the
failures were using 64 cores

Parallel mksquashfs: Using 64 processors
Creating 4.0 filesystem on ..., block size 1048576.
FATAL ERROR: mangle2:: xz compress failed with error code 5
2021-12-08 19:23:31 +02:00
ajs124
eee45bb295
Merge pull request #146815 from ElvishJerricco/systemd-utils-expressions
Move systemd-lib.nix and systemd-unit-options.nix into utils
2021-12-08 15:07:28 +00:00
Silvan Mosberger
490d46f044
Merge pull request #148315 from hercules-ci/nixos-evalModules-legacy-cleanup
NixOS/evalModules legacy cleanup
2021-12-07 18:30:52 +01:00
pennae
027f7e1b7f nixos/lib/make-options-doc: generate options.xml from options.json
to do this we must replace derivations with attrsets in make-options-doc, since
xml can represent derivations differently from attrset but json cannot. this
also given asciidoc and mddoc the ability to handle derivation differently,
which they previously didn't have.
2021-12-06 16:12:32 +01:00
pennae
9b97a2ea88 nix/lib/make-options-doc: remove nix-level sorting
there are no remaining users of sorted option lists except the docbook build,
which sorts its input separately.
2021-12-06 16:12:32 +01:00
pennae
4670400309 nixos/lib/make-options-doc: generate asciidoc/md in derivations
use the json file derivation we already have to also generate the asciidoc and
md options docs instead of formatting the options in nix. docbook docs are
already produced in derivations.

the new script produce the exact same output as the old in-nix generation.
2021-12-06 16:12:30 +01:00
Artturin
60422ba2ea nixos/test-driver: add 10ms delay to send_key
attempt to fix https://github.com/NixOS/nixpkgs/issues/147294
2021-12-03 20:04:56 +02:00
Robert Hensing
78ada83361 nixos/eval-config: Deprecate extraArgs and check parameters 2021-12-02 18:23:43 +00:00
Robert Hensing
0b5aea2b27 nixos/eval-config: Remove a rec 2021-12-02 18:23:43 +00:00
Robert Hensing
59c4a35aab nixos/eval-config: Avoid evalModules args and check parameters 2021-12-02 18:23:43 +00:00
Jacek Galowicz
58371472fe
Merge pull request #146512 from DeterminateSystems/better-visibility
nixos/test-driver: more context when step finishes, give more functions nested labels
2021-12-02 09:26:21 +00:00
Jacek Galowicz
57dc1085dc
Merge pull request #146271 from DeterminateSystems/better-timeouts
nixos/test-driver: add execute_with_timeout, add (functional) timeouts to more functions
2021-12-01 19:01:05 +00:00
Cole Helbling
af765f3abd nixos/test-driver: give more functions nested labels
This will make it easier to trace through the test execution without
having to scroll through the entire kernel output.
2021-12-01 10:29:56 -08:00
Cole Helbling
c6ee63259a nixos/test-driver: more context when step finishes
When displaying the amount of time some step took, with no other
context, it becomes nigh impossible (especially in longer tests) to see
when specific steps finished.
2021-12-01 10:29:56 -08:00
Robert Hensing
8a129f8cf0
Merge pull request #144094 from hercules-ci/nixos-specialisations-use-extendModules
nixos/specialisation: Rephrase in terms of extendModules, noUserModules
2021-12-01 11:03:36 +01:00
Martin Schwaighofer
af180d554b qemu, runInLinuxVM: change default cpu to qemu64
The flag -cpu max leaves QEMU 6.1.0 stuck on some systems,
for example when /dev/kvm is not read-writable.
This does not happen with -cpu qemu64.

Getting stuck like that is a regression in 6.1.0 not yet present in 6.0.0
and should be fixed with 6.2.0 according to early testing with rc1.

We should consider reverting this change when we merge QEMU 6.2.0.
See #146526.

fixes #141596
2021-11-30 13:06:22 +00:00
talyz
e8cc900eae
make-disk-image: Make additionalPaths work with Nix 2.4
The `nix` command is marked as experimental since 2.4, so an extra
flag is required to unlock it.
2021-11-29 21:11:15 +01:00
Ryan Burns
2175b157ac treewide: refactor isi686 && isx86_64 -> isx86 2021-11-20 17:50:41 -08:00
Will Fancher
851495a752 Move systemd-lib.nix and systemd-unit-options.nix into utils 2021-11-20 17:52:29 -05:00
Patrick Hilhorst
1334a62539
test-driver.py: directly import pathlib.Path 2021-11-20 01:37:08 +01:00
Patrick Hilhorst
9e71014ede
test-driver.py: always export single machine as 'machine' 2021-11-19 23:02:30 +01:00
Patrick Hilhorst
a8f693ed48
test-driver.py: fix weird non-pythonism 2021-11-19 22:28:32 +01:00
Cole Helbling
e62b8020f3 nixos/test-driver: add (functional) timeouts to more functions
A retry timeout doesn't really help if the thing it's retrying may block
forever.
2021-11-17 16:11:10 -08:00
Cole Helbling
363d7f3ae8 nixos/test-driver: add timeout parameter to execute 2021-11-17 16:11:03 -08:00
Artturin
83f892c511 nixos/lib: add /usr to pathsNeededForBoot
if /usr is split from root then it has to be mounted at boot
See https://github.com/NixOS/nixpkgs/issues/146115
2021-11-15 16:28:22 +02:00
Jacek Galowicz
2ba0732988
Merge pull request #142747 from helsinki-systems/fix/test-runner-execute
nixos/test-runner: Fix execute() flakiness
2021-11-02 14:51:50 +01:00
Robert Hensing
b5681a7a40 nixos/specialisation: Rephrase in terms of extendModules, noUserModules
By using the new extendModules function to produce the specialisations,
we avoid reimplementing the eval-config.nix logic in reverse and fix
cross compilation support for specialisations in the process.
2021-11-01 10:59:47 +01:00
Robert Hensing
0b0d2637fc Revert "nixos/specialisation: Rephrase in terms of extendModules, noUserModules"
This reverts commit e2bea4427b.

While this commit was probably fine, I want to be conservative
with changes right before the release branch-off.
So far the extendModules commits have been adding and refactoring
expressions that did not affect derivation hashes, whereas this
commit changes the module ordering. I will open a separate PR for
it.
2021-11-01 09:41:55 +01:00
Robert Hensing
e2bea4427b nixos/specialisation: Rephrase in terms of extendModules, noUserModules 2021-11-01 09:40:16 +01:00
Robert Hensing
22584ce667 nixos/eval-config.nix: Expose type
Also works for (pkgs.nixos {}).type.
2021-11-01 09:38:49 +01:00
Robert Hensing
56c4f9d005 nixosTest: Fix infinite recursion involving hasContext testScript when useNixStoreImage = true
The involved test was nixosTests.nextcloud.basic21.

It has a testScript that is strict in nodes.nextcloud.config.system.build.vm,
in assertions about imagemagick being in the system closure.

The recursion was introduced in 329a4461a7 from
https://github.com/NixOS/nixpkgs/pull/140792
2021-10-31 18:25:19 +01:00
talyz
46f7521144 make-disk-image: Add an argument to only build a Nix store image
Add the `onlyNixStore` argument which enables building images
containing the contents of the Nix store at the root, instead of a
full system.
2021-10-28 12:55:01 +02:00
talyz
329a4461a7 nixos/testing-python: Copy test script derivations to nodes
Make sure the all derivations referenced by the test script are
available on the nodes. Accessing these derivations works just fine
without this change when using 9p to mount the host's store, but when
an image is built (virtualisation.buildRootImage), the dependencies
need to be copied to the image. We don't want to copy the script
itself, though, since that would trigger unnecessary image rebuilds.
2021-10-28 12:55:01 +02:00
talyz
87d8eec069 make-disk-image: Add additionalPaths argument
Add an argument which makes it possible to add additional paths to the
image's nix store.
2021-10-28 12:55:01 +02:00
talyz
398a73ac98 make-disk-image: Add copyChannel argument
Add a copyChannel argument which controls whether the current source
tree will be made available as a nix channel in the image or
not. Previously, it always was. Making it available is useful for
interactive use of nix utils, but changes the hash of the image when
the sources are updated.
2021-10-28 12:55:01 +02:00
talyz
56c5efa25b make-disk-image: Reintroduce the installBootLoader argument
installBootLoader was removed in
f1708a9d7d79e2bf2961fc648625578b23b3460f; probably by mistake, since
only the logic was removed, not the argument.
2021-10-28 12:55:01 +02: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
Janne Heß
1ed5606d8a
nixos/test-runner: Fix thread cleanup 2021-10-24 15:11:46 +02:00
K900
9611041ef5 nixos/lib/test-driver: set defaults in __init__ instead of class level
Just a minor code style nit to avoid potential footguns
2021-10-19 16:29:19 +03:00
K900
a874235dff nixos/lib/test-driver: clean up threads correctly
The current implementation just forks off a thread to read
QEMU's stdout and lets it exist forever. This, however,
makes the interpreter shutdown racy, as the thread could
still be running and writing out buffered stdout when the
main thread exits (and since it's using the low level API,
the worker thread does not get cleaned up by the atexit hooks
installed by `threading`, either). So, instead of doing that,
let's create a real `threading.Thread` object, and also
explicitly `join` it along with the other stuff when cleaning up.
2021-10-19 16:23:51 +03:00
Domen Kožar
8fdc8fe5ce
Merge pull request #142040 from pennae/optimize-module-docs
make-options-docs: don't sort the options XML file
2021-10-18 16:38:32 -05:00
pennae
24eb353907 make-options-docs: don't sort the options XML file
we need the file itself as a dependency for the docbook build, but we don't need
it to be properly sorted at the nix level. push the sort out to a python script
instead to save eval time. on the machine used to write this `nix-instantiate
<nixos/nixos> -A system` went down from 7.1s to 5.4s and GC heap size decreased
by 50MB (or 70MB max RSS).
2021-10-18 03:45:33 +02:00
Robert Hensing
c247827654 nixosTest: Provide system.build.networkConfig 2021-10-17 23:56:52 +02:00
Janne Heß
540dc908ca
nixos/test-runner: Print exceptions that happen 2021-10-14 00:15:53 +02:00
Kim Lindberger
4e97bedf93
Merge pull request #112823 from deviant/nixos-boot-paths
nixos/boot: add /var/lib/nixos to pathsNeededForBoot
2021-10-07 17:38:54 +02:00
Jacek Galowicz
d68f1e43df
Merge pull request #126713 from blaggacao/nixos-test-ref/05-class-ify-test-driver
nixos test ref/05 class ify test driver
2021-10-07 14:37:01 +02:00
Jacek Galowicz
5c666cdf62 Re-RAII-ify the NixOS integration test driver's VLAN class.
We have no usecase for manually/selectively starting or stopping VLANs
in integration tests.
By starting and stopping the VLANs with the constructor and destructor
of VLAN objects, we remove the obligation and complexity to maintain
network lifetime separately.
2021-10-05 14:38:48 -05:00
Maximilian Bosch
3f63e3ce65 nixos/test-driver: fix graphics for VM
`-nographic` should only be set if no display is available. Otherwise,
tools such as `nixos-build-vms(8)` will never open up a graphical
display.
2021-10-05 14:38:48 -05:00
David Arnold
b0fc9da879 nixos/test/test-driver: Class-ify the test driver
This commit encapsulates the involved domain into classes and
defines explicit and typed arguments where untyped dicts where used.

It preserves backwards compatibility through legacy wrappers.
2021-10-05 14:38:48 -05:00
Naïm Favier
330b1e08b8
nixos/lib/make-options-doc: implement literalDocBook 2021-10-03 17:59:44 +02:00
rnhmjoj
b29c2f97c3
nixos/lib/qemu-flags: rename to qemu-common
The current name is misleading: it doesn't contain cli arguments,
but several constants and utility functions related to qemu.
This commit also removes the use of `with import ...` for clarity.
2021-09-18 16:58:16 +02:00
rnhmjoj
30f0faac22
nixos/qemu: add types to all options 2021-09-18 16:47:11 +02:00
rnhmjoj
c1fd51f490
nixos/qemu: fix several shellcheck issues
- Fix shell quoting issues
- Fix unsafe cd in run-machine-vm script
2021-09-18 16:46:20 +02:00
Matthew Kenigsberg
b00d2a8f3e
nixos/testing: remove unused function runInMachine
runInMachine and runInMachineWithX are not used for any tests and can be
removed
2021-09-08 06:25:20 -05:00
Graham Christensen
076f6e2d94 nixos/make-zfs-image: init
This is a private interface for internal NixOS  use. It is similar
to `make-disk-image` except it is much more opinionated about what
kind of disk image it'll make.

Specifically, it will always create *two* disks:

1. a `boot` disk formatted with FAT in a hybrid GPT mode.
2. a `root` disk which is completely owned by a single zpool.

The partitioning and FAT decisions should make the resulting images
bootable under EFI or BIOS, with systemd-boot or grub.

The root disk's zpools options are highly customizable, including
fully customizable datasets and their options.

Because the boot disk and partition are highly opinionated, it is
expected that the `boot` disk will be mounted at `/boot`. It is
always labeled ESP even on BIOS boot systems.

In order for the datasets to be mounted properly, the `datasets`
passed in to `make-zfs-image` are turned in to NixOS configuration
stored at /etc/nixos/configuration.nix inside the VM.
NOTE: The function accepts a system configuration in the `config`
argument. The *caller* must manually configure the system
in `config` to have each specified `dataset` be represented
by a corresponding `fileSystems` entry.

One way to test the resulting images is with qemu:

```sh
boot=$(find ./result/ -name '*.boot.*');
root=$(find ./result/ -name '*.root.*');

echo '`Ctrl-a h` to get help on the monitor';
echo '`Ctrl-a x` to exit';

qemu-kvm \
    -nographic \
    -cpu max \
    -m 16G \
    -drive file=$boot,snapshot=on,index=0,media=disk \
    -drive file=$root,snapshot=on,index=1,media=disk \
    -boot c \
    -net user \
    -net nic \
    -msg timestamp=on
```
2021-08-25 10:42:35 -04:00
David Arnold
2832896c5b
nixos/test: some test fixes in succession of #125992 2021-08-20 13:38:22 -05:00
David Arnold
db614e11d6
nixos/tests/test-driver: better control test env symbols
Previous to this commit, the entire test driver environment was shared
with the actual python test environment.

This is a hefty api surface. This commit selectively exposes only those
symbols to the test environment that are actually meant to be used by
tests.
2021-08-19 23:55:26 -05:00
Maximilian Bosch
0362d572b2
Merge pull request #133675 from Ma27/test-driver-compat
nixos/test-driver: minor fixes for `nixos-build-vms(8)`
2021-08-16 14:07:01 +02:00
Robert Hensing
fbafeb7ad5 treewide: runCommandNoCC -> runCommand
This has been synonymous for ~5y.
2021-08-15 17:36:41 +02:00
Maximilian Bosch
1ba3f7927f
nixos/testing: only create nixos-run-vms for nixos-build-vms(8)
This is the case when the test-script is empty. `nixos-build-vms(8)` is
primarily supposed to be used as tool to test changes or to reproduce
bugs (IMHO) where "just spinning up a few VMs" is the primary use-case.

In the ongoing discussion about these changes[1] it was suggested to
only expose it when needed (i.e. in the case I described above) to keep
the API surface as slim as possible.

[1] https://github.com/NixOS/nixpkgs/pull/133675#discussion_r688112485
2021-08-13 17:39:49 +02:00
Maximilian Bosch
e1ec5acd31
nixos/test-driver: start interactive mode if testScript is empty
This is relevant for `nixos-build-vms(8)` which doesn't have a
test-script. In that case it's more intuitive to directly go into the
interactive mode which is IMHO more intuitive.
2021-08-12 23:01:03 +02:00
Maximilian Bosch
260d9cc7e1
nixos/testing: re-add nixos-run-vms script
Originally removed in 926fb93968. This
one is actually quite useful for `nixos-build-vms(8)`.
2021-08-12 22:50:29 +02:00
lewo
7aa78642c5
Merge pull request #125979 from blaggacao/nixos-test-ref/03-normalse-the-python-entrypoint
nixos/test-driver: normalize the python entrypoint
2021-08-08 10:24:47 +02:00
David Arnold
926fb93968
nixos/tests/test-driver: normalise test driver entrypoint(s)
Previously the driver was configured exclusively through convoluted
environment variables.

Now the driver's defaults are configured through env variables.

Some additional concerns are in the github comments of this PR.
2021-08-05 19:07:11 -05:00
David Arnold
dc060ff8b2
nixos/testing: fix invalid node names detection
the use of python further restricts possible RFC1035 host labels since
dash is not allowed for use in python identifiers.

The previous implementation of this check was flawed, since it did not
check the `hostName` value that is actually used to construe the
identifier, but the node name, which can be anything, e.g. just `machine`.

The previous implementation, by further restricting RFC1035 labels, only
for the sake of testing seems to be an unacceptable restriction and should
be addressed separately.
2021-07-28 15:37:57 -05:00
Ingo Blechschmidt
5143ab9f74 tigervnc, tightvnc: add basic tests
Co-Authored-By: Ingo Blechschmidt <iblech@web.de>
2021-07-20 15:22:31 +02:00
misuzu
702a1c23a4 nixos/test-driver: allow overriding qemu binary in create_startcommand 2021-07-14 12:47:12 +03:00
Robert Hensing
c1a75084ea
Merge pull request #127744 from cransom/disk-image-faster
make-disk-image: Reduce forking
2021-06-26 08:31:12 +02:00
Jörg Thalheim
48aec70ea1
nixos/test-driver: replace termlib with socat
telnetlib does not handle unicode, which is annoying when using systemctl.
Also this gives us a nice readline with history.
2021-06-22 09:08:57 +02:00
Casey Ransom
c3f28aed94 make-disk-image: Reduce forking
The disk image calculator was using find + exec forking du for every
file in the disk image, making it very slow. Change du to accept files,
nul delimeted on stdin to speed it back up.

Before change:
nix-build nixos/tests/image-contents.nix  9.71s user 1.06s system 8% cpu 2:13.11 total

After change:
nix-build nixos/tests/image-contents.nix  9.93s user 1.23s system 21% cpu 51.601 total
2021-06-21 22:58:07 -04:00
David Arnold
8bbdff4581
nixosTest: Force system.nixos.revision constant
nixos tests are blended with other system configurations, hence
their settings must be either enforced or defaulted.

This particular setting is set via lib.nixosSystem as
`system.nixos.revision = final.mkIf (self ? rev) self.rev;` which would
mean that without this change no flake generated nixos could be blended
with nixos testing.

This setting was made previously constant in 
169c6b4b14 in order to avoid pointless
rebuilds of the testing VMs, but was set without enforcing it.
2021-06-21 11:08:26 -05:00
Kim Lindberger
410496d0f3
Merge pull request #127309 from jakobrs/nixos-normalise-null
Resolve evaluation failure when filesystem device option is null
2021-06-18 17:15:08 +02:00
aszlig
bc0997489b
nixos/test-driver: Fix passing passthru attribute
Apparently this looks like it was forgotten when doing commit
3884ff70ba, which refactored the test
runner and driver a bit.

The passthru argument actually was correctly reintroduced in
setupDriverForTest, but the actual makeTest function didn't use it.

This fixes the nixpkgs tarball job, which previously failed with:

  attribute 'elkPackages' missing, at /build/source/pkgs/tools/misc/logstash/6.x.nix:58:30

Signed-off-by: aszlig <aszlig@nix.build>
Acked-by: David Arnold <dar@xoe.solutions>
Fixes: https://github.com/NixOS/nixpkgs/issues/127274
Merges: https://github.com/NixOS/nixpkgs/pull/127346
2021-06-18 14:50:15 +02:00
jakobrs
7a0c1728ac nixos/lib: Handle null device correctly 2021-06-18 08:32:45 +02:00
Jacek Galowicz
a6d8488c58
Merge pull request #125973 from blaggacao/nixos-test-ref/02-normalise-test-driver-nix-expressions
nixos test ref/02 normalise test driver nix expressions
2021-06-16 18:59:23 +02:00
Kim Lindberger
26706834a5
Merge pull request #86967 from jakobrs/more-general-fsbefore
nixos/lib/utils: Add `fileSystems.<name>.depends` option and generalise fsBefore (fixes #86955)
2021-06-14 10:50:07 +02:00
David Arnold
3884ff70ba
nixos/tests/test-driver: cleanup nix expression
Less nesting, where that improves readability. More nesteing, where
that improves readability, but most importantly:

Expose individual functions separately so that they can be more easily
built directly, eg.:

`nix build --impure --expr '(import ./testing-python.nix {system = builtins.currentSystem;}).mkTestDriver'`
2021-06-13 15:47:51 -05:00
jakobrs
b07602a604 nixos/lib, nixos/filesystems: Make fsBefore more stable, and add depends option 2021-06-08 18:51:31 +02:00
David Arnold
03bfa29891
nixos/tests/test-driver: cleanup "dead" code (USE_SERIAL)
At nixpkgs root:

`rg redirectSerial ./` does not result in any other match
nor does
`rg USE_SERIAL ./` except for an unrelated match in:

pkgs/tools/graphics/argyllcms/default.nix
2021-06-06 12:58:58 -05:00
talyz
b7749c7671
nixos/test-driver: Run commands with error handling
Bash's standard behavior of not propagating non-zero exit codes
through a pipeline is unexpected and almost universally
unwanted. Default to setting `pipefail` for the command being run;
it can still be turned off by prefixing the pipeline with
`set +o pipefail` if needed.

Also, set `errexit` and `nonunset` options to make the first command
of consecutive commands separated by `;` fail, and disallow
dereferencing unset variables respectively.
2021-06-05 18:44:42 +02:00
Frederik Rietdijk
3edde6562e make-test-python: disallow aliases
When importing Nixpkgs within Nixpkgs, we should not consider aliases
to ensure we don't rely on them internally.

There are probably more places that need to be converted.
2021-06-03 11:03:31 -07:00
Domen Kožar
f88be6e55c
Merge pull request #125372 from Synthetica9/shell_interact
nixos/tests/test-driver: add shell_interact
2021-06-03 11:46:01 +02:00
Patrick Hilhorst
fd739c4dee
nixos/tests/test-driver: make it clear when shell is ready
Co-authored-by: Domen Kožar <domen@enlambda.com>
2021-06-03 11:20:26 +02:00
Patrick Hilhorst
9469433e34
nixos/tests/test-driver: document shell_interact 2021-06-02 14:49:59 +02:00
Patrick Hilhorst
5a589b5ba8
nixos/tests/test-driver: add shell_interact 2021-06-02 14:20:04 +02:00
Damien Diederen
7c2adb1d5c nixos/lib/make-ext4-fs: Fix: `resize2fs -M' can leave insufficient slack
The root filesystem resizing step, `resize2fs -M', does not provide any
control over the amount of slack left in the result.  It can produce an
arbitrarily tight fit, depending on how well the payload aligns with
ext4 data structures.

This is problematic, as NixOS must create a few files and directories
during its first boot, before the root is enlarged to match the size of
the containing SD card.

An overly tight fit can cause failures in the first stage:

    mkdir: can't create directory '/mnt-root/proc': No space left on device

or in the second stage:

    install: cannot create directory '/var': No space left on device

A previous version of `make-ext4-fs' (before PR #79368) was explicitly
"reserving" 16 MiB of free space in the final filesystem.  Manually
calculating the size of an ext4 filesystem is a perilous endeavor,
however, and the method it employed was apparently unreliable.

Reverting is consequently not a good option.

A solution would be to create some sort of "balloon" occupying inodes
and blocks in the image prior to invoking `resize2fs -M', and to remove
these temporary files/directories before the compression step.

This changeset takes the simpler approach of simply dropping the
resizing step.

Note that this does *not* result in a larger image in general, as the
current procedure does not truncate the `.img' file anyway.  In fact, it
has been observed to yield *smaller* compressed images---probably
because of some "noise" left after resizing.  E.g., before-vs-after:

    -r--r--r-- 2 root root 607M  1. Jan 1970  nixos-sd-image-21.11pre-git-x86_64-linux.img.zst

    -r--r--r-- 2 root root 606M  1. Jan 1970  nixos-sd-image-21.11pre-git-x86_64-linux.img.zst
2021-05-31 21:35:51 +02:00
Andreas Rammhold
d07f52bf81
nixos/test-driver: mention the elapsed time when it times out
For now you had to know that the actions are retried for 900s when
seeing an error like

> Traceback (most recent call last):
>   File "/nix/store/dbvmxk60sv87xsxm7kwzzjm7a4fhgy6y-nixos-test-driver/bin/.nixos-test-driver-wrapped", line 927, in run_tests
>     exec(tests, globals())
>   File "<string>", line 1, in <module>
>   File "<string>", line 31, in <module>
>   File "/nix/store/dbvmxk60sv87xsxm7kwzzjm7a4fhgy6y-nixos-test-driver/bin/.nixos-test-driver-wrapped", line 565, in wait_for_file
>     retry(check_file)
>   File "/nix/store/dbvmxk60sv87xsxm7kwzzjm7a4fhgy6y-nixos-test-driver/bin/.nixos-test-driver-wrapped", line 142, in retry
>     raise Exception("action timed out")
> Exception: action timed out

in your (hydra) build failure. Due to the absence of timestamps you were
left guessing if the machine was just slow, someone passed a low timeout
value (which they couldn't until now) or whatever might have happened.

By making this error a bit more descriptive (by including the elapsed
time) these hopefully become more useful.
2021-05-30 17:26:13 +02:00
Jacek Galowicz
5d05391846
Merge pull request #123823 from misuzu/test-driver-usb-boot-speedup
nixos/test-driver: use usb-ehci controller instead of piix3-usb-uhci
2021-05-21 20:47:47 +02:00
misuzu
b2319b086c nixos/test-driver: use usb-ehci controller instead of piix3-usb-uhci
On my system this change offers ~5X speed up of
nixosTests.boot.biosUsb and nixosTests.boot.uefiUsb tests.
2021-05-20 22:33:08 +03:00
Robert Hensing
a37d157601
Merge pull request #123052 from xoe-labs/da-test-vm-innteractive-log-switch
nixos/testing: add interactive serial stdout logs switch and dim them
2021-05-20 15:32:54 +02:00
Robert Hensing
76a7840f5f
Merge pull request #117275 from hercules-ci/nixosTest-remove-nixpkgs-commit-hash
nixosTest: Make system.nixos.revision constant
2021-05-20 10:40:59 +02:00
David Arnold
8ee31be5dd
nixos/testing: add interactive serial stdout logs switch and dim them 2021-05-14 20:36:00 -04:00
Robert Hensing
75c4fc1c8b nixos/testing-python.nix: Move makeWrapper to nativeBuildInputs 2021-05-09 03:04:03 +02:00
Robert Hensing
56d9637119
nixos/testing: Set up scope for testScript linter
Our test driver exposes a bunch of variables and functions, which
pyflakes doesn't recognise by default because it assumes that the test
script is executed standalone. In reality however the test driver script
is using exec() on the testScript.

Fortunately pyflakes has $PYFLAKES_BUILTINS, which are the attributes
that are globally available on all modules to be checked. Since we only
have one module, using this environment variable is fine as opposed to
my first approach to this, which tried to use the unstable internal API
of pyflakes.

The attributes are gathered by the main derivation of the test driver,
because we don't want to end up defining a new attribute in the test
driver module just to being confused why using it in a test will result
in an error.

Another way we could have gathered these attributes would be in
mkDriver, which is where the linting takes place. However, we do have a
different set of Python dependencies in scope and duplicating these will
again just cause confusion over having it at one location only.

Signed-off-by: aszlig <aszlig@nix.build>
Co-Authored-By: aszlig <aszlig@nix.build>
2021-05-09 02:26:51 +02:00
Robert Hensing
71087b2bc4
nixos/testing-python.nix: Expose driver
(cherry picked from commit a2c9220568648b4528154ebd8e657add243ed0b4)
2021-05-09 02:26:40 +02:00
aszlig
c362a28fcf
nixos/testing: Switch from black to pyflakes
So far, we have used "black" for formatting the test code, which is
rather strict and opinionated and when used inline in Nix expressions it
creates all sorts of trouble.

One of the main annoyances is that when using strings coming from Nix
expressions (eg. store paths or option definitions from NixOS modules),
completely unrelated changes could cause tests to fail, since eg. black
wants lines to be broken.

Another downside of enforcing a certain kind of formatting is that it
makes the Nix expression code inconsistent because we're mixing two
spaces of indentation (common in nixpkgs) with four spaces of
indentation as defined in PEP-8. While this is perfectly fine for
standalone Python files, it really looks ugly and inconsistent IMO when
used within Nix strings.

What we actually want though is a linter that catches problems early on
before actually running the test, because this is *actually* helping in
development because running the actual VM test takes much longer.

This is the reason why I switched from black to pyflakes, because the
latter actually has useful checks, eg. usage of undefined variables,
invalid format arguments, duplicate arguments, shadowed loop vars and
more.

Signed-off-by: aszlig <aszlig@nix.build>
Closes: https://github.com/NixOS/nixpkgs/issues/72964
2021-05-09 02:26:37 +02:00
Michael Weiss
3c1a76611e
nixos/test-driver: Allow interactive testing on Wayland-only setups
On my system I have XWayland disabled and therefore only WAYLAND_DISPLAY
is set. This ensures that the graphical output will still be enabled on
such setups (both Wayland and X11 are supported by the viewer).
2021-05-04 16:23:02 +02:00
Robert Hensing
162b8fba12 testing-python.nix: document runTests pos argument 2021-05-03 13:33:41 +02:00
Robert Hensing
b2f44e9aeb
Merge pull request #112504 from hercules-ci/fix-nixosTest-meta-position
nixosTest: fix meta.position
2021-05-03 11:50:57 +02:00
Alyssa Ross
a8afbb45c1 treewide: use lib.warnIf where appropriate 2021-04-28 21:44:21 +00:00
Lassulus
ee04d772e4
Merge pull request #120489 from samueldr/fix/make-disk-image-auto-size
Fix make disk image automatic size
2021-04-26 10:34:15 +02:00
Lassulus
cdddbf59ea
Merge pull request #120251 from mschwaig/fix-make-disk-image-for-efi-2
make-disk-image: fix broken EFI image builds
2021-04-26 10:04:00 +02:00
Martin Schwaighofer
f20ae954d5 make-disk-image: fix broken EFI image builds
Work around missing /dev files inside runInLinuxVM by creating a
symlink before calling nixos-enter.

This fixes https://github.com/NixOS/nixpkgs/issues/93381.
I ran into this issue when trying to create a VMware image that boots from EFI.

Thanks @colemickens for reporting this and @danielfullmer for fixing the same thing in in qemu-vm.nix (37676e77cb) and explaining what the issue was.
2021-04-26 01:12:10 +02:00