Commit graph

1203 commits

Author SHA1 Message Date
Robert Hensing d20a574948 Revert "systemd: Add functions.escapeSystemdExecArg[s]"
This reverts commit 121c0d9efad7cf74ccc70ce3e69763e9a8822f3b.
2025-07-20 03:01:07 +02:00
Robert Hensing b915f0c5c0 systemd: Add functions.escapeSystemdExecArg[s]
This makes it available outside the NixOS `utils` context.
2025-07-20 03:01:05 +02:00
Maximilian Bosch b4b7218254
nixos/testing: enable ssh backdoor by default if debug hook is enabled
You usually want both, so it makes sense to have the former imply the
latter. If this is not desired, it can still be modified within a test.
2025-07-18 17:39:03 +02:00
Jacek Galowicz d6b326d659
test-driver: Implement debugging breakpoint hooks
Co-authored-by: Maximilian Bosch <maximilian@mbosch.me>
2025-07-18 17:39:01 +02:00
Philip Taron 8279ffe622
treewide: specify that mebibytes are used when it's ambiguous (#424169) 2025-07-11 12:29:33 -07:00
Axel Karjalainen 7159ab6f43 treewide: specify where mebibytes are used when it's ambiguous 2025-07-11 00:44:23 +03:00
Wolfgang Walther f965d36fa1
nixos/lib/test-driver: correct regex in pythonize_name() (#423064) 2025-07-09 16:01:27 +00:00
Robert Hensing 0e32661202 nixos/testing: Add test attribute to please discoverTests 2025-07-07 22:23:55 +02:00
Michael Daniels 98b97a2011
nixos/lib/test-driver: correct regex in pythonize_name()
r"[A-z]" is not equivalent to r"[A-Za-z]"; it is equivalent to r"[A-Z[]^_`a-z]".
But Python variable names cannot contain, e.g., a backtick.
So the current regex is wrong.
2025-07-06 21:09:36 -04:00
Robert Hensing 7845abc842
NixOS test framework: add overriding methods (#421480) 2025-07-06 13:40:24 +02:00
Robert Hensing f2b3aeb383 nixos.runTest: Add extendNixOS 2025-07-06 13:39:15 +02:00
Robert Hensing 63e2606ddf nixos.runTest: Add extend, overrideTestDerivation 2025-07-06 13:39:15 +02:00
Yarny0 5e2baf54d4 nixos/test-driver: fix race from filename clash in OCR
There is a race condition
in the new paralleized OCR code.
The race condition got "active" in commit
819d304a39 (Use futures for OCR parallelization),
however, the underlying bug already slipped in with commit
e6ea13f4ea (User proper `Path` instead of `str` in OCR code).

The OCR module applies tesseract to at most three variants
of the screenshot: the original one, and two variants that
are created by a preprocessing step (with ImageMagick).
The preprocessing step needs an output filename
that is used to write the preprocessed image file.

The "Path" commit broke the way the output file is named:
The code still attempts to append a ".negative" to *one*
of the preprocessed output files, but the method
`.with_suffix` is not suitable for that purpose:
Lateron, ".png" is also added with `.with_suffix`,
*replacing* the ".negative" and thereby yielding the
*the same* output filename for both preprocessed files.

Without parallelization, this doesn't hurt;
preprocessed files are simply created and analyzed in order.
But the parallelization commit
causes that these two tasks now run in parallel
(plus the third task that analyses the original screensshot,
but that does not cause any further harm here):

* Task 1: preprocess (non-negative), then tesseract the output
* Task 2: preprocess (negative), then tesseract the output

Both tasks use the same filename and thus the same file for the
preprocessed image that is generated, then used by tesseract.
This often creates a garbage file since both
preprocessings write that one file at the same time.
Tesseract consequently fails and
complains about bad data in its input file.

The commit at hand simply fixes the file naming
by adding ".negative.png" or ".positive.png"
to the filename for the preprocessed image.
This ensures both threads no longer hurt each
other's data and can now coexist in peace.
2025-07-04 12:10:53 +02:00
Jacek Galowicz 3a670480d1
nixos/lib/test-driver: try using XDG_RUNTIME_DIR if available (#414231) 2025-07-02 16:11:44 +02:00
Jacek Galowicz 26bcb57f3c test-driver: fix number of cores 2025-07-02 13:59:15 +00:00
Maximilian Bosch 59b4d0de90
nixos/lib/test-driver: try using XDG_RUNTIME_DIR if available
At work we have the use-case that several people connect to a large
Linux box to run tests and debug those interactively.

All tests write their state into a global `/tmp` -- e.g. the vde1 socket
and the VMs' state. This leads to conflicts when multiple people are
doing this.

This change tries to use XDG_RUNTIME_DIR before using Python's detection
of a global temp directory: when connecting, this requires a working
user session, but then we get working directories per user. This is
preferable over doing something like `mktemp -d` per run since that
would break use-cases where you want to keep the VMs' state across
multiple sessions (`--keep-vm-state`).
2025-07-02 15:53:12 +02:00
Jacek Galowicz 819d304a39 test-driver: Use futures for OCR parallelization 2025-07-02 11:43:13 +00:00
Jacek Galowicz e6ea13f4ea test-driver: User proper Path instead of str in OCR code 2025-07-01 14:18:41 +02:00
Jacek Galowicz f56933ebbf test-driver: drop OCR engine mode variations 2025-07-01 14:18:40 +02:00
Jacek Galowicz 14c01b5af5 test-driver: Parallelize OCR 2025-07-01 14:18:40 +02:00
Jacek Galowicz 9f10c9bce8 test-driver: Factor out OCR related code to machine/ocr.py 2025-07-01 14:18:40 +02:00
Jacek Galowicz 2c8500b91d test-driver: Move machine code into its own python module folder 2025-07-01 14:18:40 +02:00
John Titor c87464cb0c
Revert "treewide: migrate nixos modules to networking.hosts"
This reverts commit cd64f1bd87.
2025-06-09 00:10:05 +05:30
John Titor 7c873c2d00
Revert "nixos/lib/testing: fix network module"
This reverts commit 35fb55d21b.
2025-06-08 23:54:55 +05:30
John Titor 4a842aed37 nixos/lib/testing: fix network module
This fixes acme tests.

Signed-off-by: John Titor <50095635+JohnRTitor@users.noreply.github.com>
2025-06-08 16:12:54 +05:30
John Titor cd64f1bd87 treewide: migrate nixos modules to networking.hosts
Signed-off-by: John Titor <50095635+JohnRTitor@users.noreply.github.com>
2025-06-07 23:09:46 +05:30
Pol Dellaiera 6d9d3014ba
treewide: fix typos in comments (#413240) 2025-06-02 18:43:07 +02:00
Peder Bergebakken Sundt c77ac9dfc3 treewide: fix typos 2025-06-02 16:07:07 +02:00
Johannes Kirschbauer 46be72d315
nixos/unitOption: remove unnecessary definition filtering 2025-05-30 22:39:51 +02:00
Jörg Thalheim 4420d42422 nixos: make squashfs reproducible 2025-05-30 11:34:05 +05:30
sanana c156a809e3 nixosTests.limine.bios: init
This patch adds a NixOS test for Limine on BIOS systems. It also fixes
some formatting in `nixos/lib/make-disk-image.nix`.

Signed-off-by: John Titor <50095635+JohnRTitor@users.noreply.github.com>
2025-05-26 14:06:42 +05:30
sanana 11ed9936cc nixos/make-disk-image: support partition layout "legacy+boot"
This patch adds a new partition layout type `"legacy+boot` which will
produce MBR images with a separate FAT32 boot partition. This is
necessary for adding a NixOS test for Limine on BIOS systems, as Limine
can't read ext4 partitions.
2025-05-26 14:06:42 +05:30
Robert Hensing eed414caf1
Fix running NixOS tests on darwin (#405599) 2025-05-15 09:47:30 +02:00
Maximilian Bosch c6978e8a58
nixos/test-driver: exit early if /dev/vhost-vsock isn't available
Right now it wrongly seems as if you can set
`sshBackdoor.enable = true;` for each test and not only for debugging
purposes.

This is wrong however since you'd need to pass /dev/vhost-vsock into the
sandbox for this (which is also a prerequisite for #392117).

To make that clear, two things were changed:

* add a warning to the manual to communicate this.
* exit both interactive and non-interactive driver early if
  /dev/vhost-vsock is missing and the ssh backdoor is enabled.

  If that's the case, we pass a CLI flag to the driver already in the
  interactive case. This change also sets the flag for the
  non-interactive case.

  That way we also get a better error if somebody tries to enable this
  on a system that doesn't support that.
2025-05-13 11:14:13 +02:00
Jacek Galowicz 08ed87ccc6
nixos/test-driver: allow assigning other vsock number ranges (#405508) 2025-05-11 13:24:41 +02:00
Maximilian Bosch b8b86834b7
nixos/test-driver: move sshBackdoor cfg from test-instrumentation to driver
That way, we don't need to duplicate the sshBackdoor options on NixOS-level.

Suggested-by: Jacek Galowicz <jacek@galowicz.de>
2025-05-10 10:40:35 +02:00
Maximilian Bosch 12c544e008
nixos/testing: improve wording of vsockOffset description
Co-authored-by: Jacek Galowicz <jacek@galowicz.de>
2025-05-10 10:28:44 +02:00
Florian Klink 9cc7df71a7
nixos/lib: fix typo in documentation for systemd (#405675) 2025-05-09 21:39:44 +03:00
squat 8f6b1ac340
nixos/lib: fix typo in documentation for systemd
This commit fixes a small typo in the documentation for the
`asDropinIfExists` option and clarifies the comment.

Signed-off-by: squat <lserven@gmail.com>
2025-05-09 20:25:34 +02:00
Robert Hensing ee83bfa879 nixos/testing: Drop darwin from default hydraPlatforms
Litmus test: the following attribute disappears

    nix eval -f pkgs/top-level/release.nix tests.testers.nixosTest-example.x86_64-darwin.outPath
2025-05-09 19:25:46 +02:00
Robert Hensing 0433bf6a90 nixos/testing/meta.nix: lib.mkOption -> mkOption 2025-05-09 16:27:05 +02:00
Robert Hensing 51d915e451 nixos/testing: Add meta.hydraPlatforms 2025-05-09 16:27:05 +02:00
Robert Hensing 18e2327aa7 Revert "nixos/lib/testing: avoid generating darwin VM tests"
This reverts commit 72155225aa.
2025-05-09 16:00:18 +02:00
Maximilian Bosch a9adfc631a
nixos/test-driver: allow assigning other vsock number ranges
I'm a little annoyed at myself that I only realized this _after_ #392030
got merged. But I realized that if something else is using AF_VSOCK or
you simply have another interactive test running (e.g. by another user
on a larger builder), starting up VMs in the driver fails with

    qemu-system-x86_64: -device vhost-vsock-pci,guest-cid=3: vhost-vsock: unable to set guest cid: Address already in use

Multi-user setups are broken anyways because you usually don't have
permissions to remove the VM state from another user and thus starting
the driver fails with

    PermissionError: [Errno 13] Permission denied: PosixPath('/tmp/vm-state-machine')

but this is something you can work around at least.

I was considering to generate random offsets, but that's not feasible
given we need to know the numbers at eval time to inject them into the
QEMU args. Also, while we could do this via the test-driver, we should
also probe if the vsock numbers are unused making the code even more
complex for a use-case I consider rather uncommon.

Hence the solution is to do

    sshBackdoor.vsockOffset = 23542;

when encountering conflicts.
2025-05-09 11:54:00 +02:00
Jacek Galowicz 8b3baa1402
nixos/test-driver: add backdoor based on systemd-ssh-proxy & AF_VSOCK (#392030) 2025-05-09 08:03:55 +02:00
Maximilian Bosch 8869265f93
nixos/test-driver: printout instructions on how to connect via AF_VSOCK 2025-05-08 10:51:39 +02:00
Paul Haerle 86a1af8a7b
nixos/systemd: clarify what enableStrictShellChecks checks (#401460) 2025-04-27 14:15:15 +02:00
Vladimír Čunát 1a41b5c78e
nixos/lib/testing: avoid generating darwin VM tests (#393977) 2025-04-27 09:29:26 +02:00
Maximilian Bosch b1394ba443
nixos/test-driver: improve wording of the enable option of SSH backdoor
Co-authored-by: Ryan Lahfa <masterancpp@gmail.com>
2025-04-26 12:20:10 +02:00
Maximilian Bosch 1bd8073958
nixos/test-driver: add backdoor based on systemd-ssh-proxy & AF_VSOCK
With this it's possible to trivially SSH into running machines from the
test-driver. This is especially useful when running VM tests
interactively on a remote system.

This is based on `systemd-ssh-proxy(1)`, so there's no need to configure
any additional networking on the host-side.

Suggested-by: Ryan Lahfa <masterancpp@gmail.com>
2025-04-26 11:35:47 +02:00