Skip to content

Comments

nixosTest: make modular#191540

Merged
roberth merged 38 commits intoNixOS:masterfrom
hercules-ci:nixosTest-modular
Sep 28, 2022
Merged

nixosTest: make modular#191540
roberth merged 38 commits intoNixOS:masterfrom
hercules-ci:nixosTest-modular

Conversation

@roberth
Copy link
Member

@roberth roberth commented Sep 16, 2022

Why

Closes #171396

What
  • Move testing-python.nix logic and build-vms.nix logic into modules
  • Rewrite the node numbering logic
  • Write docs

Extracted from #176557

Hydra: 4299c17 https://hydra.nixos.org/eval/1781169?compare=1780016

First nixos-unstable: https://hydra.nixos.org/eval/1782482

"removed" attributes

  • ec2: meta.broken now applies to test runner
  • fcitx: meta.broken now applies to test runner
  • gocd-agent: meta.broken now applies to test runner
  • hadoop: rename the attr path to include system
  • hocker-fetchdocker: meta.broken now applies to test runner
  • installed-tests.xdg-desktop-portal: meta.broken now applies to test runner
  • mariadb, mysql: now runs on both system types, changing the attr path
  • pulseaudio: now runs on both system types, changing the attr path
  • shadowsocks: now runs on both system types, changing the attr path
  • zigbee2mqtt: name has already been added in master. merge will fix this.
Things done
  • Built on platform(s)
    • x86_64-linux
    • aarch64-linux
    • x86_64-darwin
    • aarch64-darwin
  • For non-Linux: Is sandbox = true set in nix.conf? (See Nix manual)
  • Tested, as applicable:
  • Tested compilation of all packages that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD". Note: all changes have to be committed, also see nixpkgs-review usage
  • Tested basic functionality of all binary files (usually in ./result/bin/)
  • 22.11 Release Notes (or backporting 22.05 Release notes)
    • (Package updates) Added a release notes entry if the change is major or breaking
    • (Module updates) Added a release notes entry if the change is significant
    • (Module addition) Added a release notes entry if adding a new NixOS module
    • (Release notes changes) Ran nixos/doc/manual/md-to-db.sh to update generated release notes
  • Fits CONTRIBUTING.md.

@github-actions github-actions bot added 6.topic: nixos Issues or PRs affecting NixOS modules, or package usability issues specific to NixOS 8.has: documentation This PR adds or changes documentation 8.has: module (update) This PR changes an existing module in `nixos/` labels Sep 16, 2022
@ofborg ofborg bot added the 2.status: merge conflict This PR has merge conflicts with the target branch label Sep 16, 2022
@ofborg ofborg bot added 8.has: clean-up This PR removes packages or removes other cruft 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin. 10.rebuild-linux: 1-10 This PR causes between 1 and 10 packages to rebuild on Linux. and removed 2.status: merge conflict This PR has merge conflicts with the target branch labels Sep 16, 2022
@roberth roberth force-pushed the nixosTest-modular branch 5 times, most recently from 4299c17 to 7ab4c0f Compare September 18, 2022 22:03
@roberth
Copy link
Member Author

roberth commented Sep 19, 2022

Ofborg ran out of disk space.

@ofborg eval

This is a decomposition of the testing-python.nix and build-vms.nix
files into modules.

By refactoring the glue, we accomplish the following:

 - NixOS tests can now use `imports` and other module system features.
    - Network-wide test setup can now be reusable; example:
       - A setup with all VMs configured to use a DNS server
       - Split long, slow tests into multiple tests that import a
         common module that has most of the setup.
    - Type checking for the test arguments
    - (TBD) "generated" options reference docs
 - Aspects that had to be wired through all the glue are now in their
   own files.
    - Chief example: interactive.nix.
    - Also: network.nix

In rewriting this, I've generally stuck as close as possible to the
existing code; copying pieces of logic and rewiring them, without
changing the logic itself.

I've made two exceptions to this rule

 - Introduction of `extraDriverArgs` instead of hardcoded
   interactivity logic.

 - Incorporation of NixOS#144110
   in testScript.nix.

I might revert the latter and split it into a new commit.
This parameter is for packages to use in VMs, unlike hostPkgs.
@bobby285271 bobby285271 removed the 12.approvals: 1 This PR was reviewed and approved by one person. label Sep 24, 2022
@roberth roberth merged commit 7f0d934 into NixOS:master Sep 28, 2022
roberth added a commit to hercules-ci/nixpkgs that referenced this pull request Sep 28, 2022
(NB: the lib in the flake)

Correcting a mistake I made when removing the test matrix code
from NixOS#191540
aszlig added a commit to openlab-aux/vuizvui that referenced this pull request Oct 3, 2022
Introduced by a recent change[1], all NixOS VM tests are evaluated using
the NixOS module system and with [2], makeTest doesn't return a
derivation anymore but the .config attribute of the module system
evaluation.

This however doesn't work very well when thrown into Hydra, which
traverses through all attributes recursively looking for derivations.

We had our fair share of OOMs on our Hydra evaluator and right now, some
jobsets are still getting evaluation timouts, one of them is due to the
fact that we use makeTest without returning the actual test derivation.

[1]: NixOS/nixpkgs#191540
[2]: NixOS/nixpkgs@aed1deab0574f663be2d401861b

Signed-off-by: aszlig <aszlig@nix.build>
@Atemu
Copy link
Member

Atemu commented May 16, 2023

This broke kernel passthru tests:

$ nix-instantiate -A linux.passthru.tests --system x86_64-linux --show-trace
error: attempt to call something which is not a function but a set

       at /Users/atemu/Projects/nixpkgs/pkgs/os-specific/linux/kernel/generic.nix:217:11:

          216|       };
          217|     in [ (nixosTests.kernel-generic.testsForKernel overridableKernel) ] ++ kernelTests;
             |           ^
          218|   };

@roberth
Copy link
Member Author

roberth commented May 16, 2023

The way both nixosTests and nixos/release.nix load and transform the tests is incredibly ad hoc and fragile.
It appears that nixosTests now tries to invoke the test according what we might call the standalone import ./make-test-python.nix pattern, considering that testsForLinuxPackages appears to receive { pkgs = ...; system = ...; } as its argument. Both discoverTests and handleTest pass these arguments, but perhaps discoverTests is at fault. I really can't tell though, because of all the "legacy" that this code needs to support.

Ideally we'd standardize the solution for both the test matrix "problem" and the package testing problem in one go. That could be #176557 or something similar.

@roberth
Copy link
Member Author

roberth commented May 16, 2023

Reading through the changes, e77913a may be the commit to blame, but reverting it is likely to break some other tests' glue.

Atemu added a commit to Atemu/nixpkgs that referenced this pull request Aug 6, 2023
NixOS#191540 indirectly broke kernel
passthru.tests; calling the testsForLinuxPackages and testsForKernel functions
with some args intended for some other exposed test-internal function.

Organise the passed-through functions under `passthru` to prevent this from
happening.
@Atemu Atemu mentioned this pull request Aug 6, 2023
12 tasks
github-actions bot pushed a commit that referenced this pull request Aug 8, 2023
#191540 indirectly broke kernel
passthru.tests; calling the testsForLinuxPackages and testsForKernel functions
with some args intended for some other exposed test-internal function.

Organise the passed-through functions under `passthru` to prevent this from
happening.

(cherry picked from commit a0dcabb)
CHN-beta pushed a commit to CHN-beta/nixpkgs that referenced this pull request Aug 26, 2023
partial revert of f371975

Revert "linuxManualConfig: restore functionality of isModular and buildDTBs"

This reverts commit 284d76e.

Revert "lib/systems: strip kernel to avoid reference cycles"

This reverts commit 2458c94.

Revert "linuxManualConfig: set badPlatforms"

This reverts commit 5c5e5e2.

Revert "linux.configfile: remove unused kernelTarget attr"

This reverts commit 01b3642.

Revert "linuxManualConfig: always depend on ubootTools"

This reverts commit e5e02f3.

Revert "linux: default stdenv.hostPlatform.linux-kernel"

This reverts commit febe477.

Revert "linux: manual-config: use a non-random path for $buildRoot"

This reverts commit a695425.

Revert "linuxManualConfig: fix inaccurate FIXME comment"

This reverts commit 4d15632.

Revert "linuxManualConfig: get rid of drvAttrs"

This reverts commit f521f46.

Revert "linuxManualConfig: install GDB scripts"

This reverts commit d57568f.

Revert "linuxManualConfig: use the default make target"

This reverts commit 41f788b.

Revert "linuxManualConfig: unpack directly into $dev"

This reverts commit 7de3f08.

Revert "linuxManualConfig: don't build inside source tree"

This reverts commit d75cff2.

kernel: fix passthru.tests

NixOS#191540 indirectly broke kernel
passthru.tests; calling the testsForLinuxPackages and testsForKernel functions
with some args intended for some other exposed test-internal function.

Organise the passed-through functions under `passthru` to prevent this from
happening.

linuxPackages_testing.perf: fix patchShebang

Without the change `perf` build fails as:

    $ nix build --no-link -f. linuxPackages_testing.perf -L

    build flags: SHELL=/nix/store/p6dlr3skfhxpyphipg2bqnj52999banh-bash-5.2-p15/bin/bash prefix=\$\(out\) WERROR=0 ASCIIDOC8=1 O=\$\(buildRoot\) CC=/nix/store/bxic6j2whyg3z4h2x3xjyqgp7fl83bnp-gcc-wrapper-12.3.0/bin/cc HOSTCC=/nix/store/bxic6j2whyg3z4h2x3xjyqgp7fl83bnp-gcc-wrapper-12.3.0/bin/cc HOSTLD=/nix/store/kcp78dk7h5gcs7d4qss7rbz3skxhzdnn-binutils-wrapper-2.40/bin/ld ARCH=x86_64 NO_GTK2=1
      BUILD:   Doing 'make -j16' parallel build
      HOSTCC  fixdep.o
      HOSTLD  fixdep-in.o
      LINK    fixdep
    make[1]: ./check-headers.sh: No such file or directory
    make[1]: *** [Makefile.perf:241: sub-make] Error 127
    make: *** [Makefile:70: all] Error 2

This started happening because upstream linux commit
    torvalds/linux@d674838
changed shebang from /bin/sh to /bin/bash.

Let's retroactively switch all `perf` releases to shell interpreter from
store.

linux: 4.14.320 -> 4.14.321

linux: 4.19.289 -> 4.19.290

linux: 5.10.188 -> 5.10.189

linux: 5.15.124 -> 5.15.125

linux: 5.4.251 -> 5.4.252

linux: 6.1.43 -> 6.1.44

linux: 6.4.8 -> 6.4.9

linux: disable KUnit (NixOS#247826)

linux_testing: 6.5-rc3 -> 6.5-rc5

rc5: https://lwn.net/Articles/940617/
rc4: https://lwn.net/Articles/939684/

linux: 4.14.321 -> 4.14.322

linux: 4.19.290 -> 4.19.291

linux: 5.10.189 -> 5.10.190

linux: 5.4.252 -> 5.4.253

linux: 6.1.44 -> 6.1.45

linux: 6.4.9 -> 6.4.10

linux-rt_5_15: 5.15.119-rt65 -> 5.15.125-rt66

linux: 5.15.125 -> 5.15.126

linux: disable KUNIT only at 5.5 and later

`KUNIT` knob was added around 5.5 release:
    torvalds/linux@914cc63

linux_xanmod: 6.1.43 -> 6.1.45

linux_xanmod_latest: 6.4.8 -> 6.4.10

linux: 4.14.322 -> 4.14.323

linux: 4.19.291 -> 4.19.292

linux: 5.10.190 -> 5.10.191

linux: 5.15.126 -> 5.15.127

linux: 5.4.253 -> 5.4.254

linux: 6.1.45 -> 6.1.46

linux: 6.4.10 -> 6.4.11

linux_latest-libre: 19337 -> 19386

linux/hardened/patches/4.14: 4.14.320-hardened1 -> 4.14.322-hardened1

linux/hardened/patches/4.19: 4.19.289-hardened1 -> 4.19.291-hardened1

linux/hardened/patches/5.10: 5.10.188-hardened1 -> 5.10.190-hardened1

linux/hardened/patches/5.15: 5.15.123-hardened1 -> 5.15.126-hardened1

linux/hardened/patches/5.4: 5.4.251-hardened1 -> 5.4.253-hardened1

linux/hardened/patches/6.1: 6.1.42-hardened1 -> 6.1.45-hardened1

linux/hardened/patches/6.4: 6.4.7-hardened1 -> 6.4.10-hardened1

linux_xanmod: 6.1.45 -> 6.1.46

linux_xanmod_latest: 6.4.10 -> 6.4.11

linux-rt_6_1: 6.1.33-rt11 -> 6.1.46-rt13

linux: make main update script slightly more robust

On NixOS#249636 I had to manually run the updaters for hardened & libre kernels.
The cause was that `update-rt.sh` suddenly broke. Because I didn't want to
inhibit other kernel updates because of a rather niche variant, I decided to
move forward temporarily and take care of it later.

One issue was that the script failed silently, i.e. I only saw that the
script terminated early from my prompt. This is fixed now by making each
niche kernel updater print its exit code code if it failed. Also, errors
are allowed, i.e. a broken `update-rt.sh` doesn't block
`hardened/update.py` etc..

The issue itself is rather simple. When I updated the kernels in NixOS#249636,
the sha256sums.asc for rt kernels[1] looked like this:

    199bbb0cdb97ead22732473b95c8b2e8da62dfd71bde2339163119fb537a2b7c  patch-6.1.38-rt13-rc1.patch.gz
    a1af54f6987e96de06cad0a3226c5b5a992b60df084a904b6b94ea247fb46027  patch-6.1.38-rt13-rc1.patch.xz
    7bb68561787e46e3c433d9b514373ce368d587ac459b91df41934e70280d008f  patches-6.1.38-rt13-rc1.tar.gz
    ee65336dd6ae0be398796e7b75291918811a23e10121dc09bd84b244b12402fa  patches-6.1.38-rt13-rc1.tar.xz

However, the script itself skips any RC versions of the realtime
patches, so no releases were usable and the script failed. It's probably
possible to use the overview over all releases instead[2], however
that'd complicate the script notably. Anyways, since RT kernels don't
bump to each patch-level release, I don't think it hurts too much if
such an update is slightly more delayed. However if we want to fix this, I'd prefer
this to be fixed by folks who care more about rt kernels than I do.

[1] https://kernel.org/pub/linux/kernel/projects/rt/6.1/sha256sums.asc
[2] https://mirrors.edge.kernel.org/pub/linux/kernel/projects/rt/6.1/older/sha256sums.asc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

6.topic: nixos Issues or PRs affecting NixOS modules, or package usability issues specific to NixOS 8.has: clean-up This PR removes packages or removes other cruft 8.has: documentation This PR adds or changes documentation 8.has: module (update) This PR changes an existing module in `nixos/` 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin. 10.rebuild-linux: 1-10 This PR causes between 1 and 10 packages to rebuild on Linux.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

nixosTest reusable test setup via module system

4 participants