diff options
author | Frederik Rietdijk <fridh@fridh.nl> | 2019-08-14 13:45:54 +0200 |
---|---|---|
committer | Frederik Rietdijk <fridh@fridh.nl> | 2019-08-14 13:45:54 +0200 |
commit | 8d56f2472e47a3f1f388b69c0ecc24421910d555 (patch) | |
tree | 6eabee7471ed3f7395156dc158a58205cca236f4 /nixos/tests | |
parent | 9bd78cb0488040ea996b27e82135396a45325af5 (diff) | |
parent | 930659b10bc7c875fd49b1cdae21a631b429c25a (diff) | |
download | nixlib-8d56f2472e47a3f1f388b69c0ecc24421910d555.tar nixlib-8d56f2472e47a3f1f388b69c0ecc24421910d555.tar.gz nixlib-8d56f2472e47a3f1f388b69c0ecc24421910d555.tar.bz2 nixlib-8d56f2472e47a3f1f388b69c0ecc24421910d555.tar.lz nixlib-8d56f2472e47a3f1f388b69c0ecc24421910d555.tar.xz nixlib-8d56f2472e47a3f1f388b69c0ecc24421910d555.tar.zst nixlib-8d56f2472e47a3f1f388b69c0ecc24421910d555.zip |
Merge master into staging-next
Diffstat (limited to 'nixos/tests')
-rw-r--r-- | nixos/tests/all-tests.nix | 10 | ||||
-rw-r--r-- | nixos/tests/gnome3-gdm.nix | 63 | ||||
-rw-r--r-- | nixos/tests/gnome3-xorg.nix | 41 | ||||
-rw-r--r-- | nixos/tests/gnome3.nix | 51 | ||||
-rw-r--r-- | nixos/tests/lightdm.nix | 2 | ||||
-rw-r--r-- | nixos/tests/mosquitto.nix | 33 | ||||
-rw-r--r-- | nixos/tests/nixos-generate-config.nix | 24 | ||||
-rw-r--r-- | nixos/tests/postgresql-wal-receiver.nix | 86 | ||||
-rw-r--r-- | nixos/tests/syncthing-init.nix | 8 |
9 files changed, 227 insertions, 91 deletions
diff --git a/nixos/tests/all-tests.nix b/nixos/tests/all-tests.nix index c3fa53ac544f..c24c8ae61a58 100644 --- a/nixos/tests/all-tests.nix +++ b/nixos/tests/all-tests.nix @@ -56,7 +56,7 @@ in containers-physical_interfaces = handleTest ./containers-physical_interfaces.nix {}; containers-restart_networking = handleTest ./containers-restart_networking.nix {}; containers-tmpfs = handleTest ./containers-tmpfs.nix {}; - #couchdb = handleTest ./couchdb.nix {}; # spidermonkey-1.8.5 is marked as broken + couchdb = handleTest ./couchdb.nix {}; deluge = handleTest ./deluge.nix {}; dhparams = handleTest ./dhparams.nix {}; dnscrypt-proxy = handleTestOn ["x86_64-linux"] ./dnscrypt-proxy.nix {}; @@ -93,8 +93,8 @@ in gitlab = handleTest ./gitlab.nix {}; gitolite = handleTest ./gitolite.nix {}; gjs = handleTest ./gjs.nix {}; - gnome3 = handleTestOn ["x86_64-linux"] ./gnome3.nix {}; # libsmbios is unsupported on aarch64 - gnome3-gdm = handleTestOn ["x86_64-linux"] ./gnome3-gdm.nix {}; # libsmbios is unsupported on aarch64 + gnome3-xorg = handleTest ./gnome3-xorg.nix {}; + gnome3 = handleTest ./gnome3.nix {}; gocd-agent = handleTest ./gocd-agent.nix {}; gocd-server = handleTest ./gocd-server.nix {}; google-oslogin = handleTest ./google-oslogin {}; @@ -139,7 +139,7 @@ in ldap = handleTest ./ldap.nix {}; leaps = handleTest ./leaps.nix {}; lidarr = handleTest ./lidarr.nix {}; - #lightdm = handleTest ./lightdm.nix {}; + lightdm = handleTest ./lightdm.nix {}; limesurvey = handleTest ./limesurvey.nix {}; login = handleTest ./login.nix {}; loki = handleTest ./loki.nix {}; @@ -183,6 +183,7 @@ in nginx = handleTest ./nginx.nix {}; nginx-sso = handleTest ./nginx-sso.nix {}; nix-ssh-serve = handleTest ./nix-ssh-serve.nix {}; + nixos-generate-config = handleTest ./nixos-generate-config.nix {}; novacomd = handleTestOn ["x86_64-linux"] ./novacomd.nix {}; nsd = handleTest ./nsd.nix {}; nzbget = handleTest ./nzbget.nix {}; @@ -209,6 +210,7 @@ in plotinus = handleTest ./plotinus.nix {}; postgis = handleTest ./postgis.nix {}; postgresql = handleTest ./postgresql.nix {}; + postgresql-wal-receiver = handleTest ./postgresql-wal-receiver.nix {}; powerdns = handleTest ./powerdns.nix {}; predictable-interface-names = handleTest ./predictable-interface-names.nix {}; printing = handleTest ./printing.nix {}; diff --git a/nixos/tests/gnome3-gdm.nix b/nixos/tests/gnome3-gdm.nix deleted file mode 100644 index c2808d87d99d..000000000000 --- a/nixos/tests/gnome3-gdm.nix +++ /dev/null @@ -1,63 +0,0 @@ -import ./make-test.nix ({ pkgs, ...} : { - name = "gnome3-gdm"; - meta = with pkgs.stdenv.lib.maintainers; { - maintainers = [ lethalman ]; - }; - - machine = - { ... }: - - { imports = [ ./common/user-account.nix ]; - - services.xserver.enable = true; - - services.xserver.displayManager.gdm = { - enable = true; - autoLogin = { - enable = true; - user = "alice"; - }; - }; - services.xserver.desktopManager.gnome3.enable = true; - - virtualisation.memorySize = 1024; - }; - - testScript = let - # Keep line widths somewhat managable - bus = "DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/1000/bus"; - gdbus = "${bus} gdbus"; - # Call javascript in gnome shell, returns a tuple (success, output), where - # `success` is true if the dbus call was successful and output is what the - # javascript evaluates to. - eval = "call --session -d org.gnome.Shell -o /org/gnome/Shell -m org.gnome.Shell.Eval"; - # False when startup is done - startingUp = "${gdbus} ${eval} Main.layoutManager._startingUp"; - # Hopefully gnome-terminal's wm class - wmClass = "${gdbus} ${eval} global.display.focus_window.wm_class"; - in '' - # wait for gdm to start - $machine->waitForUnit("display-manager.service"); - - # wait for alice to be logged in - $machine->waitForUnit("default.target","alice"); - - # Check that logging in has given the user ownership of devices. - $machine->succeed("getfacl /dev/snd/timer | grep -q alice"); - - # Wait for the wayland server - $machine->waitForFile("/run/user/1000/wayland-0"); - - # Wait for gnome shell, correct output should be "(true, 'false')" - $machine->waitUntilSucceeds("su - alice -c '${startingUp} | grep -q true,..false'"); - - # open a terminal - $machine->succeed("su - alice -c '${bus} gnome-terminal'"); - # and check it's there - $machine->waitUntilSucceeds("su - alice -c '${wmClass} | grep -q gnome-terminal-server'"); - - # wait to get a nice screenshot - $machine->sleep(20); - $machine->screenshot("screen"); - ''; -}) diff --git a/nixos/tests/gnome3-xorg.nix b/nixos/tests/gnome3-xorg.nix new file mode 100644 index 000000000000..f12361da0372 --- /dev/null +++ b/nixos/tests/gnome3-xorg.nix @@ -0,0 +1,41 @@ +import ./make-test.nix ({ pkgs, ...} : { + name = "gnome3-xorg"; + meta = with pkgs.stdenv.lib.maintainers; { + maintainers = pkgs.gnome3.maintainers; + }; + + machine = + { ... }: + + { imports = [ ./common/user-account.nix ]; + + services.xserver.enable = true; + + services.xserver.displayManager.gdm.enable = false; + services.xserver.displayManager.lightdm.enable = true; + services.xserver.displayManager.lightdm.autoLogin.enable = true; + services.xserver.displayManager.lightdm.autoLogin.user = "alice"; + services.xserver.desktopManager.gnome3.enable = true; + services.xserver.desktopManager.default = "gnome-xorg"; + + virtualisation.memorySize = 1024; + }; + + testScript = + '' + $machine->waitForX; + + # wait for alice to be logged in + $machine->waitForUnit("default.target","alice"); + + # Check that logging in has given the user ownership of devices. + $machine->succeed("getfacl /dev/snd/timer | grep -q alice"); + + $machine->succeed("su - alice -c 'DISPLAY=:0.0 gnome-terminal &'"); + $machine->succeed("xauth merge ~alice/.Xauthority"); + $machine->waitForWindow(qr/alice.*machine/); + $machine->succeed("timeout 900 bash -c 'while read msg; do if [[ \$msg =~ \"GNOME Shell started\" ]]; then break; fi; done < <(journalctl -f)'"); + $machine->sleep(10); + $machine->screenshot("screen"); + ''; +}) diff --git a/nixos/tests/gnome3.nix b/nixos/tests/gnome3.nix index b58c9e5a0e32..b6fe602a7327 100644 --- a/nixos/tests/gnome3.nix +++ b/nixos/tests/gnome3.nix @@ -1,7 +1,7 @@ import ./make-test.nix ({ pkgs, ...} : { name = "gnome3"; meta = with pkgs.stdenv.lib.maintainers; { - maintainers = [ domenkozar eelco lethalman ]; + maintainers = pkgs.gnome3.maintainers; }; machine = @@ -11,19 +11,34 @@ import ./make-test.nix ({ pkgs, ...} : { services.xserver.enable = true; - services.xserver.displayManager.gdm.enable = false; - services.xserver.displayManager.lightdm.enable = true; - services.xserver.displayManager.lightdm.autoLogin.enable = true; - services.xserver.displayManager.lightdm.autoLogin.user = "alice"; + services.xserver.displayManager.gdm = { + enable = true; + autoLogin = { + enable = true; + user = "alice"; + }; + }; + services.xserver.desktopManager.gnome3.enable = true; - services.xserver.desktopManager.default = "gnome-xorg"; virtualisation.memorySize = 1024; }; - testScript = - '' - $machine->waitForX; + testScript = let + # Keep line widths somewhat managable + bus = "DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/1000/bus"; + gdbus = "${bus} gdbus"; + # Call javascript in gnome shell, returns a tuple (success, output), where + # `success` is true if the dbus call was successful and output is what the + # javascript evaluates to. + eval = "call --session -d org.gnome.Shell -o /org/gnome/Shell -m org.gnome.Shell.Eval"; + # False when startup is done + startingUp = "${gdbus} ${eval} Main.layoutManager._startingUp"; + # Hopefully gnome-terminal's wm class + wmClass = "${gdbus} ${eval} global.display.focus_window.wm_class"; + in '' + # wait for gdm to start + $machine->waitForUnit("display-manager.service"); # wait for alice to be logged in $machine->waitForUnit("default.target","alice"); @@ -31,11 +46,19 @@ import ./make-test.nix ({ pkgs, ...} : { # Check that logging in has given the user ownership of devices. $machine->succeed("getfacl /dev/snd/timer | grep -q alice"); - $machine->succeed("su - alice -c 'DISPLAY=:0.0 gnome-terminal &'"); - $machine->succeed("xauth merge ~alice/.Xauthority"); - $machine->waitForWindow(qr/alice.*machine/); - $machine->succeed("timeout 900 bash -c 'while read msg; do if [[ \$msg =~ \"GNOME Shell started\" ]]; then break; fi; done < <(journalctl -f)'"); - $machine->sleep(10); + # Wait for the wayland server + $machine->waitForFile("/run/user/1000/wayland-0"); + + # Wait for gnome shell, correct output should be "(true, 'false')" + $machine->waitUntilSucceeds("su - alice -c '${startingUp} | grep -q true,..false'"); + + # open a terminal + $machine->succeed("su - alice -c '${bus} gnome-terminal'"); + # and check it's there + $machine->waitUntilSucceeds("su - alice -c '${wmClass} | grep -q gnome-terminal-server'"); + + # wait to get a nice screenshot + $machine->sleep(20); $machine->screenshot("screen"); ''; }) diff --git a/nixos/tests/lightdm.nix b/nixos/tests/lightdm.nix index 8a9a7408d292..c805f1ed9f3c 100644 --- a/nixos/tests/lightdm.nix +++ b/nixos/tests/lightdm.nix @@ -1,7 +1,7 @@ import ./make-test.nix ({ pkgs, ...} : { name = "lightdm"; meta = with pkgs.stdenv.lib.maintainers; { - maintainers = [ aszlig ]; + maintainers = [ aszlig worldofpeace ]; }; machine = { ... }: { diff --git a/nixos/tests/mosquitto.nix b/nixos/tests/mosquitto.nix index 86b7f9c044d8..bd5447de15ff 100644 --- a/nixos/tests/mosquitto.nix +++ b/nixos/tests/mosquitto.nix @@ -49,21 +49,40 @@ in rec { testScript = let file = "/tmp/msg"; - payload = "wootWOOT"; + sub = args: + "(${cmd "sub"} -C 1 ${args} | tee ${file} &)"; in '' startAll; $server->waitForUnit("mosquitto.service"); $server->fail("test -f ${file}"); - $server->execute("(${cmd "sub"} -C 1 | tee ${file} &)"); - $client1->fail("test -f ${file}"); - $client1->execute("(${cmd "sub"} -C 1 | tee ${file} &)"); + $client2->fail("test -f ${file}"); + + + # QoS = 0, so only one subscribers should get it + $server->execute("${sub "-q 0"}"); + + # we need to give the subscribers some time to connect + $client2->execute("sleep 5"); + $client2->succeed("${cmd "pub"} -m FOO -q 0"); + + $server->waitUntilSucceeds("grep -q FOO ${file}"); + $server->execute("rm ${file}"); + + + # QoS = 1, so both subscribers should get it + $server->execute("${sub "-q 1"}"); + $client1->execute("${sub "-q 1"}"); - $client2->succeed("${cmd "pub"} -m ${payload}"); + # we need to give the subscribers some time to connect + $client2->execute("sleep 5"); + $client2->succeed("${cmd "pub"} -m BAR -q 1"); - $server->succeed("grep -q ${payload} ${file}"); + $server->waitUntilSucceeds("grep -q BAR ${file}"); + $server->execute("rm ${file}"); - $client1->succeed("grep -q ${payload} ${file}"); + $client1->waitUntilSucceeds("grep -q BAR ${file}"); + $client1->execute("rm ${file}"); ''; }) diff --git a/nixos/tests/nixos-generate-config.nix b/nixos/tests/nixos-generate-config.nix new file mode 100644 index 000000000000..15a173e024b4 --- /dev/null +++ b/nixos/tests/nixos-generate-config.nix @@ -0,0 +1,24 @@ +import ./make-test.nix ({ lib, ... } : { + name = "nixos-generate-config"; + meta.maintainers = with lib.maintainers; [ basvandijk ]; + machine = { + system.nixos-generate-config.configuration = '' + # OVERRIDDEN + { config, pkgs, ... }: { + imports = [ ./hardware-configuration.nix ]; + $bootLoaderConfig + } + ''; + }; + testScript = '' + startAll; + $machine->waitForUnit("multi-user.target"); + $machine->succeed("nixos-generate-config"); + + # Test if the configuration really is overridden + $machine->succeed("grep 'OVERRIDDEN' /etc/nixos/configuration.nix"); + + # Test of if the Perl variable $bootLoaderConfig is spliced correctly: + $machine->succeed("grep 'boot\\.loader\\.grub\\.enable = true;' /etc/nixos/configuration.nix"); + ''; +}) diff --git a/nixos/tests/postgresql-wal-receiver.nix b/nixos/tests/postgresql-wal-receiver.nix new file mode 100644 index 000000000000..791b041ba95b --- /dev/null +++ b/nixos/tests/postgresql-wal-receiver.nix @@ -0,0 +1,86 @@ +{ system ? builtins.currentSystem +, config ? { } +, pkgs ? import ../.. { inherit system config; } }: + +with import ../lib/testing.nix { inherit system pkgs; }; +with pkgs.lib; + +let + postgresqlDataDir = "/var/db/postgresql/test"; + replicationUser = "wal_receiver_user"; + replicationSlot = "wal_receiver_slot"; + replicationConn = "postgresql://${replicationUser}@localhost"; + baseBackupDir = "/tmp/pg_basebackup"; + walBackupDir = "/tmp/pg_wal"; + recoveryConf = pkgs.writeText "recovery.conf" '' + restore_command = 'cp ${walBackupDir}/%f %p' + ''; + + makePostgresqlWalReceiverTest = subTestName: postgresqlPackage: makeTest { + name = "postgresql-wal-receiver-${subTestName}"; + meta.maintainers = with maintainers; [ pacien ]; + + machine = { ... }: { + services.postgresql = { + package = postgresqlPackage; + enable = true; + dataDir = postgresqlDataDir; + extraConfig = '' + wal_level = archive # alias for replica on pg >= 9.6 + max_wal_senders = 10 + max_replication_slots = 10 + ''; + authentication = '' + host replication ${replicationUser} all trust + ''; + initialScript = pkgs.writeText "init.sql" '' + create user ${replicationUser} replication; + select * from pg_create_physical_replication_slot('${replicationSlot}'); + ''; + }; + + services.postgresqlWalReceiver.receivers.main = { + inherit postgresqlPackage; + connection = replicationConn; + slot = replicationSlot; + directory = walBackupDir; + }; + }; + + testScript = '' + # make an initial base backup + $machine->waitForUnit('postgresql'); + $machine->waitForUnit('postgresql-wal-receiver-main'); + # WAL receiver healthchecks PG every 5 seconds, so let's be sure they have connected each other + # required only for 9.4 + $machine->sleep(5); + $machine->succeed('${postgresqlPackage}/bin/pg_basebackup --dbname=${replicationConn} --pgdata=${baseBackupDir}'); + + # create a dummy table with 100 records + $machine->succeed('sudo -u postgres psql --command="create table dummy as select * from generate_series(1, 100) as val;"'); + + # stop postgres and destroy data + $machine->systemctl('stop postgresql'); + $machine->systemctl('stop postgresql-wal-receiver-main'); + $machine->succeed('rm -r ${postgresqlDataDir}/{base,global,pg_*}'); + + # restore the base backup + $machine->succeed('cp -r ${baseBackupDir}/* ${postgresqlDataDir} && chown postgres:postgres -R ${postgresqlDataDir}'); + + # prepare WAL and recovery + $machine->succeed('chmod a+rX -R ${walBackupDir}'); + $machine->execute('for part in ${walBackupDir}/*.partial; do mv $part ''${part%%.*}; done'); # make use of partial segments too + $machine->succeed('cp ${recoveryConf} ${postgresqlDataDir}/recovery.conf && chmod 666 ${postgresqlDataDir}/recovery.conf'); + + # replay WAL + $machine->systemctl('start postgresql'); + $machine->waitForFile('${postgresqlDataDir}/recovery.done'); + $machine->systemctl('restart postgresql'); + $machine->waitForUnit('postgresql'); + + # check that our records have been restored + $machine->succeed('test $(sudo -u postgres psql --pset="pager=off" --tuples-only --command="select count(distinct val) from dummy;") -eq 100'); + ''; + }; + +in mapAttrs makePostgresqlWalReceiverTest (import ../../pkgs/servers/sql/postgresql pkgs) diff --git a/nixos/tests/syncthing-init.nix b/nixos/tests/syncthing-init.nix index 811a466ff941..0de76b688bdc 100644 --- a/nixos/tests/syncthing-init.nix +++ b/nixos/tests/syncthing-init.nix @@ -22,9 +22,13 @@ in { }; testScript = '' + my $config; + $machine->waitForUnit("syncthing-init.service"); - $machine->succeed("cat /var/lib/syncthing/config.xml") =~ /${testId}/ or die; - $machine->succeed("cat /var/lib/syncthing/config.xml") =~ /testFolder/ or die; + $config = $machine->succeed("cat /var/lib/syncthing/.config/syncthing/config.xml"); + + $config =~ /${testId}/ or die; + $config =~ /testFolder/ or die; ''; }) |