Commit graph

1181 commits

Author SHA1 Message Date
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
Jacek Galowicz
d0c304d4c1
nixos/test-driver: improve error reporting and assertions (#390996) 2025-04-26 10:26:01 +02:00
Scott Edlund
02555cd0bd nixos/systemd: clarify what enableStrictShellChecks checks
the specifics of this option are in the release notes, but bring
them into the documentation.
2025-04-26 01:46:12 +08:00
Aleksana
64f024b81e
treewide: drop copumpkin from maintainers (#392486) 2025-04-18 19:00:51 +08:00
Silvan Mosberger
374e6bcc40 treewide: Format all Nix files
Format all Nix files using the officially approved formatter,
making the CI check introduced in the previous commit succeed:

  nix-build ci -A fmt.check

This is the next step of the of the [implementation](https://github.com/NixOS/nixfmt/issues/153)
of the accepted [RFC 166](https://github.com/NixOS/rfcs/pull/166).

This commit will lead to merge conflicts for a number of PRs,
up to an estimated ~1100 (~33%) among the PRs with activity in the past 2
months, but that should be lower than what it would be without the previous
[partial treewide format](https://github.com/NixOS/nixpkgs/pull/322537).

Merge conflicts caused by this commit can now automatically be resolved while rebasing using the
[auto-rebase script](8616af08d9/maintainers/scripts/auto-rebase).

If you run into any problems regarding any of this, please reach out to the
[formatting team](https://nixos.org/community/teams/formatting/) by
pinging @NixOS/nix-formatting.
2025-04-01 20:10:43 +02:00
Vladimír Čunát
72155225aa
nixos/lib/testing: avoid generating darwin VM tests
We're getting 2x5 darwin VM jobs that aren't schedulable
on our current Hydra.nixos.org, which makes them hang around
and delay advancing of all `nixpkgs-*` channels.
To me that's quite an annoying effect, as it can be like an extra day
of additional delay without any benefit that I can really perceive.
(unless someone like me keeps manually cancelling the jobs all the time)
2025-03-29 19:32:31 +01:00
phaer
c60ace300b make-disk-image: Add note about re-factoring plans in #324817
This replaces an older note by @copumpkin about the (stale) issue
maintainer-list.
2025-03-23 20:07:15 +01:00
phaer
b349e80087 treewide: drop copumpkin from maintainers
Their last commit is from March 28th 2019, about 6 years ago.

This PR is in no way intended to diminish Daniels's accomplishments, and they're welcome to just say so if they'd prefer this PR not to be merged. Also, even if it's merged, of course they're always welcome to return to activity and be added back. The intent of this PR is to give more realistic expectations around the maintainership of these packages, and to invite others to step up for maintainership if they rely on those packages.

If this is merged, they should probably also be removed from the list
of committers for the time being.
2025-03-23 20:07:15 +01:00
Maximilian Bosch
deff22bcc8
nixos/test-driver: improve wording on comments about new error handling
Co-authored-by: Benoit de Chezelles <bew@users.noreply.github.com>
2025-03-22 19:13:48 +01:00
Maximilian Bosch
e2b3517f59
nixos/test-driver: use ipython via ptpython
Closes #180089

I realized that the previous commits relying on `sys.exit` for dealing
with `MachineError`/`RequestedAssertionFailed` exit the interactive
session which is kinda bad.

This patch uses the ipython driver: it seems to have equivalent features
such as auto-completion and doesn't stop on SystemExit being raised.

This also fixes other places where this happened such as things calling
`log.error` on the CompositeLogger.
2025-03-21 12:34:59 +00:00
Maximilian Bosch
d587d569e0
nixos/test-driver: restructure error classes
After a discussion with tfc, we agreed that we need a distinction
between errors where the user isn't at fault (e.g. OCR failing - now
called `MachineError`) and errors where the test actually failed (now
called `RequestedAssertionFailed`).

Both get special treatment from the error handler, i.e. a `!!!` prefix
to make it easier to spot visually.

However, only `RequestedAssertionFailed` gets the shortening of the
traceback, `MachineError` exceptions may be something to report and
maintainers usually want to see the full trace.

Suggested-by: Jacek Galowicz <jacek@galowicz.de>
2025-03-21 11:38:01 +00:00
Jacek Galowicz
482beabbbd NixOS Test driver: Display Qemu windows on macOS in interactive mode 2025-03-20 15:40:02 +00:00
Maximilian Bosch
cc3d409adc
nixos/test-driver: log associated machine for self.nested
When doing `machine.succeed(...)` or something similar, it's now clear
that the command `...` was issued on `machine`.

Essentially, this results in the following diff in the log:

    -(finished: waiting for unit default.target, in 13.47 seconds)
    +machine: (finished: waiting for unit default.target, in 13.47 seconds)
    (finished: subtest: foobar text lorem ipsum, in 13.47 seconds)
2025-03-20 13:20:51 +00:00
Maximilian Bosch
11ff96a679
nixos/test-driver: use RequestedAssertionFailed/TestScriptError in Machine class
I think it's reasonable to also have this kind of visual distinction
here between test failures and actual errors from the test framework.

A failing `machine.require_unit_state` now lookgs like this for
instance:

    !!! Traceback (most recent call last):
    !!!   File "<string>", line 3, in <module>
    !!!     machine.require_unit_state("postgresql","active")
    !!!
    !!! RequestedAssertionFailed: Expected unit 'postgresql' to to be in state 'active' but it is in state 'inactive'

Co-authored-by: Benoit de Chezelles <bew@users.noreply.github.com>
2025-03-20 13:20:37 +00:00
Maximilian Bosch
a1dfaf51e2
nixos/test-driver: integrate Python unittest assertions
Replaces / Closes #345948

I tried to integrate `pytest` assertions because I like the reporting,
but I only managed to get the very basic thing and even that was messing
around a lot with its internals.

The approach in #345948 shifts too much maintenance effort to us, so
it's not really desirable either.

After discussing with Benoit on Ocean Sprint about this, we decided that
it's probably the best compromise to integrate `unittest`: it also
provides good diffs when needed, but the downside is that existing tests
don't benefit from it.

This patch essentially does the following things:

* Add a new global `t` that is an instance of a `unittest.TestCase`
  class. I decided to just go for `t` given that e.g.
  `tester.assertEqual` (or any other longer name) seems quite verbose.

* Use a special class for errors that get special treatment:
  * The traceback is minimized to only include frames from the
    testScript: in this case I don't really care about anything else and
    IMHO that's just visual noise.

    This is not the case for other exceptions since these may indicate a
    bug and then people should be able to send the full traceback to the
    maintainers.
  * Display the error, but with `!!!` as prefix to make sure it's
    easier to spot in between other logs.

This looks e.g. like

    !!! Traceback (most recent call last):
    !!!   File "<string>", line 7, in <module>
    !!!     foo()
    !!!   File "<string>", line 5, in foo
    !!!     t.assertEqual({"foo":[1,2,{"foo":"bar"}]},{"foo":[1,2,{"bar":"foo"}],"bar":[1,2,3,4,"foo"]})
    !!!
    !!! NixOSAssertionError: {'foo': [1, 2, {'foo': 'bar'}]} != {'foo': [1, 2, {'bar': 'foo'}], 'bar': [1, 2, 3, 4, 'foo']}
    !!! - {'foo': [1, 2, {'foo': 'bar'}]}
    !!! + {'bar': [1, 2, 3, 4, 'foo'], 'foo': [1, 2, {'bar': 'foo'}]}
    cleanup
    kill machine (pid 9)
    qemu-system-x86_64: terminating on signal 15 from pid 6 (/nix/store/wz0j2zi02rvnjiz37nn28h3gfdq61svz-python3-3.12.9/bin/python3.12)
    kill vlan (pid 7)
    (finished: cleanup, in 0.00 seconds)

Co-authored-by: bew <bew@users.noreply.github.com>
2025-03-20 12:30:58 +00:00
K900
58edd1e2ac
nixos/docs: fix typo (#372394) 2025-02-10 13:47:45 +03:00
andle
0149ffd511
fix(utils): remove unnecessary $ from variable in arithmetic 2025-02-08 23:07:10 -05:00
Wolfgang Walther
d16aa077d2
nixos/lib/make-*-disk-zfs-image: fix build
Those two helpers have not received the memo about a new requirement for
virtiofs and about changes regarding the zfs related attributes.

Can be tested with nix/release.nix' amazonImageZfs.
2025-02-02 21:51:07 +01:00
OPNA2608
fa984fd7aa nixos/lib/test-driver: Revert magick args order
...as it apparently matters when we do the -negate
2025-01-22 14:59:35 +01:00
K900
5b434ed807 nixos/lib/test-driver: try more OCR options
The current setup is really weird and definitely wrong for many cases
because it inverts the colors of the image, which is never a good idea
for GUIs. So, try to OCR three different times: once on the source image,
once with processing, and once with processing but no negation.

This should hopefully make things work at least somewhat better for GUIs.
2025-01-21 14:16:04 +03:00
K900
4b5b5d19d2
nixos/test-driver: fix OCR (#375091) 2025-01-19 21:01:53 +03:00
Victor Engmark
8f2bc9842e
nixos/test-driver: Use consistent naming and types
Specifies the "last try" parameter in all methods called by `retry`.
Doing this clarifies its presence, and makes it easier to use it in the
future if needed.
2025-01-19 17:59:13 +01:00
K900
84b216c2a6 nixos/test-driver: fix OCR
I don't know why it doesn't want to do TIFF now, but there's also
absolutely no reason for it to be TIFF anyway, so let's just use
an image format that is actually sane.
2025-01-19 18:41:58 +03:00