summary refs log tree commit diff
path: root/nixos/lib/testing-python.nix
AgeCommit message (Collapse)AuthorFilesLines
2022-11-11nixos/lib/testing-python: remove unused `with pkgs;`Andreas Rammhold1-3/+0
This with statement has no users anymore and can safely be removed.
2022-10-16nixos/tests: Generalize nix-build file.nix hack to testing-python.nixRobert Hensing1-2/+8
2022-09-29nixos/testing: Fix release.nix tests evaluationRobert Hensing1-2/+2
Fixes the problem introduced by 12b3066aae46a8ccc3d21f54f668a3f4be344332 which caused nixos/release.nix to return the wrong attributes, while intending to only affect nixos/lib's runTest. This also removes callTest from the test options, because callTest is only ever invoked by all-tests.nix.
2022-09-24nixos/testing-python: Add interactive variant support to makeTestRobert Hensing1-0/+1
2022-09-24nixos/testing: Embrace callTestRobert Hensing1-1/+0
My conception of its input was wrong. It is quite a useful construct, even if its name is a bit weird.
2022-09-24testing-python.nix: Replace makeTest implementationRobert Hensing1-232/+10
2022-09-24nixos/testing: Move entrypoint to nixos/lib + docRobert Hensing1-20/+13
2022-09-21nixos/testing: Add pkgs parameterRobert Hensing1-0/+1
This parameter is for packages to use in VMs, unlike hostPkgs.
2022-09-21nixos/testing-python.nix: Add evalTestRobert Hensing1-0/+20
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 https://github.com/NixOS/nixpkgs/pull/144110 in testScript.nix. I might revert the latter and split it into a new commit.
2022-06-17nixos/test-driver: Support mypy through regular mechanismsRobert Hensing1-3/+1
2022-06-03Merge branch 'master' into ↵Robert Hensing1-6/+29
172325-nixostest-override-python-pkgs-additional-param
2022-06-03add opt out flag for type checkingMichael Schneider1-15/+19
2022-06-02nixos/test-driver: Typecheck TestScriptMichael Schneider1-3/+22
2022-05-29nixos/test-driver: add option to add extra python packages to test codetljuniper1-3/+5
2022-05-27nixos/testing-python.nix: fix typo in warningAlyssa Ross1-1/+1
"pyton" -> "python"
2022-05-05nixos/testing-python.nix: Set meta.mainProgramRobert Hensing1-0/+1
2022-03-28nixosTest: Simplify doc by deprecating syntax sugarRobert Hensing1-0/+1
2022-03-19fixup! nixos/testing: restrict arguments to makeTestNaïm Favier1-6/+1
2022-03-18nixos/testing: restrict arguments to makeTestNaïm Favier1-12/+15
Disallow passing arbitrary arguments to makeTest since they are not used; this can help catch mistakes.
2022-01-26nixos/testing-python: actually copy build artefactsPatrick Hilhorst1-1/+1
This broke in #156858.
2022-01-26use lib.optionalStringMarijan Petričević1-1/+1
2022-01-26nixos/tests: fix #146169Marijan Petričević1-1/+4
2022-01-04nixos/test-driver: also passthru driverInteractivePatrick Hilhorst1-3/+3
2021-12-10nixos/test-driver: make the test-driver a python packageMarijan Petričević1-62/+11
2021-11-19test-driver.py: always export single machine as 'machine'Patrick Hilhorst1-1/+3
2021-10-31nixosTest: Fix infinite recursion involving hasContext testScript when ↵Robert Hensing1-1/+12
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 329a4461a7a1898b3aad13968a232a054422c4fb from https://github.com/NixOS/nixpkgs/pull/140792
2021-10-28nixos/testing-python: Copy test script derivations to nodestalyz1-0/+19
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-07Merge pull request #126713 from ↵Jacek Galowicz1-9/+2
blaggacao/nixos-test-ref/05-class-ify-test-driver nixos test ref/05 class ify test driver
2021-10-05nixos/test/test-driver: Class-ify the test driverDavid Arnold1-9/+2
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-09-18nixos/lib/qemu-flags: rename to qemu-commonrnhmjoj1-2/+1
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-08nixos/testing: remove unused function runInMachineMatthew Kenigsberg1-96/+9
runInMachine and runInMachineWithX are not used for any tests and can be removed
2021-08-19nixos/tests/test-driver: better control test env symbolsDavid Arnold1-1/+3
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-13nixos/testing: only create `nixos-run-vms` for `nixos-build-vms(8)`Maximilian Bosch1-5/+7
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-12nixos/testing: re-add nixos-run-vms scriptMaximilian Bosch1-0/+6
Originally removed in 926fb9396881202e727e5ec1fbf609b64455b388. This one is actually quite useful for `nixos-build-vms(8)`.
2021-08-08Merge pull request #125979 from ↵lewo1-11/+12
blaggacao/nixos-test-ref/03-normalse-the-python-entrypoint nixos/test-driver: normalize the python entrypoint
2021-08-05nixos/tests/test-driver: normalise test driver entrypoint(s)David Arnold1-11/+12
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-07-28nixos/testing: fix invalid node names detectionDavid Arnold1-2/+7
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-06-22nixos/test-driver: replace termlib with socatJörg Thalheim1-1/+1
telnetlib does not handle unicode, which is annoying when using systemctl. Also this gives us a nice readline with history.
2021-06-18nixos/test-driver: Fix passing passthru attributeaszlig1-2/+2
Apparently this looks like it was forgotten when doing commit 3884ff70badca0c93c717e6190946a9a2846e948, 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-13nixos/tests/test-driver: cleanup nix expressionDavid Arnold1-122/+135
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-06nixos/tests/test-driver: cleanup "dead" code (USE_SERIAL)David Arnold1-2/+1
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-03make-test-python: disallow aliasesFrederik Rietdijk1-1/+7
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-05-14nixos/testing: add interactive serial stdout logs switch and dim themDavid Arnold1-1/+1
2021-05-09nixos/testing-python.nix: Move makeWrapper to nativeBuildInputsRobert Hensing1-1/+1
2021-05-09nixos/testing: Set up scope for testScript linterRobert Hensing1-1/+16
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-09nixos/testing-python.nix: Expose driverRobert Hensing1-1/+3
(cherry picked from commit a2c9220568648b4528154ebd8e657add243ed0b4)
2021-05-09nixos/testing: Switch from black to pyflakesaszlig1-1/+1
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-03testing-python.nix: document runTests pos argumentRobert Hensing1-2/+7
2021-05-03Merge pull request #112504 from hercules-ci/fix-nixosTest-meta-positionRobert Hensing1-2/+9
nixosTest: fix meta.position
2021-04-28treewide: use lib.warnIf where appropriateAlyssa Ross1-3/+1