0
0
Fork 0
mirror of https://github.com/NixOS/nixpkgs.git synced 2025-07-13 21:50:33 +03:00

nixosTests: migrate tests to runTests (#389964)

This commit is contained in:
Martin Weinelt 2025-03-15 20:49:33 +01:00 committed by GitHub
commit 48e041d23c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
27 changed files with 1151 additions and 1211 deletions

View file

@ -1300,26 +1300,26 @@ in {
wrappers = handleTest ./wrappers.nix {}; wrappers = handleTest ./wrappers.nix {};
writefreely = handleTest ./web-apps/writefreely.nix {}; writefreely = handleTest ./web-apps/writefreely.nix {};
wstunnel = runTest ./wstunnel.nix; wstunnel = runTest ./wstunnel.nix;
xandikos = handleTest ./xandikos.nix {}; xandikos = runTest ./xandikos.nix;
xautolock = handleTest ./xautolock.nix {}; xautolock = runTest ./xautolock.nix;
xfce = handleTest ./xfce.nix {}; xfce = runTest ./xfce.nix;
xfce-wayland = handleTest ./xfce-wayland.nix {}; xfce-wayland = runTest ./xfce-wayland.nix;
xmonad = handleTest ./xmonad.nix {}; xmonad = runTest ./xmonad.nix;
xmonad-xdg-autostart = handleTest ./xmonad-xdg-autostart.nix {}; xmonad-xdg-autostart = runTest ./xmonad-xdg-autostart.nix;
xpadneo = handleTest ./xpadneo.nix {}; xpadneo = runTest ./xpadneo.nix;
xrdp = handleTest ./xrdp.nix {}; xrdp = runTest ./xrdp.nix;
xrdp-with-audio-pulseaudio = handleTest ./xrdp-with-audio-pulseaudio.nix {}; xrdp-with-audio-pulseaudio = runTest ./xrdp-with-audio-pulseaudio.nix;
xscreensaver = handleTest ./xscreensaver.nix {}; xscreensaver = handleTest ./xscreensaver.nix {};
xss-lock = handleTest ./xss-lock.nix {}; xss-lock = runTest ./xss-lock.nix;
xterm = handleTest ./xterm.nix {}; xterm = runTest ./xterm.nix;
xxh = handleTest ./xxh.nix {}; xxh = runTest ./xxh.nix;
yabar = handleTest ./yabar.nix {}; yabar = runTest ./yabar.nix;
ydotool = handleTest ./ydotool.nix {}; ydotool = handleTest ./ydotool.nix {};
yggdrasil = handleTest ./yggdrasil.nix {}; yggdrasil = runTest ./yggdrasil.nix;
your_spotify = handleTest ./your_spotify.nix {}; your_spotify = runTest ./your_spotify.nix;
zammad = handleTest ./zammad.nix {}; zammad = runTest ./zammad.nix;
zenohd = handleTest ./zenohd.nix {}; zenohd = runTest ./zenohd.nix;
zeronet-conservancy = handleTest ./zeronet-conservancy.nix {}; zeronet-conservancy = runTest ./zeronet-conservancy.nix;
zfs = handleTest ./zfs.nix {}; zfs = handleTest ./zfs.nix {};
zigbee2mqtt_1 = runTest { zigbee2mqtt_1 = runTest {
imports = [ ./zigbee2mqtt.nix ]; imports = [ ./zigbee2mqtt.nix ];
@ -1329,12 +1329,12 @@ in {
imports = [ ./zigbee2mqtt.nix ]; imports = [ ./zigbee2mqtt.nix ];
_module.args.package = pkgs.zigbee2mqtt_2; _module.args.package = pkgs.zigbee2mqtt_2;
}; };
zipline = handleTest ./zipline.nix {}; zipline = runTest ./zipline.nix;
zoneminder = handleTest ./zoneminder.nix {}; zoneminder = runTest ./zoneminder.nix;
zookeeper = handleTest ./zookeeper.nix {}; zookeeper = runTest ./zookeeper.nix;
zram-generator = handleTest ./zram-generator.nix {}; zram-generator = runTest ./zram-generator.nix;
zrepl = handleTest ./zrepl.nix {}; zrepl = runTest ./zrepl.nix;
zsh-history = handleTest ./zsh-history.nix {}; zsh-history = runTest ./zsh-history.nix;
zwave-js = handleTest ./zwave-js.nix {}; zwave-js = runTest ./zwave-js.nix;
zwave-js-ui = handleTest ./zwave-js-ui.nix {}; zwave-js-ui = runTest ./zwave-js-ui.nix;
} }

View file

@ -1,73 +1,71 @@
import ./make-test-python.nix ( { lib, ... }:
{ pkgs, lib, ... }:
{ {
name = "xandikos"; name = "xandikos";
meta.maintainers = with lib.maintainers; [ _0x4A6F ]; meta.maintainers = with lib.maintainers; [ _0x4A6F ];
nodes = { nodes = {
xandikos_client = { }; xandikos_client = { };
xandikos_default = { xandikos_default = {
networking.firewall.allowedTCPPorts = [ 8080 ]; networking.firewall.allowedTCPPorts = [ 8080 ];
services.xandikos.enable = true; services.xandikos.enable = true;
}; };
xandikos_proxy = { xandikos_proxy = {
networking.firewall.allowedTCPPorts = [ networking.firewall.allowedTCPPorts = [
80 80
8080 8080
]; ];
services.xandikos.enable = true; services.xandikos.enable = true;
services.xandikos.address = "localhost"; services.xandikos.address = "localhost";
services.xandikos.port = 8080; services.xandikos.port = 8080;
services.xandikos.routePrefix = "/xandikos-prefix/"; services.xandikos.routePrefix = "/xandikos-prefix/";
services.xandikos.extraOptions = [ services.xandikos.extraOptions = [
"--defaults" "--defaults"
]; ];
services.nginx = { services.nginx = {
enable = true; enable = true;
recommendedProxySettings = true; recommendedProxySettings = true;
virtualHosts."xandikos" = { virtualHosts."xandikos" = {
serverName = "xandikos.local"; serverName = "xandikos.local";
basicAuth.xandikos = "snakeOilPassword"; basicAuth.xandikos = "snakeOilPassword";
locations."/xandikos/" = { locations."/xandikos/" = {
proxyPass = "http://localhost:8080/xandikos-prefix/"; proxyPass = "http://localhost:8080/xandikos-prefix/";
};
}; };
}; };
}; };
}; };
};
testScript = '' testScript = ''
start_all() start_all()
with subtest("Xandikos default"): with subtest("Xandikos default"):
xandikos_default.wait_for_unit("multi-user.target") xandikos_default.wait_for_unit("multi-user.target")
xandikos_default.wait_for_unit("xandikos.service") xandikos_default.wait_for_unit("xandikos.service")
xandikos_default.wait_for_open_port(8080) xandikos_default.wait_for_open_port(8080)
xandikos_default.succeed("curl --fail http://localhost:8080/") xandikos_default.succeed("curl --fail http://localhost:8080/")
xandikos_default.succeed( xandikos_default.succeed(
"curl -s --fail --location http://localhost:8080/ | grep -i Xandikos" "curl -s --fail --location http://localhost:8080/ | grep -i Xandikos"
) )
xandikos_client.wait_for_unit("network.target") xandikos_client.wait_for_unit("network.target")
xandikos_client.fail("curl --fail http://xandikos_default:8080/") xandikos_client.fail("curl --fail http://xandikos_default:8080/")
with subtest("Xandikos proxy"): with subtest("Xandikos proxy"):
xandikos_proxy.wait_for_unit("multi-user.target") xandikos_proxy.wait_for_unit("multi-user.target")
xandikos_proxy.wait_for_unit("xandikos.service") xandikos_proxy.wait_for_unit("xandikos.service")
xandikos_proxy.wait_for_open_port(8080) xandikos_proxy.wait_for_open_port(8080)
xandikos_proxy.succeed("curl --fail http://localhost:8080/") xandikos_proxy.succeed("curl --fail http://localhost:8080/")
xandikos_proxy.succeed( xandikos_proxy.succeed(
"curl -s --fail --location http://localhost:8080/ | grep -i Xandikos" "curl -s --fail --location http://localhost:8080/ | grep -i Xandikos"
) )
xandikos_client.wait_for_unit("network.target") xandikos_client.wait_for_unit("network.target")
xandikos_client.fail("curl --fail http://xandikos_proxy:8080/") xandikos_client.fail("curl --fail http://xandikos_proxy:8080/")
xandikos_client.succeed( xandikos_client.succeed(
"curl -s --fail -u xandikos:snakeOilPassword -H 'Host: xandikos.local' http://xandikos_proxy/xandikos/ | grep -i Xandikos" "curl -s --fail -u xandikos:snakeOilPassword -H 'Host: xandikos.local' http://xandikos_proxy/xandikos/ | grep -i Xandikos"
) )
xandikos_client.succeed( xandikos_client.succeed(
"curl -s --fail -u xandikos:snakeOilPassword -H 'Host: xandikos.local' http://xandikos_proxy/xandikos/user/ | grep -i Xandikos" "curl -s --fail -u xandikos:snakeOilPassword -H 'Host: xandikos.local' http://xandikos_proxy/xandikos/user/ | grep -i Xandikos"
) )
''; '';
} }
)

View file

@ -1,27 +1,23 @@
import ./make-test-python.nix ( {
{ pkgs, lib, ... }: name = "xautolock";
meta.maintainers = [ ];
{ nodes.machine = {
name = "xautolock"; imports = [
meta.maintainers = [ ]; ./common/x11.nix
./common/user-account.nix
];
nodes.machine = { test-support.displayManager.auto.user = "bob";
imports = [ services.xserver.xautolock.enable = true;
./common/x11.nix services.xserver.xautolock.time = 1;
./common/user-account.nix };
];
test-support.displayManager.auto.user = "bob"; testScript = ''
services.xserver.xautolock.enable = true; machine.start()
services.xserver.xautolock.time = 1; machine.wait_for_x()
}; machine.fail("pgrep xlock")
machine.sleep(120)
testScript = '' machine.succeed("pgrep xlock")
machine.start() '';
machine.wait_for_x() }
machine.fail("pgrep xlock")
machine.sleep(120)
machine.succeed("pgrep xlock")
'';
}
)

View file

@ -1,71 +1,68 @@
import ./make-test-python.nix ( {
{ pkgs, ... }: name = "xfce-wayland";
{
name = "xfce-wayland";
nodes.machine = nodes.machine =
{ pkgs, ... }: { pkgs, ... }:
{ {
imports = [ imports = [
./common/user-account.nix ./common/user-account.nix
]; ];
services.xserver.enable = true; services.xserver.enable = true;
services.xserver.displayManager.lightdm.enable = true; services.xserver.displayManager.lightdm.enable = true;
services.displayManager = { services.displayManager = {
defaultSession = "xfce-wayland"; defaultSession = "xfce-wayland";
autoLogin = { autoLogin = {
enable = true; enable = true;
user = "alice"; user = "alice";
};
}; };
services.xserver.desktopManager.xfce.enable = true;
services.xserver.desktopManager.xfce.enableWaylandSession = true;
environment.systemPackages = [ pkgs.wlrctl ];
}; };
enableOCR = true; services.xserver.desktopManager.xfce.enable = true;
services.xserver.desktopManager.xfce.enableWaylandSession = true;
environment.systemPackages = [ pkgs.wlrctl ];
};
testScript = enableOCR = true;
{ nodes, ... }:
let
user = nodes.machine.users.users.alice;
rtdir = "XDG_RUNTIME_DIR=/run/user/${toString user.uid}";
in
''
machine.wait_for_unit("display-manager.service")
with subtest("Wait for Wayland server"): testScript =
machine.wait_for_file("/run/user/${toString user.uid}/wayland-0") { nodes, ... }:
let
user = nodes.machine.users.users.alice;
rtdir = "XDG_RUNTIME_DIR=/run/user/${toString user.uid}";
in
''
machine.wait_for_unit("display-manager.service")
with subtest("Check that logging in has given the user ownership of devices"): with subtest("Wait for Wayland server"):
machine.succeed("getfacl -p /dev/snd/timer | grep -q ${user.name}") machine.wait_for_file("/run/user/${toString user.uid}/wayland-0")
with subtest("Check if Xfce components actually start"): with subtest("Check that logging in has given the user ownership of devices"):
for p in ["labwc", "xfdesktop", "xfce4-notifyd", "xfconfd", "xfce4-panel"]: machine.succeed("getfacl -p /dev/snd/timer | grep -q ${user.name}")
machine.wait_until_succeeds(f"pgrep {p}")
with subtest("Open Xfce terminal"): with subtest("Check if Xfce components actually start"):
machine.succeed("su - ${user.name} -c '${rtdir} xfce4-terminal >&2 &'") for p in ["labwc", "xfdesktop", "xfce4-notifyd", "xfconfd", "xfce4-panel"]:
machine.wait_until_succeeds("su - ${user.name} -c '${rtdir} wlrctl toplevel list | grep xfce4-terminal'") machine.wait_until_succeeds(f"pgrep {p}")
with subtest("Open Thunar"): with subtest("Open Xfce terminal"):
machine.succeed("su - ${user.name} -c '${rtdir} thunar >&2 &'") machine.succeed("su - ${user.name} -c '${rtdir} xfce4-terminal >&2 &'")
machine.wait_until_succeeds("su - ${user.name} -c '${rtdir} wlrctl toplevel list | grep Thunar'") machine.wait_until_succeeds("su - ${user.name} -c '${rtdir} wlrctl toplevel list | grep xfce4-terminal'")
machine.wait_for_text('(Pictures|Public|Templates|Videos)')
with subtest("Check if various environment variables are set"): with subtest("Open Thunar"):
cmd = "xargs --null --max-args=1 echo < /proc/$(pgrep -xf xfce4-panel)/environ" machine.succeed("su - ${user.name} -c '${rtdir} thunar >&2 &'")
machine.succeed(f"{cmd} | grep 'XDG_SESSION_TYPE' | grep 'wayland'") machine.wait_until_succeeds("su - ${user.name} -c '${rtdir} wlrctl toplevel list | grep Thunar'")
machine.succeed(f"{cmd} | grep 'XFCE4_SESSION_COMPOSITOR' | grep 'labwc'") machine.wait_for_text('(Pictures|Public|Templates|Videos)')
machine.succeed(f"{cmd} | grep 'XDG_CURRENT_DESKTOP' | grep 'XFCE'")
with subtest("Check if any coredumps are found"): with subtest("Check if various environment variables are set"):
machine.succeed("(coredumpctl --json=short 2>&1 || true) | grep 'No coredumps found'") cmd = "xargs --null --max-args=1 echo < /proc/$(pgrep -xf xfce4-panel)/environ"
machine.sleep(10) machine.succeed(f"{cmd} | grep 'XDG_SESSION_TYPE' | grep 'wayland'")
machine.screenshot("screen") machine.succeed(f"{cmd} | grep 'XFCE4_SESSION_COMPOSITOR' | grep 'labwc'")
''; machine.succeed(f"{cmd} | grep 'XDG_CURRENT_DESKTOP' | grep 'XFCE'")
}
) with subtest("Check if any coredumps are found"):
machine.succeed("(coredumpctl --json=short 2>&1 || true) | grep 'No coredumps found'")
machine.sleep(10)
machine.screenshot("screen")
'';
}

View file

@ -1,76 +1,73 @@
import ./make-test-python.nix ( {
{ pkgs, ... }: name = "xfce";
{
name = "xfce";
nodes.machine = nodes.machine =
{ pkgs, ... }: { pkgs, ... }:
{ {
imports = [ imports = [
./common/user-account.nix ./common/user-account.nix
]; ];
services.xserver.enable = true; services.xserver.enable = true;
services.xserver.displayManager.lightdm.enable = true; services.xserver.displayManager.lightdm.enable = true;
services.displayManager.autoLogin = { services.displayManager.autoLogin = {
enable = true; enable = true;
user = "alice"; user = "alice";
};
services.xserver.desktopManager.xfce.enable = true;
environment.systemPackages = [ pkgs.xfce.xfce4-whiskermenu-plugin ];
}; };
enableOCR = true; services.xserver.desktopManager.xfce.enable = true;
environment.systemPackages = [ pkgs.xfce.xfce4-whiskermenu-plugin ];
};
testScript = enableOCR = true;
{ nodes, ... }:
let
user = nodes.machine.users.users.alice;
bus = "DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/${toString user.uid}/bus";
in
''
with subtest("Wait for login"):
machine.wait_for_x()
machine.wait_for_file("${user.home}/.Xauthority")
machine.succeed("xauth merge ${user.home}/.Xauthority")
with subtest("Check that logging in has given the user ownership of devices"): testScript =
machine.succeed("getfacl -p /dev/snd/timer | grep -q ${user.name}") { nodes, ... }:
let
user = nodes.machine.users.users.alice;
bus = "DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/${toString user.uid}/bus";
in
''
with subtest("Wait for login"):
machine.wait_for_x()
machine.wait_for_file("${user.home}/.Xauthority")
machine.succeed("xauth merge ${user.home}/.Xauthority")
with subtest("Check if Xfce components actually start"): with subtest("Check that logging in has given the user ownership of devices"):
machine.wait_for_window("xfce4-panel") machine.succeed("getfacl -p /dev/snd/timer | grep -q ${user.name}")
machine.wait_for_window("Desktop")
for i in ["xfwm4", "xfsettingsd", "xfdesktop", "xfce4-screensaver", "xfce4-notifyd", "xfconfd"]:
machine.wait_until_succeeds(f"pgrep -f {i}")
with subtest("Open whiskermenu"): with subtest("Check if Xfce components actually start"):
machine.succeed("su - ${user.name} -c 'DISPLAY=:0 ${bus} xfconf-query -c xfce4-panel -p /plugins/plugin-1 -t string -s whiskermenu -n >&2 &'") machine.wait_for_window("xfce4-panel")
machine.succeed("su - ${user.name} -c 'DISPLAY=:0 ${bus} xfconf-query -c xfce4-panel -p /plugins/plugin-1/stay-on-focus-out -t bool -s true -n >&2 &'") machine.wait_for_window("Desktop")
machine.succeed("su - ${user.name} -c 'DISPLAY=:0 ${bus} xfce4-panel -r >&2 &'") for i in ["xfwm4", "xfsettingsd", "xfdesktop", "xfce4-screensaver", "xfce4-notifyd", "xfconfd"]:
machine.wait_until_succeeds("journalctl -b --grep 'xfce4-panel: Restarting' -t xsession") machine.wait_until_succeeds(f"pgrep -f {i}")
machine.sleep(5)
machine.wait_until_succeeds("pgrep -f libwhiskermenu")
machine.succeed("su - ${user.name} -c 'DISPLAY=:0 ${bus} xfce4-popup-whiskermenu >&2 &'")
machine.wait_for_text('Mail Reader')
# Close the menu.
machine.succeed("su - ${user.name} -c 'DISPLAY=:0 ${bus} xfce4-popup-whiskermenu >&2 &'")
with subtest("Open Xfce terminal"): with subtest("Open whiskermenu"):
machine.succeed("su - ${user.name} -c 'DISPLAY=:0 xfce4-terminal >&2 &'") machine.succeed("su - ${user.name} -c 'DISPLAY=:0 ${bus} xfconf-query -c xfce4-panel -p /plugins/plugin-1 -t string -s whiskermenu -n >&2 &'")
machine.wait_for_window("Terminal") machine.succeed("su - ${user.name} -c 'DISPLAY=:0 ${bus} xfconf-query -c xfce4-panel -p /plugins/plugin-1/stay-on-focus-out -t bool -s true -n >&2 &'")
machine.succeed("su - ${user.name} -c 'DISPLAY=:0 ${bus} xfce4-panel -r >&2 &'")
machine.wait_until_succeeds("journalctl -b --grep 'xfce4-panel: Restarting' -t xsession")
machine.sleep(5)
machine.wait_until_succeeds("pgrep -f libwhiskermenu")
machine.succeed("su - ${user.name} -c 'DISPLAY=:0 ${bus} xfce4-popup-whiskermenu >&2 &'")
machine.wait_for_text('Mail Reader')
# Close the menu.
machine.succeed("su - ${user.name} -c 'DISPLAY=:0 ${bus} xfce4-popup-whiskermenu >&2 &'")
with subtest("Open Thunar"): with subtest("Open Xfce terminal"):
machine.succeed("su - ${user.name} -c 'DISPLAY=:0 thunar >&2 &'") machine.succeed("su - ${user.name} -c 'DISPLAY=:0 xfce4-terminal >&2 &'")
machine.wait_for_window("Thunar") machine.wait_for_window("Terminal")
machine.wait_for_text('(Pictures|Public|Templates|Videos)')
with subtest("Check if any coredumps are found"): with subtest("Open Thunar"):
machine.succeed("(coredumpctl --json=short 2>&1 || true) | grep 'No coredumps found'") machine.succeed("su - ${user.name} -c 'DISPLAY=:0 thunar >&2 &'")
machine.sleep(10) machine.wait_for_window("Thunar")
machine.screenshot("screen") machine.wait_for_text('(Pictures|Public|Templates|Videos)')
'';
} with subtest("Check if any coredumps are found"):
) machine.succeed("(coredumpctl --json=short 2>&1 || true) | grep 'No coredumps found'")
machine.sleep(10)
machine.screenshot("screen")
'';
}

View file

@ -1,44 +1,42 @@
import ./make-test-python.nix ( { lib, ... }:
{ lib, ... }: {
{ name = "xmonad-xdg-autostart";
name = "xmonad-xdg-autostart"; meta.maintainers = with lib.maintainers; [ oxalica ];
meta.maintainers = with lib.maintainers; [ oxalica ];
nodes.machine = nodes.machine =
{ pkgs, config, ... }: { pkgs, config, ... }:
{ {
imports = [ imports = [
./common/x11.nix ./common/x11.nix
./common/user-account.nix ./common/user-account.nix
]; ];
test-support.displayManager.auto.user = "alice"; test-support.displayManager.auto.user = "alice";
services.displayManager.defaultSession = "none+xmonad"; services.displayManager.defaultSession = "none+xmonad";
services.xserver.windowManager.xmonad.enable = true; services.xserver.windowManager.xmonad.enable = true;
services.xserver.desktopManager.runXdgAutostartIfNone = true; services.xserver.desktopManager.runXdgAutostartIfNone = true;
environment.systemPackages = [ environment.systemPackages = [
(pkgs.writeTextFile { (pkgs.writeTextFile {
name = "test-xdg-autostart"; name = "test-xdg-autostart";
destination = "/etc/xdg/autostart/test-xdg-autostart.desktop"; destination = "/etc/xdg/autostart/test-xdg-autostart.desktop";
text = '' text = ''
[Desktop Entry] [Desktop Entry]
Name=test-xdg-autoatart Name=test-xdg-autoatart
Type=Application Type=Application
Terminal=false Terminal=false
Exec=${pkgs.coreutils}/bin/touch ${config.users.users.alice.home}/xdg-autostart-executed Exec=${pkgs.coreutils}/bin/touch ${config.users.users.alice.home}/xdg-autostart-executed
''; '';
}) })
]; ];
}; };
testScript = testScript =
{ nodes, ... }: { nodes, ... }:
let let
user = nodes.machine.config.users.users.alice; user = nodes.machine.users.users.alice;
in in
'' ''
machine.wait_for_x() machine.wait_for_x()
machine.wait_for_file("${user.home}/xdg-autostart-executed") machine.wait_for_file("${user.home}/xdg-autostart-executed")
''; '';
} }
)

View file

@ -1,131 +1,129 @@
import ./make-test-python.nix ( { pkgs, ... }:
{ pkgs, ... }:
let let
mkConfig = name: keys: '' mkConfig = name: keys: ''
import XMonad import XMonad
import XMonad.Operations (restart) import XMonad.Operations (restart)
import XMonad.Util.EZConfig import XMonad.Util.EZConfig
import XMonad.Util.SessionStart import XMonad.Util.SessionStart
import Control.Monad (when) import Control.Monad (when)
import Text.Printf (printf) import Text.Printf (printf)
import System.Posix.Process (executeFile) import System.Posix.Process (executeFile)
import System.Info (arch,os) import System.Info (arch,os)
import System.Environment (getArgs) import System.Environment (getArgs)
import System.FilePath ((</>)) import System.FilePath ((</>))
main = do main = do
dirs <- getDirectories dirs <- getDirectories
launch (def { startupHook = startup } `additionalKeysP` myKeys) dirs launch (def { startupHook = startup } `additionalKeysP` myKeys) dirs
startup = isSessionStart >>= \sessInit -> startup = isSessionStart >>= \sessInit ->
spawn "touch /tmp/${name}" spawn "touch /tmp/${name}"
>> if sessInit then setSessionStarted else spawn "xterm" >> if sessInit then setSessionStarted else spawn "xterm"
myKeys = [${builtins.concatStringsSep ", " keys}] myKeys = [${builtins.concatStringsSep ", " keys}]
compiledConfig = printf "xmonad-%s-%s" arch os compiledConfig = printf "xmonad-%s-%s" arch os
compileRestart resume = do compileRestart resume = do
dirs <- asks directories dirs <- asks directories
whenX (recompile dirs True) $ whenX (recompile dirs True) $
when resume writeStateToFile when resume writeStateToFile
*> catchIO *> catchIO
( do ( do
args <- getArgs args <- getArgs
executeFile (cacheDir dirs </> compiledConfig) False args Nothing executeFile (cacheDir dirs </> compiledConfig) False args Nothing
) )
''; '';
oldKeys = [ oldKeys = [
''("M-C-x", spawn "xterm")'' ''("M-C-x", spawn "xterm")''
''("M-q", restart "xmonad" True)'' ''("M-q", restart "xmonad" True)''
''("M-C-q", compileRestart True)'' ''("M-C-q", compileRestart True)''
''("M-C-t", spawn "touch /tmp/somefile")'' # create somefile ''("M-C-t", spawn "touch /tmp/somefile")'' # create somefile
];
newKeys = [
''("M-C-x", spawn "xterm")''
''("M-q", restart "xmonad" True)''
''("M-C-q", compileRestart True)''
''("M-C-r", spawn "rm /tmp/somefile")'' # delete somefile
];
newConfig = pkgs.writeText "xmonad.hs" (mkConfig "newXMonad" newKeys);
in
{
name = "xmonad";
meta = with pkgs.lib.maintainers; {
maintainers = [
nequissimus
ivanbrennan
]; ];
};
newKeys = [ nodes.machine =
''("M-C-x", spawn "xterm")'' { pkgs, ... }:
''("M-q", restart "xmonad" True)'' {
''("M-C-q", compileRestart True)'' imports = [
''("M-C-r", spawn "rm /tmp/somefile")'' # delete somefile ./common/x11.nix
]; ./common/user-account.nix
newConfig = pkgs.writeText "xmonad.hs" (mkConfig "newXMonad" newKeys);
in
{
name = "xmonad";
meta = with pkgs.lib.maintainers; {
maintainers = [
nequissimus
ivanbrennan
]; ];
test-support.displayManager.auto.user = "alice";
services.displayManager.defaultSession = "none+xmonad";
services.xserver.windowManager.xmonad = {
enable = true;
enableConfiguredRecompile = true;
enableContribAndExtras = true;
extraPackages = with pkgs.haskellPackages; haskellPackages: [ xmobar ];
config = mkConfig "oldXMonad" oldKeys;
};
}; };
nodes.machine = testScript =
{ pkgs, ... }: { nodes, ... }:
{ let
imports = [ user = nodes.machine.users.users.alice;
./common/x11.nix in
./common/user-account.nix ''
]; machine.wait_for_x()
test-support.displayManager.auto.user = "alice"; machine.wait_for_file("${user.home}/.Xauthority")
services.displayManager.defaultSession = "none+xmonad"; machine.succeed("xauth merge ${user.home}/.Xauthority")
services.xserver.windowManager.xmonad = { machine.send_key("alt-ctrl-x")
enable = true; machine.wait_for_window("${user.name}.*machine")
enableConfiguredRecompile = true; machine.sleep(1)
enableContribAndExtras = true; machine.screenshot("terminal1")
extraPackages = with pkgs.haskellPackages; haskellPackages: [ xmobar ]; machine.succeed("rm /tmp/oldXMonad")
config = mkConfig "oldXMonad" oldKeys; machine.send_key("alt-q")
}; machine.wait_for_file("/tmp/oldXMonad")
}; machine.wait_for_window("${user.name}.*machine")
machine.sleep(1)
machine.screenshot("terminal2")
testScript = # /tmp/somefile should not exist yet
{ nodes, ... }: machine.fail("stat /tmp/somefile")
let
user = nodes.machine.config.users.users.alice;
in
''
machine.wait_for_x()
machine.wait_for_file("${user.home}/.Xauthority")
machine.succeed("xauth merge ${user.home}/.Xauthority")
machine.send_key("alt-ctrl-x")
machine.wait_for_window("${user.name}.*machine")
machine.sleep(1)
machine.screenshot("terminal1")
machine.succeed("rm /tmp/oldXMonad")
machine.send_key("alt-q")
machine.wait_for_file("/tmp/oldXMonad")
machine.wait_for_window("${user.name}.*machine")
machine.sleep(1)
machine.screenshot("terminal2")
# /tmp/somefile should not exist yet # original config has a keybinding that creates somefile
machine.fail("stat /tmp/somefile") machine.send_key("alt-ctrl-t")
machine.wait_for_file("/tmp/somefile")
# original config has a keybinding that creates somefile # set up the new config
machine.send_key("alt-ctrl-t") machine.succeed("mkdir -p ${user.home}/.xmonad")
machine.wait_for_file("/tmp/somefile") machine.copy_from_host("${newConfig}", "${user.home}/.config/xmonad/xmonad.hs")
# set up the new config # recompile xmonad using the new config
machine.succeed("mkdir -p ${user.home}/.xmonad") machine.send_key("alt-ctrl-q")
machine.copy_from_host("${newConfig}", "${user.home}/.config/xmonad/xmonad.hs") machine.wait_for_file("/tmp/newXMonad")
# recompile xmonad using the new config # new config has a keybinding that deletes somefile
machine.send_key("alt-ctrl-q") machine.send_key("alt-ctrl-r")
machine.wait_for_file("/tmp/newXMonad") machine.wait_until_fails("stat /tmp/somefile", timeout=30)
# new config has a keybinding that deletes somefile # restart with the old config, and confirm the old keybinding is back
machine.send_key("alt-ctrl-r") machine.succeed("rm /tmp/oldXMonad")
machine.wait_until_fails("stat /tmp/somefile", timeout=30) machine.send_key("alt-q")
machine.wait_for_file("/tmp/oldXMonad")
# restart with the old config, and confirm the old keybinding is back machine.send_key("alt-ctrl-t")
machine.succeed("rm /tmp/oldXMonad") machine.wait_for_file("/tmp/somefile")
machine.send_key("alt-q") '';
machine.wait_for_file("/tmp/oldXMonad") }
machine.send_key("alt-ctrl-t")
machine.wait_for_file("/tmp/somefile")
'';
}
)

View file

@ -1,21 +1,19 @@
import ./make-test-python.nix ( { lib, pkgs, ... }:
{ lib, pkgs, ... }: {
{ name = "xpadneo";
name = "xpadneo"; meta.maintainers = with lib.maintainers; [ kira-bruneau ];
meta.maintainers = with lib.maintainers; [ kira-bruneau ];
nodes = { nodes = {
machine = { machine = {
config.hardware.xpadneo.enable = true; config.hardware.xpadneo.enable = true;
};
}; };
};
# This is just a sanity check to make sure the module was # This is just a sanity check to make sure the module was
# loaded. We'd have to find some way to mock an xbox controller if # loaded. We'd have to find some way to mock an xbox controller if
# we wanted more in-depth testing. # we wanted more in-depth testing.
testScript = '' testScript = ''
machine.start(); machine.start();
machine.succeed("modinfo hid_xpadneo | grep 'version:\s\+${pkgs.linuxPackages.xpadneo.version}'") machine.succeed("modinfo hid_xpadneo | grep 'version:\s\+${pkgs.linuxPackages.xpadneo.version}'")
''; '';
} }
)

View file

@ -1,110 +1,108 @@
import ./make-test-python.nix ( { pkgs, ... }:
{ pkgs, ... }: {
{ # How to interactively test this module if the audio actually works
# How to interactively test this module if the audio actually works
# - nix run .#pulseaudio-module-xrdp.tests.xrdp-with-audio-pulseaudio.driverInteractive # - nix run .#pulseaudio-module-xrdp.tests.xrdp-with-audio-pulseaudio.driverInteractive
# - test_script() # launches the terminal and the tests itself # - test_script() # launches the terminal and the tests itself
# - server.send_monitor_command("hostfwd_add tcp::3389-:3389") # forward the RDP port to the host # - server.send_monitor_command("hostfwd_add tcp::3389-:3389") # forward the RDP port to the host
# - Connect with the RDP client you like (ex: Remmina) # - Connect with the RDP client you like (ex: Remmina)
# - Don't forget to enable audio support. In remmina: Advanced -> Audio output mode to Local (default is Off) # - Don't forget to enable audio support. In remmina: Advanced -> Audio output mode to Local (default is Off)
# - Open a browser or something that plays sound. Ex: chromium # - Open a browser or something that plays sound. Ex: chromium
name = "xrdp-with-audio-pulseaudio"; name = "xrdp-with-audio-pulseaudio";
meta = with pkgs.lib.maintainers; { meta = with pkgs.lib.maintainers; {
maintainers = [ lucasew ]; maintainers = [ lucasew ];
}; };
nodes = { nodes = {
server = server =
{ pkgs, ... }: { pkgs, ... }:
{ {
imports = [ ./common/user-account.nix ]; imports = [ ./common/user-account.nix ];
environment.etc."xrdp/test.txt".text = "Shouldn't conflict"; environment.etc."xrdp/test.txt".text = "Shouldn't conflict";
services.xrdp.enable = true; services.xrdp.enable = true;
services.xrdp.audio.enable = true; services.xrdp.audio.enable = true;
services.xrdp.defaultWindowManager = "${pkgs.xterm}/bin/xterm"; services.xrdp.defaultWindowManager = "${pkgs.xterm}/bin/xterm";
services.pulseaudio = { services.pulseaudio = {
enable = true; enable = true;
}; };
systemd.user.services.pactl-list = { systemd.user.services.pactl-list = {
script = '' script = ''
while [ ! -S /tmp/.xrdp/xrdp_chansrv_audio_in_socket_* ]; do while [ ! -S /tmp/.xrdp/xrdp_chansrv_audio_in_socket_* ]; do
sleep 1
done
sleep 1 sleep 1
${pkgs.pulseaudio}/bin/pactl list done
echo Source: sleep 1
${pkgs.pulseaudio}/bin/pactl get-default-source | tee /tmp/pulseaudio-source ${pkgs.pulseaudio}/bin/pactl list
echo Sink: echo Source:
${pkgs.pulseaudio}/bin/pactl get-default-sink | tee /tmp/pulseaudio-sink ${pkgs.pulseaudio}/bin/pactl get-default-source | tee /tmp/pulseaudio-source
echo Sink:
${pkgs.pulseaudio}/bin/pactl get-default-sink | tee /tmp/pulseaudio-sink
''; '';
wantedBy = [ "default.target" ]; wantedBy = [ "default.target" ];
};
networking.firewall.allowedTCPPorts = [ 3389 ];
}; };
client = networking.firewall.allowedTCPPorts = [ 3389 ];
{ pkgs, ... }: };
{
imports = [
./common/x11.nix
./common/user-account.nix
];
test-support.displayManager.auto.user = "alice";
environment.systemPackages = [ pkgs.freerdp ]; client =
{ pkgs, ... }:
{
imports = [
./common/x11.nix
./common/user-account.nix
];
test-support.displayManager.auto.user = "alice";
services.xrdp.enable = true; environment.systemPackages = [ pkgs.freerdp ];
services.xrdp.audio.enable = true;
services.xrdp.defaultWindowManager = "${pkgs.icewm}/bin/icewm";
services.pulseaudio = { services.xrdp.enable = true;
enable = true; services.xrdp.audio.enable = true;
}; services.xrdp.defaultWindowManager = "${pkgs.icewm}/bin/icewm";
services.pulseaudio = {
enable = true;
}; };
}; };
};
testScript = testScript =
{ nodes, ... }: { nodes, ... }:
let let
user = nodes.client.config.users.users.alice; user = nodes.client.config.users.users.alice;
in in
'' ''
start_all() start_all()
client.wait_for_x() client.wait_for_x()
client.wait_for_file("${user.home}/.Xauthority") client.wait_for_file("${user.home}/.Xauthority")
client.succeed("xauth merge ${user.home}/.Xauthority") client.succeed("xauth merge ${user.home}/.Xauthority")
client.sleep(5) client.sleep(5)
client.execute("xterm >&2 &") client.execute("xterm >&2 &")
client.sleep(1) client.sleep(1)
client.send_chars("xfreerdp /cert-tofu /w:640 /h:480 /v:127.0.0.1 /u:${user.name} /p:${user.password} /sound\n") client.send_chars("xfreerdp /cert-tofu /w:640 /h:480 /v:127.0.0.1 /u:${user.name} /p:${user.password} /sound\n")
client.sleep(10) client.sleep(10)
client.succeed("[ -S /tmp/.xrdp/xrdp_chansrv_audio_in_socket_* ]") # checks if it's a socket client.succeed("[ -S /tmp/.xrdp/xrdp_chansrv_audio_in_socket_* ]") # checks if it's a socket
client.sleep(5) client.sleep(5)
client.screenshot("localrdp") client.screenshot("localrdp")
client.execute("xterm >&2 &") client.execute("xterm >&2 &")
client.sleep(1) client.sleep(1)
client.send_chars("xfreerdp /cert-tofu /w:640 /h:480 /v:server /u:${user.name} /p:${user.password} /sound\n") client.send_chars("xfreerdp /cert-tofu /w:640 /h:480 /v:server /u:${user.name} /p:${user.password} /sound\n")
client.sleep(10) client.sleep(10)
server.succeed("[ -S /tmp/.xrdp/xrdp_chansrv_audio_in_socket_* ]") # checks if it's a socket server.succeed("[ -S /tmp/.xrdp/xrdp_chansrv_audio_in_socket_* ]") # checks if it's a socket
server.succeed('[ "$(cat /tmp/pulseaudio-source)" == "xrdp-source" ]') server.succeed('[ "$(cat /tmp/pulseaudio-source)" == "xrdp-source" ]')
server.succeed('[ "$(cat /tmp/pulseaudio-sink)" == "xrdp-sink" ]') server.succeed('[ "$(cat /tmp/pulseaudio-sink)" == "xrdp-sink" ]')
client.screenshot("remoterdp") client.screenshot("remoterdp")
''; '';
} }
)

View file

@ -1,60 +1,58 @@
import ./make-test-python.nix ( { pkgs, ... }:
{ pkgs, ... }: {
{ name = "xrdp";
name = "xrdp"; meta = with pkgs.lib.maintainers; {
meta = with pkgs.lib.maintainers; { maintainers = [ ];
maintainers = [ ]; };
};
nodes = { nodes = {
server = server =
{ pkgs, ... }: { pkgs, ... }:
{ {
imports = [ ./common/user-account.nix ]; imports = [ ./common/user-account.nix ];
services.xrdp.enable = true; services.xrdp.enable = true;
services.xrdp.defaultWindowManager = "${pkgs.xterm}/bin/xterm"; services.xrdp.defaultWindowManager = "${pkgs.xterm}/bin/xterm";
networking.firewall.allowedTCPPorts = [ 3389 ]; networking.firewall.allowedTCPPorts = [ 3389 ];
}; };
client = client =
{ pkgs, ... }: { pkgs, ... }:
{ {
imports = [ imports = [
./common/x11.nix ./common/x11.nix
./common/user-account.nix ./common/user-account.nix
]; ];
test-support.displayManager.auto.user = "alice"; test-support.displayManager.auto.user = "alice";
environment.systemPackages = [ pkgs.freerdp ]; environment.systemPackages = [ pkgs.freerdp ];
services.xrdp.enable = true; services.xrdp.enable = true;
services.xrdp.defaultWindowManager = "${pkgs.icewm}/bin/icewm"; services.xrdp.defaultWindowManager = "${pkgs.icewm}/bin/icewm";
}; };
}; };
testScript = testScript =
{ nodes, ... }: { nodes, ... }:
let let
user = nodes.client.config.users.users.alice; user = nodes.client.users.users.alice;
in in
'' ''
start_all() start_all()
client.wait_for_x() client.wait_for_x()
client.wait_for_file("${user.home}/.Xauthority") client.wait_for_file("${user.home}/.Xauthority")
client.succeed("xauth merge ${user.home}/.Xauthority") client.succeed("xauth merge ${user.home}/.Xauthority")
client.sleep(5) client.sleep(5)
client.execute("xterm >&2 &") client.execute("xterm >&2 &")
client.sleep(1) client.sleep(1)
client.send_chars("xfreerdp /cert-tofu /w:640 /h:480 /v:127.0.0.1 /u:${user.name} /p:${user.password}\n") client.send_chars("xfreerdp /cert-tofu /w:640 /h:480 /v:127.0.0.1 /u:${user.name} /p:${user.password}\n")
client.sleep(5) client.sleep(5)
client.screenshot("localrdp") client.screenshot("localrdp")
client.execute("xterm >&2 &") client.execute("xterm >&2 &")
client.sleep(1) client.sleep(1)
client.send_chars("xfreerdp /cert-tofu /w:640 /h:480 /v:server /u:${user.name} /p:${user.password}\n") client.send_chars("xfreerdp /cert-tofu /w:640 /h:480 /v:server /u:${user.name} /p:${user.password}\n")
client.sleep(5) client.sleep(5)
client.screenshot("remoterdp") client.screenshot("remoterdp")
''; '';
} }
)

View file

@ -1,54 +1,51 @@
import ./make-test-python.nix ( {
{ pkgs, lib, ... }: name = "xss-lock";
{ meta.maintainers = [ ];
name = "xss-lock";
meta.maintainers = [ ];
nodes = { nodes = {
simple = { simple = {
imports = [
./common/x11.nix
./common/user-account.nix
];
programs.xss-lock.enable = true;
test-support.displayManager.auto.user = "alice";
};
custom_lockcmd =
{ pkgs, ... }:
{
imports = [ imports = [
./common/x11.nix ./common/x11.nix
./common/user-account.nix ./common/user-account.nix
]; ];
programs.xss-lock.enable = true;
test-support.displayManager.auto.user = "alice"; test-support.displayManager.auto.user = "alice";
};
custom_lockcmd = programs.xss-lock = {
{ pkgs, ... }: enable = true;
{ extraOptions = [
imports = [ "-n"
./common/x11.nix "${pkgs.libnotify}/bin/notify-send 'About to sleep!'"
./common/user-account.nix
]; ];
test-support.displayManager.auto.user = "alice"; lockerCommand = "${pkgs.xlockmore}/bin/xlock -mode ant";
programs.xss-lock = {
enable = true;
extraOptions = [
"-n"
"${pkgs.libnotify}/bin/notify-send 'About to sleep!'"
];
lockerCommand = "${pkgs.xlockmore}/bin/xlock -mode ant";
};
}; };
}; };
};
testScript = '' testScript = ''
def perform_xsslock_test(machine, lockCmd): def perform_xsslock_test(machine, lockCmd):
machine.start() machine.start()
machine.wait_for_x() machine.wait_for_x()
machine.wait_for_unit("xss-lock.service", "alice") machine.wait_for_unit("xss-lock.service", "alice")
machine.fail(f"pgrep {lockCmd}") machine.fail(f"pgrep {lockCmd}")
machine.succeed("su -l alice -c 'xset dpms force standby'") machine.succeed("su -l alice -c 'xset dpms force standby'")
machine.wait_until_succeeds(f"pgrep {lockCmd}") machine.wait_until_succeeds(f"pgrep {lockCmd}")
with subtest("simple"): with subtest("simple"):
perform_xsslock_test(simple, "i3lock") perform_xsslock_test(simple, "i3lock")
with subtest("custom_cmd"): with subtest("custom_cmd"):
perform_xsslock_test(custom_lockcmd, "xlock") perform_xsslock_test(custom_lockcmd, "xlock")
''; '';
} }
)

View file

@ -1,26 +1,22 @@
import ./make-test-python.nix ( { pkgs, ... }:
{ pkgs, ... }: {
{ name = "xterm";
name = "xterm"; meta = with pkgs.lib.maintainers; {
meta = with pkgs.lib.maintainers; { maintainers = [ nequissimus ];
maintainers = [ nequissimus ]; };
};
nodes.machine = nodes.machine = {
{ pkgs, ... }: imports = [ ./common/x11.nix ];
{ services.xserver.desktopManager.xterm.enable = false;
imports = [ ./common/x11.nix ]; };
services.xserver.desktopManager.xterm.enable = false;
};
testScript = '' testScript = ''
machine.wait_for_x() machine.wait_for_x()
machine.succeed("DISPLAY=:0 xterm -title testterm -class testterm -fullscreen >&2 &") machine.succeed("DISPLAY=:0 xterm -title testterm -class testterm -fullscreen >&2 &")
machine.sleep(2) machine.sleep(2)
machine.send_chars("echo $XTERM_VERSION >> /tmp/xterm_version\n") machine.send_chars("echo $XTERM_VERSION >> /tmp/xterm_version\n")
machine.wait_for_file("/tmp/xterm_version") machine.wait_for_file("/tmp/xterm_version")
assert "${pkgs.xterm.version}" in machine.succeed("cat /tmp/xterm_version") assert "${pkgs.xterm.version}" in machine.succeed("cat /tmp/xterm_version")
machine.screenshot("window") machine.screenshot("window")
''; '';
} }
)

View file

@ -1,76 +1,74 @@
import ./make-test-python.nix ( { pkgs, lib, ... }:
{ pkgs, lib, ... }:
let let
inherit (import ./ssh-keys.nix pkgs) snakeOilPrivateKey snakeOilPublicKey; inherit (import ./ssh-keys.nix pkgs) snakeOilPrivateKey snakeOilPublicKey;
xxh-shell-zsh = pkgs.stdenv.mkDerivation { xxh-shell-zsh = pkgs.stdenv.mkDerivation {
pname = "xxh-shell-zsh"; pname = "xxh-shell-zsh";
version = ""; version = "";
src = pkgs.fetchFromGitHub { src = pkgs.fetchFromGitHub {
owner = "xxh"; owner = "xxh";
repo = "xxh-shell-zsh"; repo = "xxh-shell-zsh";
# gets rarely updated, we can then just replace the hash # gets rarely updated, we can then just replace the hash
rev = "91e1f84f8d6e0852c3235d4813f341230cac439f"; rev = "91e1f84f8d6e0852c3235d4813f341230cac439f";
sha256 = "sha256-Y1FrIRxTd0yooK+ZzKcCd6bLSy5E2fRXYAzrIsm7rIc="; sha256 = "sha256-Y1FrIRxTd0yooK+ZzKcCd6bLSy5E2fRXYAzrIsm7rIc=";
};
postPatch = ''
substituteInPlace build.sh \
--replace "echo Install wget or curl" "cp ${zsh-portable-binary} zsh-5.8-linux-x86_64.tar.gz" \
--replace "command -v curl" "command -v this-should-not-trigger"
'';
installPhase = ''
mkdir -p $out
mv * $out/
'';
};
zsh-portable-binary = pkgs.fetchurl {
# kept in sync with https://github.com/xxh/xxh-shell-zsh/tree/master/build.sh#L27
url = "https://github.com/romkatv/zsh-bin/releases/download/v3.0.1/zsh-5.8-linux-x86_64.tar.gz";
sha256 = "sha256-i8flMd2Isc0uLoeYQNDnOGb/kK3oTFVqQgIx7aOAIIo=";
};
in
{
name = "xxh";
meta = with lib.maintainers; {
maintainers = [ lom ];
};
nodes = {
server =
{ ... }:
{
services.openssh.enable = true;
users.users.root.openssh.authorizedKeys.keys = [ snakeOilPublicKey ];
}; };
postPatch = '' client =
substituteInPlace build.sh \ { ... }:
--replace "echo Install wget or curl" "cp ${zsh-portable-binary} zsh-5.8-linux-x86_64.tar.gz" \ {
--replace "command -v curl" "command -v this-should-not-trigger" programs.zsh.enable = true;
''; users.users.root.shell = pkgs.zsh;
environment.systemPackages = with pkgs; [
xxh
git
];
};
};
installPhase = '' testScript = ''
mkdir -p $out start_all()
mv * $out/
'';
};
zsh-portable-binary = pkgs.fetchurl { client.succeed("mkdir -m 700 /root/.ssh")
# kept in sync with https://github.com/xxh/xxh-shell-zsh/tree/master/build.sh#L27
url = "https://github.com/romkatv/zsh-bin/releases/download/v3.0.1/zsh-5.8-linux-x86_64.tar.gz";
sha256 = "sha256-i8flMd2Isc0uLoeYQNDnOGb/kK3oTFVqQgIx7aOAIIo=";
};
in
{
name = "xxh";
meta = with lib.maintainers; {
maintainers = [ lom ];
};
nodes = { client.succeed(
server = "cat ${snakeOilPrivateKey} > /root/.ssh/id_ecdsa"
{ ... }: )
{ client.succeed("chmod 600 /root/.ssh/id_ecdsa")
services.openssh.enable = true;
users.users.root.openssh.authorizedKeys.keys = [ snakeOilPublicKey ];
};
client = server.wait_for_unit("sshd")
{ ... }:
{
programs.zsh.enable = true;
users.users.root.shell = pkgs.zsh;
environment.systemPackages = with pkgs; [
xxh
git
];
};
};
testScript = '' client.succeed("xxh server -i /root/.ssh/id_ecdsa +hc \'echo $0\' +i +s zsh +I xxh-shell-zsh+path+${xxh-shell-zsh} | grep -Fq '/root/.xxh/.xxh/shells/xxh-shell-zsh/build/zsh-bin/bin/zsh'")
start_all() '';
}
client.succeed("mkdir -m 700 /root/.ssh")
client.succeed(
"cat ${snakeOilPrivateKey} > /root/.ssh/id_ecdsa"
)
client.succeed("chmod 600 /root/.ssh/id_ecdsa")
server.wait_for_unit("sshd")
client.succeed("xxh server -i /root/.ssh/id_ecdsa +hc \'echo $0\' +i +s zsh +I xxh-shell-zsh+path+${xxh-shell-zsh} | grep -Fq '/root/.xxh/.xxh/shells/xxh-shell-zsh/build/zsh-bin/bin/zsh'")
'';
}
)

View file

@ -1,33 +1,30 @@
import ./make-test-python.nix ( {
{ pkgs, lib, ... }: name = "yabar";
{ meta.maintainers = [ ];
name = "yabar";
meta.maintainers = [ ];
nodes.machine = { nodes.machine = {
imports = [ imports = [
./common/x11.nix ./common/x11.nix
./common/user-account.nix ./common/user-account.nix
]; ];
test-support.displayManager.auto.user = "bob"; test-support.displayManager.auto.user = "bob";
programs.yabar.enable = true; programs.yabar.enable = true;
programs.yabar.bars = { programs.yabar.bars = {
top.indicators.date.exec = "YABAR_DATE"; top.indicators.date.exec = "YABAR_DATE";
};
}; };
};
testScript = '' testScript = ''
machine.start() machine.start()
machine.wait_for_x() machine.wait_for_x()
# confirm proper startup # confirm proper startup
machine.wait_for_unit("yabar.service", "bob") machine.wait_for_unit("yabar.service", "bob")
machine.sleep(10) machine.sleep(10)
machine.wait_for_unit("yabar.service", "bob") machine.wait_for_unit("yabar.service", "bob")
machine.screenshot("top_bar") machine.screenshot("top_bar")
''; '';
} }
)

View file

@ -25,173 +25,169 @@ let
danIp6 = bobPrefix + "::2"; danIp6 = bobPrefix + "::2";
in in
import ./make-test-python.nix ( { pkgs, ... }:
{ pkgs, ... }: {
{ name = "yggdrasil";
name = "yggdrasil"; meta = with pkgs.lib.maintainers; {
meta = with pkgs.lib.maintainers; { maintainers = [ gazally ];
maintainers = [ gazally ]; };
};
nodes = rec { nodes = {
# Alice is listening for peerings on a specified port, # Alice is listening for peerings on a specified port,
# but has multicast peering disabled. Alice has part of her # but has multicast peering disabled. Alice has part of her
# yggdrasil config in Nix and part of it in a file. # yggdrasil config in Nix and part of it in a file.
alice = alice =
{ ... }: { ... }:
{ {
networking = { networking = {
interfaces.eth1.ipv4.addresses = [ interfaces.eth1.ipv4.addresses = [
{ {
address = "192.168.1.200"; address = "192.168.1.200";
prefixLength = 24; prefixLength = 24;
} }
]; ];
firewall.allowedTCPPorts = [ firewall.allowedTCPPorts = [
80 80
12345 12345
]; ];
};
services.httpd.enable = true;
services.httpd.adminAddr = "foo@example.org";
services.yggdrasil = {
enable = true;
settings = {
Listen = [ "tcp://0.0.0.0:12345" ];
MulticastInterfaces = [ ];
}; };
services.httpd.enable = true; configFile = toString (
services.httpd.adminAddr = "foo@example.org"; pkgs.writeTextFile {
name = "yggdrasil-alice-conf";
text = builtins.toJSON aliceKeys;
}
);
};
};
services.yggdrasil = { # Bob is set up to peer with Alice, and also to do local multicast
enable = true; # peering. Bob's yggdrasil config is in a file.
settings = { bob =
Listen = [ "tcp://0.0.0.0:12345" ]; { ... }:
MulticastInterfaces = [ ]; {
}; networking.firewall.allowedTCPPorts = [ 54321 ];
configFile = toString ( services.yggdrasil = {
pkgs.writeTextFile { enable = true;
name = "yggdrasil-alice-conf"; openMulticastPort = true;
text = builtins.toJSON aliceKeys; configFile = toString (
pkgs.writeTextFile {
name = "yggdrasil-bob-conf";
text = builtins.toJSON bobConfig;
}
);
};
boot.kernel.sysctl."net.ipv6.conf.all.forwarding" = 1;
networking = {
bridges.br0.interfaces = [ ];
interfaces.br0 = {
ipv6.addresses = [
{
address = bobPrefix + "::1";
prefixLength = 64;
} }
); ];
}; };
}; };
# Bob is set up to peer with Alice, and also to do local multicast # dan is a node inside a container running on bob's host.
# peering. Bob's yggdrasil config is in a file. containers.dan = {
bob = autoStart = true;
{ ... }: privateNetwork = true;
{ hostBridge = "br0";
networking.firewall.allowedTCPPorts = [ 54321 ]; config = {
services.yggdrasil = { networking.interfaces.eth0.ipv6 = {
enable = true; addresses = [
openMulticastPort = true;
configFile = toString (
pkgs.writeTextFile {
name = "yggdrasil-bob-conf";
text = builtins.toJSON bobConfig;
}
);
};
boot.kernel.sysctl."net.ipv6.conf.all.forwarding" = 1;
networking = {
bridges.br0.interfaces = [ ];
interfaces.br0 = {
ipv6.addresses = [
{ {
address = bobPrefix + "::1"; address = bobPrefix + "::2";
prefixLength = 64; prefixLength = 64;
} }
]; ];
}; routes = [
};
# dan is a node inside a container running on bob's host.
containers.dan = {
autoStart = true;
privateNetwork = true;
hostBridge = "br0";
config =
{ config, pkgs, ... }:
{
networking.interfaces.eth0.ipv6 = {
addresses = [
{
address = bobPrefix + "::2";
prefixLength = 64;
}
];
routes = [
{
address = "200::";
prefixLength = 7;
via = bobPrefix + "::1";
}
];
};
services.httpd.enable = true;
services.httpd.adminAddr = "foo@example.org";
networking.firewall.allowedTCPPorts = [ 80 ];
};
};
};
# Carol only does local peering. Carol's yggdrasil config is all Nix.
carol =
{ ... }:
{
networking.firewall.allowedTCPPorts = [ 43210 ];
services.yggdrasil = {
enable = true;
extraArgs = [
"-loglevel"
"error"
];
denyDhcpcdInterfaces = [ "ygg0" ];
settings = {
IfTAPMode = true;
IfName = "ygg0";
MulticastInterfaces = [
{ {
Port = 43210; address = "200::";
prefixLength = 7;
via = bobPrefix + "::1";
} }
]; ];
openMulticastPort = true;
}; };
persistentKeys = true; services.httpd.enable = true;
services.httpd.adminAddr = "foo@example.org";
networking.firewall.allowedTCPPorts = [ 80 ];
}; };
}; };
}; };
testScript = '' # Carol only does local peering. Carol's yggdrasil config is all Nix.
import re carol =
{ ... }:
{
networking.firewall.allowedTCPPorts = [ 43210 ];
services.yggdrasil = {
enable = true;
extraArgs = [
"-loglevel"
"error"
];
denyDhcpcdInterfaces = [ "ygg0" ];
settings = {
IfTAPMode = true;
IfName = "ygg0";
MulticastInterfaces = [
{
Port = 43210;
}
];
openMulticastPort = true;
};
persistentKeys = true;
};
};
};
# Give Alice a head start so she is ready when Bob calls. testScript = ''
alice.start() import re
alice.wait_for_unit("yggdrasil.service")
bob.start() # Give Alice a head start so she is ready when Bob calls.
carol.start() alice.start()
bob.wait_for_unit("default.target") alice.wait_for_unit("yggdrasil.service")
carol.wait_for_unit("yggdrasil.service")
ip_addr_show = "ip -o -6 addr show dev ygg0 scope global" bob.start()
carol.wait_until_succeeds(f"[ `{ip_addr_show} | grep -v tentative | wc -l` -ge 1 ]") carol.start()
carol_ip6 = re.split(" +|/", carol.succeed(ip_addr_show))[3] bob.wait_for_unit("default.target")
carol.wait_for_unit("yggdrasil.service")
# If Alice can talk to Carol, then Bob's outbound peering and Carol's ip_addr_show = "ip -o -6 addr show dev ygg0 scope global"
# local peering have succeeded and everybody is connected. carol.wait_until_succeeds(f"[ `{ip_addr_show} | grep -v tentative | wc -l` -ge 1 ]")
alice.wait_until_succeeds(f"ping -c 1 {carol_ip6}") carol_ip6 = re.split(" +|/", carol.succeed(ip_addr_show))[3]
alice.succeed("ping -c 1 ${bobIp6}")
bob.succeed("ping -c 1 ${aliceIp6}") # If Alice can talk to Carol, then Bob's outbound peering and Carol's
bob.succeed(f"ping -c 1 {carol_ip6}") # local peering have succeeded and everybody is connected.
alice.wait_until_succeeds(f"ping -c 1 {carol_ip6}")
alice.succeed("ping -c 1 ${bobIp6}")
carol.succeed("ping -c 1 ${aliceIp6}") bob.succeed("ping -c 1 ${aliceIp6}")
carol.succeed("ping -c 1 ${bobIp6}") bob.succeed(f"ping -c 1 {carol_ip6}")
carol.succeed("ping -c 1 ${bobPrefix}::1")
carol.succeed("ping -c 8 ${danIp6}")
carol.fail("journalctl -u dhcpcd | grep ygg0") carol.succeed("ping -c 1 ${aliceIp6}")
carol.succeed("ping -c 1 ${bobIp6}")
carol.succeed("ping -c 1 ${bobPrefix}::1")
carol.succeed("ping -c 8 ${danIp6}")
alice.wait_for_unit("httpd.service") carol.fail("journalctl -u dhcpcd | grep ygg0")
carol.succeed("curl --fail -g http://[${aliceIp6}]")
carol.succeed("curl --fail -g http://[${danIp6}]") alice.wait_for_unit("httpd.service")
''; carol.succeed("curl --fail -g http://[${aliceIp6}]")
} carol.succeed("curl --fail -g http://[${danIp6}]")
) '';
}

View file

@ -1,36 +1,34 @@
import ./make-test-python.nix ( { pkgs, ... }:
{ pkgs, ... }: {
{ name = "your_spotify";
name = "your_spotify"; meta = with pkgs.lib.maintainers; {
meta = with pkgs.lib.maintainers; { maintainers = [ patrickdag ];
maintainers = [ patrickdag ]; };
};
nodes.machine = { nodes.machine = {
services.your_spotify = { services.your_spotify = {
enable = true; enable = true;
spotifySecretFile = pkgs.writeText "spotifySecretFile" "deadbeef"; spotifySecretFile = pkgs.writeText "spotifySecretFile" "deadbeef";
settings = { settings = {
CLIENT_ENDPOINT = "http://localhost"; CLIENT_ENDPOINT = "http://localhost";
API_ENDPOINT = "http://localhost:3000"; API_ENDPOINT = "http://localhost:3000";
SPOTIFY_PUBLIC = "beefdead"; SPOTIFY_PUBLIC = "beefdead";
};
enableLocalDB = true;
nginxVirtualHost = "localhost";
}; };
enableLocalDB = true;
nginxVirtualHost = "localhost";
}; };
};
testScript = '' testScript = ''
machine.wait_for_unit("your_spotify.service") machine.wait_for_unit("your_spotify.service")
machine.wait_for_open_port(3000) machine.wait_for_open_port(3000)
machine.wait_for_open_port(80) machine.wait_for_open_port(80)
out = machine.succeed("curl --fail -X GET 'http://localhost:3000/'") out = machine.succeed("curl --fail -X GET 'http://localhost:3000/'")
assert "Hello !" in out assert "Hello !" in out
out = machine.succeed("curl --fail -X GET 'http://localhost:80/'") out = machine.succeed("curl --fail -X GET 'http://localhost:80/'")
assert "<title>Your Spotify</title>" in out assert "<title>Your Spotify</title>" in out
''; '';
} }
)

View file

@ -1,42 +1,38 @@
import ./make-test-python.nix ( { lib, pkgs, ... }:
{ lib, pkgs, ... }:
{ {
name = "zammad"; name = "zammad";
meta.maintainers = with lib.maintainers; [ meta.maintainers = with lib.maintainers; [
taeer taeer
netali netali
]; ];
nodes.machine = nodes.machine = {
{ config, ... }: virtualisation = {
{ memorySize = 2048;
virtualisation = { };
memorySize = 2048;
};
services.zammad.enable = true; services.zammad.enable = true;
services.zammad.secretKeyBaseFile = pkgs.writeText "secret" '' services.zammad.secretKeyBaseFile = pkgs.writeText "secret" ''
52882ef142066e09ab99ce816ba72522e789505caba224a52d750ec7dc872c2c371b2fd19f16b25dfbdd435a4dd46cb3df9f82eb63fafad715056bdfe25740d6 52882ef142066e09ab99ce816ba72522e789505caba224a52d750ec7dc872c2c371b2fd19f16b25dfbdd435a4dd46cb3df9f82eb63fafad715056bdfe25740d6
'';
};
testScript = ''
start_all()
machine.wait_for_unit("postgresql.service")
machine.wait_for_unit("redis-zammad.service")
machine.wait_for_unit("zammad-web.service")
machine.wait_for_unit("zammad-websocket.service")
machine.wait_for_unit("zammad-worker.service")
# wait for zammad to fully come up
machine.sleep(120)
# without the grep the command does not produce valid utf-8 for some reason
with subtest("welcome screen loads"):
machine.succeed(
"curl -sSfL http://localhost:3000/ | grep '<title>Zammad Helpdesk</title>'"
)
''; '';
} };
)
testScript = ''
start_all()
machine.wait_for_unit("postgresql.service")
machine.wait_for_unit("redis-zammad.service")
machine.wait_for_unit("zammad-web.service")
machine.wait_for_unit("zammad-websocket.service")
machine.wait_for_unit("zammad-worker.service")
# wait for zammad to fully come up
machine.sleep(120)
# without the grep the command does not produce valid utf-8 for some reason
with subtest("welcome screen loads"):
machine.succeed(
"curl -sSfL http://localhost:3000/ | grep '<title>Zammad Helpdesk</title>'"
)
'';
}

View file

@ -1,71 +1,68 @@
import ./make-test-python.nix ( { pkgs, lib, ... }:
{ pkgs, lib, ... }:
{ {
name = "zenohd"; name = "zenohd";
meta.maintainers = [ lib.maintainers.markuskowa ]; meta.maintainers = [ lib.maintainers.markuskowa ];
nodes = { nodes = {
router = router =
{ {
pkgs, pkgs,
lib, config,
config, ...
... }:
}: {
{ networking.firewall.allowedTCPPorts = [
networking.firewall.allowedTCPPorts = [ 7447 # zenohd default port
7447 # zenohd default port config.services.zenohd.settings.plugins.mqtt.port
config.services.zenohd.settings.plugins.mqtt.port config.services.zenohd.settings.plugins.webserver.http_port
config.services.zenohd.settings.plugins.webserver.http_port ];
services.zenohd = {
enable = true;
plugins = with pkgs; [
zenoh-plugin-mqtt
zenoh-plugin-webserver
]; ];
services.zenohd = { backends = with pkgs; [
enable = true; zenoh-backend-filesystem
zenoh-backend-rocksdb
];
plugins = with pkgs; [ settings = {
zenoh-plugin-mqtt plugins = {
zenoh-plugin-webserver mqtt = {
]; port = 1883;
allow = ".*";
backends = with pkgs; [ };
zenoh-backend-filesystem webserver.http_port = 8000;
zenoh-backend-rocksdb storage_manager = {
]; volumes = {
fs = { };
settings = { rocksdb = { };
plugins = {
mqtt = {
port = 1883;
allow = ".*";
}; };
webserver.http_port = 8000; storages = {
storage_manager = { mem = {
volumes = { key_expr = "mem/**";
fs = { }; volume = "memory";
rocksdb = { };
}; };
storages = { fs = {
mem = { key_expr = "fs/**";
key_expr = "mem/**"; volume = {
volume = "memory"; id = "fs";
dir = "zenoh-fs";
strip_prefix = "fs";
}; };
fs = { };
key_expr = "fs/**"; rocksdb = {
volume = { key_expr = "rocksdb/**";
id = "fs"; volume = {
dir = "zenoh-fs"; id = "rocksdb";
strip_prefix = "fs"; dir = "zenoh-rocksdb";
}; strip_prefix = "rocksdb";
}; create_db = true;
rocksdb = {
key_expr = "rocksdb/**";
volume = {
id = "rocksdb";
dir = "zenoh-rocksdb";
strip_prefix = "rocksdb";
create_db = true;
};
}; };
}; };
}; };
@ -73,21 +70,21 @@ import ./make-test-python.nix (
}; };
}; };
}; };
client = {
environment.systemPackages = [
pkgs.mosquitto
];
}; };
client = {
environment.systemPackages = [
pkgs.mosquitto
];
}; };
};
testScript = '' testScript = ''
router.wait_for_unit("zenohd.service") router.wait_for_unit("zenohd.service")
client.wait_for_unit("multi-user.target") client.wait_for_unit("multi-user.target")
for be in ["fs", "rocksdb", "mem" ]: for be in ["fs", "rocksdb", "mem" ]:
client.succeed(f"mosquitto_pub -h router -t {be}/test -m hello") client.succeed(f"mosquitto_pub -h router -t {be}/test -m hello")
client.succeed(f"curl router:8000/{be}/test | grep hello") client.succeed(f"curl router:8000/{be}/test | grep hello")
''; '';
} }
)

View file

@ -1,30 +1,31 @@
{
lib,
...
}:
let let
port = 43110; port = 43110;
in in
import ./make-test-python.nix ( {
{ pkgs, ... }: name = "zeronet-conservancy";
{ meta = with lib.maintainers; {
name = "zeronet-conservancy"; maintainers = [ fgaz ];
meta = with pkgs.lib.maintainers; { };
maintainers = [ fgaz ];
nodes.machine =
{ pkgs, ... }:
{
services.zeronet = {
enable = true;
package = pkgs.zeronet-conservancy;
inherit port;
};
}; };
nodes.machine = testScript = ''
{ config, pkgs, ... }: machine.wait_for_unit("zeronet.service")
{
services.zeronet = {
enable = true;
package = pkgs.zeronet-conservancy;
inherit port;
};
};
testScript = '' machine.wait_for_open_port(${toString port})
machine.wait_for_unit("zeronet.service")
machine.wait_for_open_port(${toString port}) machine.succeed("curl --fail -H 'Accept: text/html, application/xml, */*' localhost:${toString port}/Stats")
'';
machine.succeed("curl --fail -H 'Accept: text/html, application/xml, */*' localhost:${toString port}/Stats") }
'';
}
)

View file

@ -1,44 +1,42 @@
import ./make-test-python.nix ( { lib, ... }:
{ lib, ... }: {
{ name = "zipline";
name = "zipline"; meta.maintainers = with lib.maintainers; [ defelo ];
meta.maintainers = with lib.maintainers; [ defelo ];
nodes.machine = { nodes.machine = {
services.zipline = { services.zipline = {
enable = true; enable = true;
settings = { settings = {
CORE_HOSTNAME = "127.0.0.1"; CORE_HOSTNAME = "127.0.0.1";
CORE_PORT = 8000; CORE_PORT = 8000;
};
environmentFiles = [
(builtins.toFile "zipline.env" ''
CORE_SECRET=DMlouex3W0QLRbVwkUafNnNws5jpgRDX
'')
];
}; };
environmentFiles = [
networking.hosts."127.0.0.1" = [ "zipline.local" ]; (builtins.toFile "zipline.env" ''
CORE_SECRET=DMlouex3W0QLRbVwkUafNnNws5jpgRDX
'')
];
}; };
testScript = '' networking.hosts."127.0.0.1" = [ "zipline.local" ];
import json };
import re
machine.wait_for_unit("zipline.service") testScript = ''
machine.wait_for_open_port(8000) import json
import re
resp = machine.succeed("curl zipline.local:8000/api/setup -v -X POST -H 'Content-Type: application/json' -d '{\"username\": \"administrator\", \"password\": \"password\"}' 2>&1") machine.wait_for_unit("zipline.service")
data = json.loads(resp.splitlines()[-1]) machine.wait_for_open_port(8000)
assert data["firstSetup"] is True
assert data["user"]["username"] == "administrator"
assert data["user"]["role"] == "SUPERADMIN"
resp = machine.succeed("curl zipline.local:8000/api/auth/login -v -X POST -H 'Content-Type: application/json' -d '{\"username\": \"administrator\", \"password\": \"password\"}' 2>&1") resp = machine.succeed("curl zipline.local:8000/api/setup -v -X POST -H 'Content-Type: application/json' -d '{\"username\": \"administrator\", \"password\": \"password\"}' 2>&1")
data = json.loads(resp.splitlines()[-1])
assert data["firstSetup"] is True
assert data["user"]["username"] == "administrator"
assert data["user"]["role"] == "SUPERADMIN"
assert (cookie := re.search(r"(?m)^< set-cookie: ([^;]*)", resp)) resp = machine.succeed("curl zipline.local:8000/api/auth/login -v -X POST -H 'Content-Type: application/json' -d '{\"username\": \"administrator\", \"password\": \"password\"}' 2>&1")
resp = machine.succeed(f"curl zipline.local:8000/api/user -H 'Cookie: {cookie[1]}'")
assert json.loads(resp)["user"]["id"] == data["user"]["id"] assert (cookie := re.search(r"(?m)^< set-cookie: ([^;]*)", resp))
''; resp = machine.succeed(f"curl zipline.local:8000/api/user -H 'Cookie: {cookie[1]}'")
} assert json.loads(resp)["user"]["id"] == data["user"]["id"]
) '';
}

View file

@ -1,26 +1,24 @@
import ./make-test-python.nix ( { lib, ... }:
{ lib, ... }:
{ {
name = "zoneminder"; name = "zoneminder";
meta.maintainers = with lib.maintainers; [ danielfullmer ]; meta.maintainers = with lib.maintainers; [ danielfullmer ];
nodes.machine = nodes.machine =
{ ... }: { ... }:
{ {
services.zoneminder = { services.zoneminder = {
enable = true; enable = true;
database.createLocally = true; database.createLocally = true;
database.username = "zoneminder"; database.username = "zoneminder";
};
time.timeZone = "America/New_York";
}; };
time.timeZone = "America/New_York";
};
testScript = '' testScript = ''
machine.wait_for_unit("zoneminder.service") machine.wait_for_unit("zoneminder.service")
machine.wait_for_unit("nginx.service") machine.wait_for_unit("nginx.service")
machine.wait_for_open_port(8095) machine.wait_for_open_port(8095)
machine.succeed("curl --fail http://localhost:8095/") machine.succeed("curl --fail http://localhost:8095/")
''; '';
} }
)

View file

@ -1,54 +1,52 @@
import ./make-test-python.nix ( { pkgs, ... }:
{ pkgs, ... }: let
let
perlEnv = pkgs.perl.withPackages (p: [ p.NetZooKeeper ]); perlEnv = pkgs.perl.withPackages (p: [ p.NetZooKeeper ]);
in in
{ {
name = "zookeeper"; name = "zookeeper";
meta = with pkgs.lib.maintainers; { meta = with pkgs.lib.maintainers; {
maintainers = [ maintainers = [
nequissimus nequissimus
ztzg ztzg
]; ];
}; };
nodes = { nodes = {
server = server =
{ ... }: { ... }:
{ {
services.zookeeper = { services.zookeeper = {
enable = true; enable = true;
};
networking.firewall.allowedTCPPorts = [ 2181 ];
}; };
};
testScript = '' networking.firewall.allowedTCPPorts = [ 2181 ];
start_all() };
};
server.wait_for_unit("zookeeper") testScript = ''
server.wait_for_unit("network.target") start_all()
server.wait_for_open_port(2181)
server.wait_until_succeeds( server.wait_for_unit("zookeeper")
"${pkgs.zookeeper}/bin/zkCli.sh -server localhost:2181 create /foo bar" server.wait_for_unit("network.target")
) server.wait_for_open_port(2181)
server.wait_until_succeeds(
"${pkgs.zookeeper}/bin/zkCli.sh -server localhost:2181 set /foo hello"
)
server.wait_until_succeeds(
"${pkgs.zookeeper}/bin/zkCli.sh -server localhost:2181 get /foo | grep hello"
)
server.wait_until_succeeds( server.wait_until_succeeds(
"${perlEnv}/bin/perl -E 'use Net::ZooKeeper qw(:acls); $z=Net::ZooKeeper->new(q(localhost:2181)); $z->create(qw(/perl foo acl), ZOO_OPEN_ACL_UNSAFE) || die $z->get_error()'" "${pkgs.zookeeper}/bin/zkCli.sh -server localhost:2181 create /foo bar"
) )
server.wait_until_succeeds( server.wait_until_succeeds(
"${perlEnv}/bin/perl -E 'use Net::ZooKeeper qw(:acls); $z=Net::ZooKeeper->new(q(localhost:2181)); $z->get(qw(/perl)) eq qw(foo) || die $z->get_error()'" "${pkgs.zookeeper}/bin/zkCli.sh -server localhost:2181 set /foo hello"
) )
''; server.wait_until_succeeds(
} "${pkgs.zookeeper}/bin/zkCli.sh -server localhost:2181 get /foo | grep hello"
) )
server.wait_until_succeeds(
"${perlEnv}/bin/perl -E 'use Net::ZooKeeper qw(:acls); $z=Net::ZooKeeper->new(q(localhost:2181)); $z->create(qw(/perl foo acl), ZOO_OPEN_ACL_UNSAFE) || die $z->get_error()'"
)
server.wait_until_succeeds(
"${perlEnv}/bin/perl -E 'use Net::ZooKeeper qw(:acls); $z=Net::ZooKeeper->new(q(localhost:2181)); $z->get(qw(/perl)) eq qw(foo) || die $z->get_error()'"
)
'';
}

View file

@ -1,4 +1,4 @@
import ./make-test-python.nix { {
name = "zram-generator"; name = "zram-generator";
nodes = { nodes = {

View file

@ -1,8 +1,8 @@
import ./make-test-python.nix ({ {
name = "zrepl"; name = "zrepl";
nodes.host = nodes.host =
{ config, pkgs, ... }: { pkgs, ... }:
{ {
config = { config = {
# Prerequisites for ZFS and tests. # Prerequisites for ZFS and tests.
@ -73,4 +73,4 @@ import ./make-test-python.nix ({
"zrepl_zfs_snapshot_duration_count{filesystem=\"test\"}" in out "zrepl_zfs_snapshot_duration_count{filesystem=\"test\"}" in out
), "zrepl snapshot counter for test was not found in Prometheus output" ), "zrepl snapshot counter for test was not found in Prometheus output"
''; '';
}) }

View file

@ -1,40 +1,38 @@
import ./make-test-python.nix ( { pkgs, ... }:
{ pkgs, ... }: {
{ name = "zsh-history";
name = "zsh-history"; meta = with pkgs.lib.maintainers; {
meta = with pkgs.lib.maintainers; { maintainers = [ ];
maintainers = [ ]; };
nodes.default =
{ ... }:
{
programs = {
zsh.enable = true;
};
environment.systemPackages = [ pkgs.zsh-history ];
programs.zsh.interactiveShellInit = ''
source ${pkgs.zsh-history.out}/share/zsh/init.zsh
'';
users.users.root.shell = "${pkgs.zsh}/bin/zsh";
}; };
nodes.default = testScript = ''
{ ... }: start_all()
{ default.wait_for_unit("multi-user.target")
programs = { default.wait_until_succeeds("pgrep -f 'agetty.*tty1'")
zsh.enable = true;
};
environment.systemPackages = [ pkgs.zsh-history ];
programs.zsh.interactiveShellInit = ''
source ${pkgs.zsh-history.out}/share/zsh/init.zsh
'';
users.users.root.shell = "${pkgs.zsh}/bin/zsh";
};
testScript = '' # Login
start_all() default.wait_until_tty_matches("1", "login: ")
default.wait_for_unit("multi-user.target") default.send_chars("root\n")
default.wait_until_succeeds("pgrep -f 'agetty.*tty1'") default.wait_until_tty_matches("1", r"\nroot@default\b")
# Login # Generate some history
default.wait_until_tty_matches("1", "login: ") default.send_chars("echo foobar\n")
default.send_chars("root\n") default.wait_until_tty_matches("1", "foobar")
default.wait_until_tty_matches("1", r"\nroot@default\b")
# Generate some history # Ensure that command was recorded in history
default.send_chars("echo foobar\n") default.succeed("/run/current-system/sw/bin/history list | grep -q foobar")
default.wait_until_tty_matches("1", "foobar") '';
}
# Ensure that command was recorded in history
default.succeed("/run/current-system/sw/bin/history list | grep -q foobar")
'';
}
)

View file

@ -1,31 +1,29 @@
import ./make-test-python.nix ( { lib, ... }:
{ lib, ... }: {
{ name = "zwave-js-ui";
name = "zwave-js-ui"; meta.maintainers = with lib.maintainers; [ cdombroski ];
meta.maintainers = with lib.maintainers; [ cdombroski ];
nodes = { nodes = {
machine = machine =
{ ... }: { ... }:
{ {
services.zwave-js-ui = { services.zwave-js-ui = {
enable = true; enable = true;
serialPort = "/dev/null"; serialPort = "/dev/null";
settings = { settings = {
HOST = "::"; HOST = "::";
PORT = "9999"; PORT = "9999";
};
}; };
}; };
}; };
};
testScript = '' testScript = ''
start_all() start_all()
machine.wait_for_unit("zwave-js-ui.service") machine.wait_for_unit("zwave-js-ui.service")
machine.wait_for_open_port(9999) machine.wait_for_open_port(9999)
machine.wait_until_succeeds("journalctl --since -1m --unit zwave-js-ui --grep 'Listening on port 9999host :: protocol HTTP'") machine.wait_until_succeeds("journalctl --since -1m --unit zwave-js-ui --grep 'Listening on port 9999host :: protocol HTTP'")
machine.wait_for_file("/var/lib/zwave-js-ui/users.json") machine.wait_for_file("/var/lib/zwave-js-ui/users.json")
''; '';
} }
)

View file

@ -1,38 +1,34 @@
import ./make-test-python.nix ( { pkgs, lib, ... }:
{ pkgs, lib, ... }:
let let
secretsConfigFile = pkgs.writeText "secrets.json" ( secretsConfigFile = pkgs.writeText "secrets.json" (
builtins.toJSON { builtins.toJSON {
securityKeys = { securityKeys = {
"S0_Legacy" = "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"; "S0_Legacy" = "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA";
}; };
} }
); );
in in
{ {
name = "zwave-js"; name = "zwave-js";
meta.maintainers = with lib.maintainers; [ graham33 ]; meta.maintainers = with lib.maintainers; [ graham33 ];
nodes = { nodes = {
machine = machine = {
{ config, ... }: services.zwave-js = {
{ enable = true;
services.zwave-js = { serialPort = "/dev/null";
enable = true; extraFlags = [ "--mock-driver" ];
serialPort = "/dev/null"; inherit secretsConfigFile;
extraFlags = [ "--mock-driver" ]; };
inherit secretsConfigFile;
};
};
}; };
};
testScript = '' testScript = ''
start_all() start_all()
machine.wait_for_unit("zwave-js.service") machine.wait_for_unit("zwave-js.service")
machine.wait_for_open_port(3000) machine.wait_for_open_port(3000)
machine.wait_until_succeeds("journalctl --since -1m --unit zwave-js --grep 'ZwaveJS server listening'") machine.wait_until_succeeds("journalctl --since -1m --unit zwave-js --grep 'ZwaveJS server listening'")
''; '';
} }
)