From abe218950c779fd1c98034356d3b324d66a0d30a Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Mon, 14 Apr 2014 14:02:44 +0200 Subject: [PATCH] Make it easier to run the tests You can now run a test in the nixos/tests directory directly using nix-build, e.g. $ nix-build '' -A test This gets rid of having to add the test to nixos/tests/default.nix. (Of course, you still need to add it to nixos/release.nix if you want Hydra to run the test.) --- nixos/lib/testing.nix | 4 ++- nixos/release.nix | 50 ++++++++++++++++++++++++------- nixos/tests/avahi.nix | 6 ++-- nixos/tests/bittorrent.nix | 4 +-- nixos/tests/containers.nix | 4 +-- nixos/tests/default.nix | 46 ---------------------------- nixos/tests/firefox.nix | 6 ++-- nixos/tests/firewall.nix | 4 +-- nixos/tests/gnome3.nix | 4 +-- nixos/tests/installer.nix | 31 +++++++++---------- nixos/tests/ipv6.nix | 4 +-- nixos/tests/jenkins.nix | 4 +-- nixos/tests/kde4.nix | 6 ++-- nixos/tests/kexec.nix | 4 +-- nixos/tests/login.nix | 9 ++++-- nixos/tests/logstash.nix | 11 ++++--- nixos/tests/misc.nix | 4 +-- nixos/tests/mpich.nix | 6 +--- nixos/tests/mumble.nix | 4 +-- nixos/tests/munin.nix | 13 ++++---- nixos/tests/mysql-replication.nix | 5 ++-- nixos/tests/mysql.nix | 3 +- nixos/tests/nat.nix | 4 +-- nixos/tests/nfs.nix | 6 ++-- nixos/tests/openssh.nix | 5 ++-- nixos/tests/partition.nix | 4 +-- nixos/tests/printing.nix | 6 ++-- nixos/tests/proxy.nix | 4 +-- nixos/tests/quake3.nix | 4 +-- nixos/tests/rabbitmq.nix | 9 +++--- nixos/tests/run-in-machine.nix | 8 +++-- nixos/tests/simple.nix | 4 +-- nixos/tests/subversion.nix | 4 +-- nixos/tests/tomcat.nix | 4 +-- nixos/tests/trac.nix | 5 ++-- nixos/tests/udisks.nix | 4 +-- nixos/tests/xfce.nix | 4 +-- 37 files changed, 132 insertions(+), 175 deletions(-) delete mode 100644 nixos/tests/default.nix diff --git a/nixos/lib/testing.nix b/nixos/lib/testing.nix index d5338bc04cac..02d865895fbb 100644 --- a/nixos/lib/testing.nix +++ b/nixos/lib/testing.nix @@ -73,7 +73,7 @@ rec { apply = makeTest; # compatibility call = f: f { inherit pkgs system; }; - complete = { testScript, ... } @ t: t // rec { + complete = { testScript, makeCoverageReport ? false, ... } @ t: t // rec { nodes = buildVirtualNetwork ( t.nodes or (if t ? machine then { machine = t.machine; } else { })); @@ -117,6 +117,8 @@ rec { test = runTests driver; report = releaseTools.gcovReport { coverageRuns = [ test ]; }; + + result = if makeCoverageReport then report else test; }; diff --git a/nixos/release.nix b/nixos/release.nix index b98976c2ccea..7465488ae167 100644 --- a/nixos/release.nix +++ b/nixos/release.nix @@ -14,6 +14,8 @@ let forAllSystems = pkgs.lib.genAttrs systems; + callTest = fn: args: forAllSystems (system: (import fn ({ inherit system; } // args)).result); + pkgs = import nixpkgs { system = "x86_64-linux"; }; lib = pkgs.lib; @@ -207,14 +209,42 @@ in rec { */ - # Run the tests in ./tests/default.nix for each platform. You can - # run a test by doing e.g. "nix-build -A tests.login.x86_64-linux". - tests = - with lib; - let - testsFor = system: - mapAttrsRecursiveCond (x: !x ? test) - (n: v: listToAttrs [(nameValuePair system (if v.makeCoverageReport or false then v.report else v.test))]) - (import ./tests { inherit nixpkgs system; }); - in fold recursiveUpdate {} (map testsFor systems); + # Run the tests for each platform. You can run a test by doing + # e.g. ‘nix-build -A tests.login.x86_64-linux’, or equivalently, + # ‘nix-build tests/login.nix -A result’. + tests.avahi = callTest tests/avahi.nix {}; + tests.bittorrent = callTest tests/bittorrent.nix {}; + tests.containers = callTest tests/containers.nix {}; + tests.firefox = callTest tests/firefox.nix {}; + tests.firewall = callTest tests/firewall.nix {}; + tests.gnome3 = callTest tests/gnome3.nix {}; + tests.installer.grub1 = forAllSystems (system: (import tests/installer.nix { inherit system; }).grub1.test); + tests.installer.lvm = forAllSystems (system: (import tests/installer.nix { inherit system; }).lvm.test); + tests.installer.rebuildCD = forAllSystems (system: (import tests/installer.nix { inherit system; }).rebuildCD.test); + tests.installer.separateBoot = forAllSystems (system: (import tests/installer.nix { inherit system; }).separateBoot.test); + tests.installer.simple = forAllSystems (system: (import tests/installer.nix { inherit system; }).simple.test); + tests.ipv6 = callTest tests/ipv6.nix {}; + tests.jenkins = callTest tests/jenkins.nix {}; + tests.kde4 = callTest tests/kde4.nix {}; + tests.latestKernel.login = callTest tests/login.nix { latestKernel = true; }; + tests.login = callTest tests/login.nix {}; + tests.logstash = callTest tests/logstash.nix {}; + tests.misc = callTest tests/misc.nix {}; + tests.mumble = callTest tests/mumble.nix {}; + tests.munin = callTest tests/munin.nix {}; + tests.mysql = callTest tests/mysql.nix {}; + tests.mysqlReplication = callTest tests/mysql-replication.nix {}; + tests.nat = callTest tests/nat.nix {}; + tests.nfs3 = callTest tests/nfs.nix { version = 3; }; + tests.openssh = callTest tests/openssh.nix {}; + tests.printing = callTest tests/printing.nix {}; + tests.proxy = callTest tests/proxy.nix {}; + tests.quake3 = callTest tests/quake3.nix {}; + tests.rabbitmq = callTest tests/rabbitmq.nix {}; + tests.runInMachine = callTest tests/run-in-machine.nix {}; + tests.simple = callTest tests/simple.nix {}; + tests.tomcat = callTest tests/tomcat.nix {}; + tests.udisks = callTest tests/udisks.nix {}; + tests.xfce = callTest tests/xfce.nix {}; + } diff --git a/nixos/tests/avahi.nix b/nixos/tests/avahi.nix index d95361dcd83d..4091e7ece501 100644 --- a/nixos/tests/avahi.nix +++ b/nixos/tests/avahi.nix @@ -1,8 +1,7 @@ -{ pkgs, ... }: +# Test whether `avahi-daemon' and `libnss-mdns' work as expected. -with pkgs; +import ./make-test.nix { -{ nodes = { one = { config, pkgs, ... }: { @@ -17,7 +16,6 @@ with pkgs; }; }; - # Test whether `avahi-daemon' and `libnss-mdns' work as expected. testScript = '' startAll; diff --git a/nixos/tests/bittorrent.nix b/nixos/tests/bittorrent.nix index f84b65699d36..2604d1ffc925 100644 --- a/nixos/tests/bittorrent.nix +++ b/nixos/tests/bittorrent.nix @@ -6,7 +6,7 @@ # which only works if the first client successfully uses the UPnP-IGD # protocol to poke a hole in the NAT. -{ pkgs, ... }: +import ./make-test.nix ({ pkgs, ... }: let @@ -108,4 +108,4 @@ in $client2->succeed("cmp /tmp/test.tar.bz2 ${file}"); ''; -} +}) diff --git a/nixos/tests/containers.nix b/nixos/tests/containers.nix index 06b793ed7ac1..9580f18189a2 100644 --- a/nixos/tests/containers.nix +++ b/nixos/tests/containers.nix @@ -1,8 +1,6 @@ # Test for NixOS' container support. -{ pkgs, ... }: - -{ +import ./make-test.nix { machine = { config, pkgs, ... }: diff --git a/nixos/tests/default.nix b/nixos/tests/default.nix deleted file mode 100644 index d2eb6a999628..000000000000 --- a/nixos/tests/default.nix +++ /dev/null @@ -1,46 +0,0 @@ -{ nixpkgs ? -, system ? builtins.currentSystem -, minimal ? false -}: - -with import ../lib/testing.nix { inherit system minimal; }; - -{ - avahi = makeTest (import ./avahi.nix); - bittorrent = makeTest (import ./bittorrent.nix); - containers = makeTest (import ./containers.nix); - firefox = makeTest (import ./firefox.nix); - firewall = makeTest (import ./firewall.nix); - installer = makeTests (import ./installer.nix); - efi-installer = makeTests (import ./efi-installer.nix); - gnome3 = makeTest (import ./gnome3.nix); - ipv6 = makeTest (import ./ipv6.nix); - jenkins = makeTest (import ./jenkins.nix); - kde4 = makeTest (import ./kde4.nix); - #kexec = makeTest (import ./kexec.nix); - login = makeTest (import ./login.nix {}); - logstash = makeTest (import ./logstash.nix); - latestKernel.login = makeTest (import ./login.nix ({ config, pkgs, ... }: { boot.kernelPackages = pkgs.linuxPackages_latest; })); - misc = makeTest (import ./misc.nix); - #mpich = makeTest (import ./mpich.nix); - mysql = makeTest (import ./mysql.nix); - mysql_replication = makeTest (import ./mysql-replication.nix); - munin = makeTest (import ./munin.nix); - mumble = makeTest (import ./mumble.nix); - nat = makeTest (import ./nat.nix); - nfs3 = makeTest (import ./nfs.nix { version = 3; }); - #nfs4 = makeTest (import ./nfs.nix { version = 4; }); - openssh = makeTest (import ./openssh.nix); - #partition = makeTest (import ./partition.nix); - printing = makeTest (import ./printing.nix); - proxy = makeTest (import ./proxy.nix); - quake3 = makeTest (import ./quake3.nix); - rabbitmq = makeTest (import ./rabbitmq.nix); - simple = makeTest (import ./simple.nix); - #subversion = makeTest (import ./subversion.nix); - tomcat = makeTest (import ./tomcat.nix); - udisks = makeTest (import ./udisks.nix); - #trac = makeTest (import ./trac.nix); - xfce = makeTest (import ./xfce.nix); - runInMachine.test = import ./run-in-machine.nix { inherit system; }; -} diff --git a/nixos/tests/firefox.nix b/nixos/tests/firefox.nix index d6599be13c9e..b42d473b8025 100644 --- a/nixos/tests/firefox.nix +++ b/nixos/tests/firefox.nix @@ -1,6 +1,4 @@ -{ pkgs, ... }: - -{ +import ./make-test.nix ({ pkgs, ... }: { machine = { config, pkgs, ... }: @@ -18,4 +16,4 @@ $machine->screenshot("screen"); ''; -} +}) diff --git a/nixos/tests/firewall.nix b/nixos/tests/firewall.nix index 15653dedf3ca..d10e10b1d91c 100644 --- a/nixos/tests/firewall.nix +++ b/nixos/tests/firewall.nix @@ -1,8 +1,6 @@ # Test the firewall module. -{ pkgs, ... }: - -{ +import ./make-test.nix { nodes = { walled = diff --git a/nixos/tests/gnome3.nix b/nixos/tests/gnome3.nix index 98a76137842e..f1a6ce633313 100644 --- a/nixos/tests/gnome3.nix +++ b/nixos/tests/gnome3.nix @@ -1,6 +1,4 @@ -{ pkgs, ... }: - -{ +import ./make-test.nix { machine = { config, pkgs, ... }: diff --git a/nixos/tests/installer.nix b/nixos/tests/installer.nix index b0c0aa328f00..aebaba918111 100644 --- a/nixos/tests/installer.nix +++ b/nixos/tests/installer.nix @@ -1,7 +1,8 @@ -{ pkgs, system, ... }: +{ system ? builtins.currentSystem }: -with pkgs.lib; +with import ../lib/testing.nix { inherit system; }; with import ../lib/qemu-flags.nix; +with pkgs.lib; let @@ -99,7 +100,7 @@ let my $machine = createMachine({ hda => "harddisk", hdaInterface => "${iface}", cdrom => glob("${iso}/iso/*.iso"), - qemuFlags => '${optionalString testChannel (toString (qemuNICFlags 1 1 2))} ${optionalString (pkgs.stdenv.system == "x86_64-linux") "-cpu kvm64"}'}); + qemuFlags => '${optionalString testChannel (toString (qemuNICFlags 1 1 2))} ${optionalString (iso.system == "x86_64-linux") "-cpu kvm64"}'}); $machine->start; ${optionalString testChannel '' @@ -190,13 +191,15 @@ let ''; - makeTest = { createPartitions, fileSystems, testChannel ? false, grubVersion ? 2, grubDevice ? "/dev/vda" }: - { inherit iso; + makeInstallerTest = + { createPartitions, fileSystems, testChannel ? false, grubVersion ? 2, grubDevice ? "/dev/vda" }: + makeTest ({ ... }: { + inherit iso; nodes = if testChannel then { inherit webserver; } else { }; testScript = testScriptFun { inherit createPartitions fileSystems testChannel grubVersion grubDevice; }; - }; + }); in { @@ -206,7 +209,7 @@ in { # The (almost) simplest partitioning scheme: a swap partition and # one big filesystem partition. - simple = makeTest + simple = makeInstallerTest { createPartitions = '' $machine->succeed( @@ -225,7 +228,7 @@ in { }; # Same as the previous, but now with a separate /boot partition. - separateBoot = makeTest + separateBoot = makeInstallerTest { createPartitions = '' $machine->succeed( @@ -248,7 +251,7 @@ in { # Create two physical LVM partitions combined into one volume group # that contains the logical swap and root partitions. - lvm = makeTest + lvm = makeInstallerTest { createPartitions = '' $machine->succeed( @@ -271,8 +274,7 @@ in { fileSystems = rootFS; }; - /* - swraid = makeTest + swraid = makeInstallerTest { createPartitions = '' $machine->succeed( @@ -304,10 +306,9 @@ in { ''; fileSystems = rootFS + bootFS; }; - */ # Test a basic install using GRUB 1. - grub1 = makeTest + grub1 = makeInstallerTest { createPartitions = '' $machine->succeed( @@ -328,7 +329,7 @@ in { }; # Rebuild the CD configuration with a little modification. - rebuildCD = + rebuildCD = makeTest ({ ... }: { inherit iso; nodes = { }; testScript = @@ -352,5 +353,5 @@ in { $machine->shutdown; ''; - }; + }); } diff --git a/nixos/tests/ipv6.nix b/nixos/tests/ipv6.nix index 48c20d7f5c92..eb15363d3c32 100644 --- a/nixos/tests/ipv6.nix +++ b/nixos/tests/ipv6.nix @@ -1,9 +1,7 @@ # Test of IPv6 functionality in NixOS, including whether router # solicication/advertisement using radvd works. -{ pkgs, ... }: - -{ +import ./make-test.nix { nodes = { client = { config, pkgs, ... }: { }; diff --git a/nixos/tests/jenkins.nix b/nixos/tests/jenkins.nix index 402234827914..9d3f76ca3e15 100644 --- a/nixos/tests/jenkins.nix +++ b/nixos/tests/jenkins.nix @@ -2,9 +2,9 @@ # 1. jenkins service starts on master node # 2. jenkins user can be extended on both master and slave # 3. jenkins service not started on slave node -{ pkgs, ... }: -{ +import ./make-test.nix { + nodes = { master = diff --git a/nixos/tests/kde4.nix b/nixos/tests/kde4.nix index 3fb35bbab098..725759ab758a 100644 --- a/nixos/tests/kde4.nix +++ b/nixos/tests/kde4.nix @@ -1,6 +1,4 @@ -{ pkgs, ... }: - -{ +import ./make-test.nix ({ pkgs, ... }: { machine = { config, pkgs, ... }: @@ -64,4 +62,4 @@ $machine->screenshot("screen"); ''; -} +}) diff --git a/nixos/tests/kexec.nix b/nixos/tests/kexec.nix index b8da332b919b..b09287682c01 100644 --- a/nixos/tests/kexec.nix +++ b/nixos/tests/kexec.nix @@ -1,8 +1,6 @@ # Test whether fast reboots via kexec work. -{ pkgs, ... }: - -{ +import ./make-test.nix { machine = { config, pkgs, ... }: { virtualisation.vlans = [ ]; }; diff --git a/nixos/tests/login.nix b/nixos/tests/login.nix index ed7d97867179..0a7d25c37aca 100644 --- a/nixos/tests/login.nix +++ b/nixos/tests/login.nix @@ -1,8 +1,11 @@ -config: { pkgs, ... }: +import ./make-test.nix ({ pkgs, latestKernel ? false, ... }: { - machine = config; + machine = + { config, pkgs, lib, ... }: + { boot.kernelPackages = lib.mkIf latestKernel pkgs.linuxPackages_latest; + }; testScript = '' @@ -58,4 +61,4 @@ config: { pkgs, ... }: }; ''; -} +}) diff --git a/nixos/tests/logstash.nix b/nixos/tests/logstash.nix index ee309d39f872..e6aba7a10126 100644 --- a/nixos/tests/logstash.nix +++ b/nixos/tests/logstash.nix @@ -1,9 +1,8 @@ -{ pkgs, ... }: +# This test runs logstash and checks if messages flows and +# elasticsearch is started. -# This test runs logstash and checks if messages flows and elasticsearch is -# started +import ./make-test.nix { -{ nodes = { one = { config, pkgs, ... }: @@ -28,10 +27,10 @@ }; }; }; - + testScript = '' startAll; - + $one->waitForUnit("logstash.service"); $one->waitUntilSucceeds("journalctl -n 20 _SYSTEMD_UNIT=logstash.service | grep flowers"); $one->fail("journalctl -n 20 _SYSTEMD_UNIT=logstash.service | grep dragons"); diff --git a/nixos/tests/misc.nix b/nixos/tests/misc.nix index d355d705a24c..0f57b9f61261 100644 --- a/nixos/tests/misc.nix +++ b/nixos/tests/misc.nix @@ -1,8 +1,6 @@ # Miscellaneous small tests that don't warrant their own VM run. -{ pkgs, ... }: - -{ +import ./make-test.nix { machine = { config, pkgs, ... }: diff --git a/nixos/tests/mpich.nix b/nixos/tests/mpich.nix index d57512ebdfed..13cd0960d07c 100644 --- a/nixos/tests/mpich.nix +++ b/nixos/tests/mpich.nix @@ -1,10 +1,6 @@ # Simple example to showcase distributed tests using NixOS VMs. -{ pkgs, ... }: - -with pkgs; - -{ +import ./make-test.nix { nodes = { master = { config, pkgs, ... }: { diff --git a/nixos/tests/mumble.nix b/nixos/tests/mumble.nix index 10658eb5f02a..8896830b0c22 100644 --- a/nixos/tests/mumble.nix +++ b/nixos/tests/mumble.nix @@ -1,4 +1,4 @@ -{ pkgs, ... }: +import ./make-test.nix ( let client = { config, pkgs, ... }: { @@ -52,4 +52,4 @@ in $client1->screenshot("screen1"); $client2->screenshot("screen2"); ''; -} +}) diff --git a/nixos/tests/munin.nix b/nixos/tests/munin.nix index 66ae1c0d87f7..acc4b949ab57 100644 --- a/nixos/tests/munin.nix +++ b/nixos/tests/munin.nix @@ -1,13 +1,12 @@ -{ pkgs, ... }: - # This test runs basic munin setup with node and cron job running on the same # machine. -{ - nodes = { +import ./make-test.nix { + + nodes = { one = { config, pkgs, ... }: - { + { services = { munin-node.enable = true; munin-cron = { @@ -20,10 +19,10 @@ }; }; }; - + testScript = '' startAll; - + $one->waitForUnit("munin-node.service"); $one->waitForFile("/var/lib/munin/one/one-uptime-uptime-g.rrd"); $one->waitForFile("/var/www/munin/one/index.html"); diff --git a/nixos/tests/mysql-replication.nix b/nixos/tests/mysql-replication.nix index 44586322600d..7d0cf6d85a1a 100644 --- a/nixos/tests/mysql-replication.nix +++ b/nixos/tests/mysql-replication.nix @@ -1,9 +1,10 @@ -{ pkgs, ... }: +import ./make-test.nix ( let replicateUser = "replicate"; replicatePassword = "secret"; in + { nodes = { master = @@ -58,4 +59,4 @@ in $slave2->sleep(100); # Hopefully this is long enough!! $slave2->succeed("echo 'use testdb; select * from tests' | mysql -u root -N | grep 4"); ''; -} +}) diff --git a/nixos/tests/mysql.nix b/nixos/tests/mysql.nix index bceeb8beabc2..566d03baf367 100644 --- a/nixos/tests/mysql.nix +++ b/nixos/tests/mysql.nix @@ -1,6 +1,5 @@ -{ pkgs, ... }: +import ./make-test.nix { -{ nodes = { master = { pkgs, config, ... }: diff --git a/nixos/tests/nat.nix b/nixos/tests/nat.nix index 259ab99d3016..02981469e106 100644 --- a/nixos/tests/nat.nix +++ b/nixos/tests/nat.nix @@ -4,9 +4,7 @@ # router connected to both that performs Network Address Translation # for the client. -{ pkgs, ... }: - -{ +import ./make-test.nix { nodes = { client = diff --git a/nixos/tests/nfs.nix b/nixos/tests/nfs.nix index 7bc99aef3b5e..864d05626b67 100644 --- a/nixos/tests/nfs.nix +++ b/nixos/tests/nfs.nix @@ -1,6 +1,4 @@ -{ version }: - -{ pkgs, ... }: +import ./make-test.nix ({ version, ... }: let @@ -84,4 +82,4 @@ in die "shutdown took too long ($duration seconds)" if $duration > 30; ''; -} +}) diff --git a/nixos/tests/openssh.nix b/nixos/tests/openssh.nix index 49d92fbde908..0b9714c275da 100644 --- a/nixos/tests/openssh.nix +++ b/nixos/tests/openssh.nix @@ -1,6 +1,5 @@ -{ pkgs, ... }: +import ./make-test.nix ({ pkgs, ... }: { -{ nodes = { server = @@ -35,4 +34,4 @@ $client->succeed("ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no server 'echo hello world' >&2"); $client->succeed("ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no server 'ulimit -l' | grep 1024"); ''; -} +}) diff --git a/nixos/tests/partition.nix b/nixos/tests/partition.nix index 7126e7255ef4..309afa4ce9d0 100644 --- a/nixos/tests/partition.nix +++ b/nixos/tests/partition.nix @@ -1,4 +1,4 @@ -{ pkgs, system, ... }: +import ./make-test.nix ({ pkgs, ... }: with pkgs.lib; @@ -224,4 +224,4 @@ in { ensureMountPoint("/mnt/boot"); }; ''; -} +}) diff --git a/nixos/tests/printing.nix b/nixos/tests/printing.nix index b5ca0f25e21c..9ef28dcfcd4d 100644 --- a/nixos/tests/printing.nix +++ b/nixos/tests/printing.nix @@ -1,8 +1,6 @@ # Test printing via CUPS. -{ pkgs, ... }: - -{ +import ./make-test.nix ({pkgs, ... }: { nodes = { @@ -88,4 +86,4 @@ } ''; -} +}) diff --git a/nixos/tests/proxy.nix b/nixos/tests/proxy.nix index dd64ca02e169..88dbdb2720fb 100644 --- a/nixos/tests/proxy.nix +++ b/nixos/tests/proxy.nix @@ -1,4 +1,4 @@ -{ pkgs, ... }: +import ./make-test.nix ( let @@ -90,4 +90,4 @@ in $client->succeed("curl --fail http://proxy/"); ''; -} +}) diff --git a/nixos/tests/quake3.nix b/nixos/tests/quake3.nix index 2ebac84ca06b..3ff12fd57c06 100644 --- a/nixos/tests/quake3.nix +++ b/nixos/tests/quake3.nix @@ -1,4 +1,4 @@ -{ pkgs, ... }: +import ./make-test.nix ( let @@ -79,4 +79,4 @@ rec { $server->stopJob("quake3-server"); ''; -} +}) diff --git a/nixos/tests/rabbitmq.nix b/nixos/tests/rabbitmq.nix index 271661f06820..ffcdde9d87f2 100644 --- a/nixos/tests/rabbitmq.nix +++ b/nixos/tests/rabbitmq.nix @@ -1,8 +1,7 @@ -{ pkgs, ... }: +# This test runs rabbitmq and checks if rabbitmq is up and running. -# This test runs rabbitmq and checks if rabbitmq is up and running +import ./make-test.nix ({ pkgs, ... }: { -{ nodes = { one = { config, pkgs, ... }: { services.rabbitmq.enable = true; @@ -11,8 +10,8 @@ testScript = '' startAll; - + $one->waitForUnit("rabbitmq.service"); $one->waitUntilSucceeds("su -s ${pkgs.stdenv.shell} rabbitmq -c \"rabbitmqctl status\""); ''; -} +}) diff --git a/nixos/tests/run-in-machine.nix b/nixos/tests/run-in-machine.nix index 8efe26c17082..7f6e6a6dc573 100644 --- a/nixos/tests/run-in-machine.nix +++ b/nixos/tests/run-in-machine.nix @@ -2,7 +2,9 @@ with import ../lib/testing.nix { inherit system; }; -runInMachine { - drv = pkgs.patchelf; - machine = { config, pkgs, ... }: { services.sshd.enable = true; }; +{ + test = runInMachine { + drv = pkgs.hello; + machine = { config, pkgs, ... }: { /* services.sshd.enable = true; */ }; + }; } diff --git a/nixos/tests/simple.nix b/nixos/tests/simple.nix index eee13a101334..e21b919cdf80 100644 --- a/nixos/tests/simple.nix +++ b/nixos/tests/simple.nix @@ -1,11 +1,11 @@ -{ pkgs, ... }: +import ./make-test.nix { -{ machine = { config, pkgs, ... }: { }; testScript = '' startAll; + $machine->waitForUnit("multi-user.target"); $machine->shutdown; ''; } diff --git a/nixos/tests/subversion.nix b/nixos/tests/subversion.nix index 49450c78f3b8..e6746dc08287 100644 --- a/nixos/tests/subversion.nix +++ b/nixos/tests/subversion.nix @@ -1,4 +1,4 @@ -{ pkgs, ... }: +import ./make-test.nix ( let @@ -114,4 +114,4 @@ in $webserver->stopJob("httpd"); ''; -} +}) diff --git a/nixos/tests/tomcat.nix b/nixos/tests/tomcat.nix index 6ec21a721924..3b0b1bb79117 100644 --- a/nixos/tests/tomcat.nix +++ b/nixos/tests/tomcat.nix @@ -1,6 +1,5 @@ -{ pkgs, ... }: +import ./make-test.nix { -{ nodes = { server = { pkgs, config, ... }: @@ -25,4 +24,5 @@ $client->succeed("curl --fail http://server/examples/servlets/servlet/HelloWorldExample"); $client->succeed("curl --fail http://server/examples/jsp/jsp2/simpletag/hello.jsp"); ''; + } diff --git a/nixos/tests/trac.nix b/nixos/tests/trac.nix index e0d256f57019..3f17dafaca15 100644 --- a/nixos/tests/trac.nix +++ b/nixos/tests/trac.nix @@ -1,6 +1,5 @@ -{ pkgs, ... }: +import ./make-test.nix ({ pkgs, ... }: { -{ nodes = { storage = { config, pkgs, ... }: @@ -68,4 +67,4 @@ $client->screenshot("screen"); ''; -} +}) diff --git a/nixos/tests/udisks.nix b/nixos/tests/udisks.nix index e3e3f740d07b..2354c3106618 100644 --- a/nixos/tests/udisks.nix +++ b/nixos/tests/udisks.nix @@ -1,4 +1,4 @@ -{ pkgs, ... }: +import ./make-test.nix ({ pkgs, ... }: let @@ -53,4 +53,4 @@ in $machine->fail("[ -e /dev/sda ]"); ''; -} \ No newline at end of file +}) diff --git a/nixos/tests/xfce.nix b/nixos/tests/xfce.nix index 50ce54c918b2..ded37943e51d 100644 --- a/nixos/tests/xfce.nix +++ b/nixos/tests/xfce.nix @@ -1,6 +1,4 @@ -{ pkgs, ... }: - -{ +import ./make-test.nix { machine = { config, pkgs, ... }: