4 ms·
Another fascinating thing about NixOS is their system of automated integration tests for the whole distribution. You can quite easily set up declarative virtual
by mbrock 8y ago
Another fascinating thing about NixOS is their system of automated integration tests for the whole distribution. You can quite easily set up declarative virtual machines with Nix expressions, and the test suites use this in very cool ways.
Graham Christensen mentions some of these tests here: https://grahamc.com/blog/an-epyc-nixos-build-farm https://grahamc.com/blog/an-epyc-nixos-build-farm
> The NixOS release process is novel in that package updates happen automatically as an entire cohesive set. We of course test that specific software compiles properly, but we are also able to perform fully automatic integration tests. We test that the operating system can boot, desktop environments work, and even server tests like validating that our MySQL server replication is still working. These tests happen automatically on every release and is a unique benefit to the Nix build system being applied to an operating system.
> These tests use QEMU and KVM, and spawn one or more virtual machines running NixOS.
He goes on to describe
(1) the KDE desktop test that boots a real graphical environment and uses scripted OCR to detect activity;
(2) the MySQL replication test that verifies correct replication between three separate MySQL servers on three separate virtual machines; and
(3) a BitTorrent test that starts four virtual machines—namely one tracker with Apache serving a torrent file, one NAT router with UPnP (!), two peers of which one is routed through the NAT—and verifies the full process of peer 1 downloading from the seeder and peer 2 downloading from peer 1.
Those tests can all run automatically on a build server for every commit to the package tree... it's quite something!
The whole BitTorrent test is a 116-line Nix expression that's eminently pleasant to read: https://github.com/NixOS/nixpkgs/blob/49a6964a4250d98644da61f24dcc11ee0b28c4f9/nixos/tests/bittorrent.nix https://github.com/NixOS/nixpkgs/blob/49a6964a4250d98644da61...