Demos / Section 1: Live demos
Free

1.1 NixOS integration tests: whole networks of VMs on your laptop

Lesson 1 of 3 · 22:06

placeholder thumbnail

Create a free account to watch this lesson

Free account · no credit card needed

About this lesson

A NixOS integration test starts several virtual machines, puts them on networks, runs a script across all of them, and destroys them again. It happens inside a build sandbox, on the same laptop you write code on, and it happens identically on your CI because it is the same derivation. This demo is a tour of the NixOS test driver: what it can do, and what it feels like to work with.

In this video

  • Two machines and one small file: the shortest NixOS integration test there is, and what the grey and green lines in the log are telling you
  • Booting both VMs, waiting for the network and pinging: how many seconds that costs, and the one word you swap to make it several times faster
  • Interactive mode: the machines pop up on your desktop and you get a Python prompt to drive them by hand while you are still figuring out what to test
  • A graphical test that starts Firefox, waits for a page to appear and checks what is on it, without ever touching the browser from inside
  • A BitTorrent test with two clients, a tracker and a router doing NAT: a whole home network in roughly 50 lines, and a firewall that opens a port for itself while the test runs

After this lesson

You can tell whether your own end to end tests belong in this and roughly what moving them would cost. You also know where the thousand or so existing tests live, which is the best place to steal from before writing your first one.

Links: