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

View file

@ -1,73 +1,71 @@
import ./make-test-python.nix (
{ pkgs, lib, ... }:
{ lib, ... }:
{
name = "xandikos";
{
name = "xandikos";
meta.maintainers = with lib.maintainers; [ _0x4A6F ];
meta.maintainers = with lib.maintainers; [ _0x4A6F ];
nodes = {
xandikos_client = { };
xandikos_default = {
networking.firewall.allowedTCPPorts = [ 8080 ];
services.xandikos.enable = true;
};
xandikos_proxy = {
networking.firewall.allowedTCPPorts = [
80
8080
];
services.xandikos.enable = true;
services.xandikos.address = "localhost";
services.xandikos.port = 8080;
services.xandikos.routePrefix = "/xandikos-prefix/";
services.xandikos.extraOptions = [
"--defaults"
];
services.nginx = {
enable = true;
recommendedProxySettings = true;
virtualHosts."xandikos" = {
serverName = "xandikos.local";
basicAuth.xandikos = "snakeOilPassword";
locations."/xandikos/" = {
proxyPass = "http://localhost:8080/xandikos-prefix/";
};
nodes = {
xandikos_client = { };
xandikos_default = {
networking.firewall.allowedTCPPorts = [ 8080 ];
services.xandikos.enable = true;
};
xandikos_proxy = {
networking.firewall.allowedTCPPorts = [
80
8080
];
services.xandikos.enable = true;
services.xandikos.address = "localhost";
services.xandikos.port = 8080;
services.xandikos.routePrefix = "/xandikos-prefix/";
services.xandikos.extraOptions = [
"--defaults"
];
services.nginx = {
enable = true;
recommendedProxySettings = true;
virtualHosts."xandikos" = {
serverName = "xandikos.local";
basicAuth.xandikos = "snakeOilPassword";
locations."/xandikos/" = {
proxyPass = "http://localhost:8080/xandikos-prefix/";
};
};
};
};
};
testScript = ''
start_all()
testScript = ''
start_all()
with subtest("Xandikos default"):
xandikos_default.wait_for_unit("multi-user.target")
xandikos_default.wait_for_unit("xandikos.service")
xandikos_default.wait_for_open_port(8080)
xandikos_default.succeed("curl --fail http://localhost:8080/")
xandikos_default.succeed(
"curl -s --fail --location http://localhost:8080/ | grep -i Xandikos"
)
xandikos_client.wait_for_unit("network.target")
xandikos_client.fail("curl --fail http://xandikos_default:8080/")
with subtest("Xandikos default"):
xandikos_default.wait_for_unit("multi-user.target")
xandikos_default.wait_for_unit("xandikos.service")
xandikos_default.wait_for_open_port(8080)
xandikos_default.succeed("curl --fail http://localhost:8080/")
xandikos_default.succeed(
"curl -s --fail --location http://localhost:8080/ | grep -i Xandikos"
)
xandikos_client.wait_for_unit("network.target")
xandikos_client.fail("curl --fail http://xandikos_default:8080/")
with subtest("Xandikos proxy"):
xandikos_proxy.wait_for_unit("multi-user.target")
xandikos_proxy.wait_for_unit("xandikos.service")
xandikos_proxy.wait_for_open_port(8080)
xandikos_proxy.succeed("curl --fail http://localhost:8080/")
xandikos_proxy.succeed(
"curl -s --fail --location http://localhost:8080/ | grep -i Xandikos"
)
xandikos_client.wait_for_unit("network.target")
xandikos_client.fail("curl --fail http://xandikos_proxy:8080/")
xandikos_client.succeed(
"curl -s --fail -u xandikos:snakeOilPassword -H 'Host: xandikos.local' http://xandikos_proxy/xandikos/ | grep -i Xandikos"
)
xandikos_client.succeed(
"curl -s --fail -u xandikos:snakeOilPassword -H 'Host: xandikos.local' http://xandikos_proxy/xandikos/user/ | grep -i Xandikos"
)
'';
}
)
with subtest("Xandikos proxy"):
xandikos_proxy.wait_for_unit("multi-user.target")
xandikos_proxy.wait_for_unit("xandikos.service")
xandikos_proxy.wait_for_open_port(8080)
xandikos_proxy.succeed("curl --fail http://localhost:8080/")
xandikos_proxy.succeed(
"curl -s --fail --location http://localhost:8080/ | grep -i Xandikos"
)
xandikos_client.wait_for_unit("network.target")
xandikos_client.fail("curl --fail http://xandikos_proxy:8080/")
xandikos_client.succeed(
"curl -s --fail -u xandikos:snakeOilPassword -H 'Host: xandikos.local' http://xandikos_proxy/xandikos/ | grep -i Xandikos"
)
xandikos_client.succeed(
"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 = [ ];
{
name = "xautolock";
meta.maintainers = [ ];
nodes.machine = {
imports = [
./common/x11.nix
./common/user-account.nix
];
nodes.machine = {
imports = [
./common/x11.nix
./common/user-account.nix
];
test-support.displayManager.auto.user = "bob";
services.xserver.xautolock.enable = true;
services.xserver.xautolock.time = 1;
};
test-support.displayManager.auto.user = "bob";
services.xserver.xautolock.enable = true;
services.xserver.xautolock.time = 1;
};
testScript = ''
machine.start()
machine.wait_for_x()
machine.fail("pgrep xlock")
machine.sleep(120)
machine.succeed("pgrep xlock")
'';
}
)
testScript = ''
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 =
{ pkgs, ... }:
nodes.machine =
{ pkgs, ... }:
{
imports = [
./common/user-account.nix
];
{
imports = [
./common/user-account.nix
];
services.xserver.enable = true;
services.xserver.displayManager.lightdm.enable = true;
services.displayManager = {
defaultSession = "xfce-wayland";
autoLogin = {
enable = true;
user = "alice";
};
services.xserver.enable = true;
services.xserver.displayManager.lightdm.enable = true;
services.displayManager = {
defaultSession = "xfce-wayland";
autoLogin = {
enable = true;
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 =
{ 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")
enableOCR = true;
with subtest("Wait for Wayland server"):
machine.wait_for_file("/run/user/${toString user.uid}/wayland-0")
testScript =
{ 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"):
machine.succeed("getfacl -p /dev/snd/timer | grep -q ${user.name}")
with subtest("Wait for Wayland server"):
machine.wait_for_file("/run/user/${toString user.uid}/wayland-0")
with subtest("Check if Xfce components actually start"):
for p in ["labwc", "xfdesktop", "xfce4-notifyd", "xfconfd", "xfce4-panel"]:
machine.wait_until_succeeds(f"pgrep {p}")
with subtest("Check that logging in has given the user ownership of devices"):
machine.succeed("getfacl -p /dev/snd/timer | grep -q ${user.name}")
with subtest("Open Xfce terminal"):
machine.succeed("su - ${user.name} -c '${rtdir} xfce4-terminal >&2 &'")
machine.wait_until_succeeds("su - ${user.name} -c '${rtdir} wlrctl toplevel list | grep xfce4-terminal'")
with subtest("Check if Xfce components actually start"):
for p in ["labwc", "xfdesktop", "xfce4-notifyd", "xfconfd", "xfce4-panel"]:
machine.wait_until_succeeds(f"pgrep {p}")
with subtest("Open Thunar"):
machine.succeed("su - ${user.name} -c '${rtdir} thunar >&2 &'")
machine.wait_until_succeeds("su - ${user.name} -c '${rtdir} wlrctl toplevel list | grep Thunar'")
machine.wait_for_text('(Pictures|Public|Templates|Videos)')
with subtest("Open Xfce terminal"):
machine.succeed("su - ${user.name} -c '${rtdir} xfce4-terminal >&2 &'")
machine.wait_until_succeeds("su - ${user.name} -c '${rtdir} wlrctl toplevel list | grep xfce4-terminal'")
with subtest("Check if various environment variables are set"):
cmd = "xargs --null --max-args=1 echo < /proc/$(pgrep -xf xfce4-panel)/environ"
machine.succeed(f"{cmd} | grep 'XDG_SESSION_TYPE' | grep 'wayland'")
machine.succeed(f"{cmd} | grep 'XFCE4_SESSION_COMPOSITOR' | grep 'labwc'")
machine.succeed(f"{cmd} | grep 'XDG_CURRENT_DESKTOP' | grep 'XFCE'")
with subtest("Open Thunar"):
machine.succeed("su - ${user.name} -c '${rtdir} thunar >&2 &'")
machine.wait_until_succeeds("su - ${user.name} -c '${rtdir} wlrctl toplevel list | grep Thunar'")
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")
'';
}
)
with subtest("Check if various environment variables are set"):
cmd = "xargs --null --max-args=1 echo < /proc/$(pgrep -xf xfce4-panel)/environ"
machine.succeed(f"{cmd} | grep 'XDG_SESSION_TYPE' | grep 'wayland'")
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 =
{ pkgs, ... }:
nodes.machine =
{ pkgs, ... }:
{
imports = [
./common/user-account.nix
];
{
imports = [
./common/user-account.nix
];
services.xserver.enable = true;
services.xserver.displayManager.lightdm.enable = true;
services.xserver.enable = true;
services.xserver.displayManager.lightdm.enable = true;
services.displayManager.autoLogin = {
enable = true;
user = "alice";
};
services.xserver.desktopManager.xfce.enable = true;
environment.systemPackages = [ pkgs.xfce.xfce4-whiskermenu-plugin ];
services.displayManager.autoLogin = {
enable = true;
user = "alice";
};
enableOCR = true;
services.xserver.desktopManager.xfce.enable = true;
environment.systemPackages = [ pkgs.xfce.xfce4-whiskermenu-plugin ];
};
testScript =
{ 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")
enableOCR = true;
with subtest("Check that logging in has given the user ownership of devices"):
machine.succeed("getfacl -p /dev/snd/timer | grep -q ${user.name}")
testScript =
{ 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"):
machine.wait_for_window("xfce4-panel")
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("Check that logging in has given the user ownership of devices"):
machine.succeed("getfacl -p /dev/snd/timer | grep -q ${user.name}")
with subtest("Open whiskermenu"):
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.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("Check if Xfce components actually start"):
machine.wait_for_window("xfce4-panel")
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 Xfce terminal"):
machine.succeed("su - ${user.name} -c 'DISPLAY=:0 xfce4-terminal >&2 &'")
machine.wait_for_window("Terminal")
with subtest("Open whiskermenu"):
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.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"):
machine.succeed("su - ${user.name} -c 'DISPLAY=:0 thunar >&2 &'")
machine.wait_for_window("Thunar")
machine.wait_for_text('(Pictures|Public|Templates|Videos)')
with subtest("Open Xfce terminal"):
machine.succeed("su - ${user.name} -c 'DISPLAY=:0 xfce4-terminal >&2 &'")
machine.wait_for_window("Terminal")
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")
'';
}
)
with subtest("Open Thunar"):
machine.succeed("su - ${user.name} -c 'DISPLAY=:0 thunar >&2 &'")
machine.wait_for_window("Thunar")
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, ... }:
{
name = "xmonad-xdg-autostart";
meta.maintainers = with lib.maintainers; [ oxalica ];
{ lib, ... }:
{
name = "xmonad-xdg-autostart";
meta.maintainers = with lib.maintainers; [ oxalica ];
nodes.machine =
{ pkgs, config, ... }:
{
imports = [
./common/x11.nix
./common/user-account.nix
];
test-support.displayManager.auto.user = "alice";
services.displayManager.defaultSession = "none+xmonad";
services.xserver.windowManager.xmonad.enable = true;
services.xserver.desktopManager.runXdgAutostartIfNone = true;
nodes.machine =
{ pkgs, config, ... }:
{
imports = [
./common/x11.nix
./common/user-account.nix
];
test-support.displayManager.auto.user = "alice";
services.displayManager.defaultSession = "none+xmonad";
services.xserver.windowManager.xmonad.enable = true;
services.xserver.desktopManager.runXdgAutostartIfNone = true;
environment.systemPackages = [
(pkgs.writeTextFile {
name = "test-xdg-autostart";
destination = "/etc/xdg/autostart/test-xdg-autostart.desktop";
text = ''
[Desktop Entry]
Name=test-xdg-autoatart
Type=Application
Terminal=false
Exec=${pkgs.coreutils}/bin/touch ${config.users.users.alice.home}/xdg-autostart-executed
'';
})
];
};
environment.systemPackages = [
(pkgs.writeTextFile {
name = "test-xdg-autostart";
destination = "/etc/xdg/autostart/test-xdg-autostart.desktop";
text = ''
[Desktop Entry]
Name=test-xdg-autoatart
Type=Application
Terminal=false
Exec=${pkgs.coreutils}/bin/touch ${config.users.users.alice.home}/xdg-autostart-executed
'';
})
];
};
testScript =
{ nodes, ... }:
let
user = nodes.machine.config.users.users.alice;
in
''
machine.wait_for_x()
machine.wait_for_file("${user.home}/xdg-autostart-executed")
'';
}
)
testScript =
{ nodes, ... }:
let
user = nodes.machine.users.users.alice;
in
''
machine.wait_for_x()
machine.wait_for_file("${user.home}/xdg-autostart-executed")
'';
}

View file

@ -1,131 +1,129 @@
import ./make-test-python.nix (
{ pkgs, ... }:
{ pkgs, ... }:
let
mkConfig = name: keys: ''
import XMonad
import XMonad.Operations (restart)
import XMonad.Util.EZConfig
import XMonad.Util.SessionStart
import Control.Monad (when)
import Text.Printf (printf)
import System.Posix.Process (executeFile)
import System.Info (arch,os)
import System.Environment (getArgs)
import System.FilePath ((</>))
let
mkConfig = name: keys: ''
import XMonad
import XMonad.Operations (restart)
import XMonad.Util.EZConfig
import XMonad.Util.SessionStart
import Control.Monad (when)
import Text.Printf (printf)
import System.Posix.Process (executeFile)
import System.Info (arch,os)
import System.Environment (getArgs)
import System.FilePath ((</>))
main = do
dirs <- getDirectories
launch (def { startupHook = startup } `additionalKeysP` myKeys) dirs
main = do
dirs <- getDirectories
launch (def { startupHook = startup } `additionalKeysP` myKeys) dirs
startup = isSessionStart >>= \sessInit ->
spawn "touch /tmp/${name}"
>> if sessInit then setSessionStarted else spawn "xterm"
startup = isSessionStart >>= \sessInit ->
spawn "touch /tmp/${name}"
>> 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
dirs <- asks directories
compileRestart resume = do
dirs <- asks directories
whenX (recompile dirs True) $
when resume writeStateToFile
*> catchIO
( do
args <- getArgs
executeFile (cacheDir dirs </> compiledConfig) False args Nothing
)
'';
whenX (recompile dirs True) $
when resume writeStateToFile
*> catchIO
( do
args <- getArgs
executeFile (cacheDir dirs </> compiledConfig) False args Nothing
)
'';
oldKeys = [
''("M-C-x", spawn "xterm")''
''("M-q", restart "xmonad" True)''
''("M-C-q", compileRestart True)''
''("M-C-t", spawn "touch /tmp/somefile")'' # create somefile
oldKeys = [
''("M-C-x", spawn "xterm")''
''("M-q", restart "xmonad" True)''
''("M-C-q", compileRestart True)''
''("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 = [
''("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
nodes.machine =
{ pkgs, ... }:
{
imports = [
./common/x11.nix
./common/user-account.nix
];
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 =
{ pkgs, ... }:
{
imports = [
./common/x11.nix
./common/user-account.nix
];
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;
};
};
testScript =
{ nodes, ... }:
let
user = nodes.machine.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")
testScript =
{ nodes, ... }:
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
machine.fail("stat /tmp/somefile")
# /tmp/somefile should not exist yet
machine.fail("stat /tmp/somefile")
# original config has a keybinding that creates somefile
machine.send_key("alt-ctrl-t")
machine.wait_for_file("/tmp/somefile")
# original config has a keybinding that creates somefile
machine.send_key("alt-ctrl-t")
machine.wait_for_file("/tmp/somefile")
# set up the new config
machine.succeed("mkdir -p ${user.home}/.xmonad")
machine.copy_from_host("${newConfig}", "${user.home}/.config/xmonad/xmonad.hs")
# set up the new config
machine.succeed("mkdir -p ${user.home}/.xmonad")
machine.copy_from_host("${newConfig}", "${user.home}/.config/xmonad/xmonad.hs")
# recompile xmonad using the new config
machine.send_key("alt-ctrl-q")
machine.wait_for_file("/tmp/newXMonad")
# recompile xmonad using the new config
machine.send_key("alt-ctrl-q")
machine.wait_for_file("/tmp/newXMonad")
# new config has a keybinding that deletes somefile
machine.send_key("alt-ctrl-r")
machine.wait_until_fails("stat /tmp/somefile", timeout=30)
# new config has a keybinding that deletes somefile
machine.send_key("alt-ctrl-r")
machine.wait_until_fails("stat /tmp/somefile", timeout=30)
# restart with the old config, and confirm the old keybinding is back
machine.succeed("rm /tmp/oldXMonad")
machine.send_key("alt-q")
machine.wait_for_file("/tmp/oldXMonad")
machine.send_key("alt-ctrl-t")
machine.wait_for_file("/tmp/somefile")
'';
}
)
# restart with the old config, and confirm the old keybinding is back
machine.succeed("rm /tmp/oldXMonad")
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, ... }:
{
name = "xpadneo";
meta.maintainers = with lib.maintainers; [ kira-bruneau ];
{ lib, pkgs, ... }:
{
name = "xpadneo";
meta.maintainers = with lib.maintainers; [ kira-bruneau ];
nodes = {
machine = {
config.hardware.xpadneo.enable = true;
};
nodes = {
machine = {
config.hardware.xpadneo.enable = true;
};
};
# 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
# we wanted more in-depth testing.
testScript = ''
machine.start();
machine.succeed("modinfo hid_xpadneo | grep 'version:\s\+${pkgs.linuxPackages.xpadneo.version}'")
'';
}
)
# 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
# we wanted more in-depth testing.
testScript = ''
machine.start();
machine.succeed("modinfo hid_xpadneo | grep 'version:\s\+${pkgs.linuxPackages.xpadneo.version}'")
'';
}

View file

@ -1,110 +1,108 @@
import ./make-test-python.nix (
{ pkgs, ... }:
{
# How to interactively test this module if the audio actually works
{ pkgs, ... }:
{
# How to interactively test this module if the audio actually works
# - nix run .#pulseaudio-module-xrdp.tests.xrdp-with-audio-pulseaudio.driverInteractive
# - 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
# - 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)
# - Open a browser or something that plays sound. Ex: chromium
# - nix run .#pulseaudio-module-xrdp.tests.xrdp-with-audio-pulseaudio.driverInteractive
# - 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
# - 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)
# - Open a browser or something that plays sound. Ex: chromium
name = "xrdp-with-audio-pulseaudio";
meta = with pkgs.lib.maintainers; {
maintainers = [ lucasew ];
};
name = "xrdp-with-audio-pulseaudio";
meta = with pkgs.lib.maintainers; {
maintainers = [ lucasew ];
};
nodes = {
server =
{ pkgs, ... }:
{
imports = [ ./common/user-account.nix ];
nodes = {
server =
{ pkgs, ... }:
{
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.audio.enable = true;
services.xrdp.defaultWindowManager = "${pkgs.xterm}/bin/xterm";
services.xrdp.enable = true;
services.xrdp.audio.enable = true;
services.xrdp.defaultWindowManager = "${pkgs.xterm}/bin/xterm";
services.pulseaudio = {
enable = true;
};
services.pulseaudio = {
enable = true;
};
systemd.user.services.pactl-list = {
script = ''
while [ ! -S /tmp/.xrdp/xrdp_chansrv_audio_in_socket_* ]; do
sleep 1
done
systemd.user.services.pactl-list = {
script = ''
while [ ! -S /tmp/.xrdp/xrdp_chansrv_audio_in_socket_* ]; do
sleep 1
${pkgs.pulseaudio}/bin/pactl list
echo Source:
${pkgs.pulseaudio}/bin/pactl get-default-source | tee /tmp/pulseaudio-source
echo Sink:
${pkgs.pulseaudio}/bin/pactl get-default-sink | tee /tmp/pulseaudio-sink
done
sleep 1
${pkgs.pulseaudio}/bin/pactl list
echo Source:
${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" ];
};
networking.firewall.allowedTCPPorts = [ 3389 ];
'';
wantedBy = [ "default.target" ];
};
client =
{ pkgs, ... }:
{
imports = [
./common/x11.nix
./common/user-account.nix
];
test-support.displayManager.auto.user = "alice";
networking.firewall.allowedTCPPorts = [ 3389 ];
};
environment.systemPackages = [ pkgs.freerdp ];
client =
{ pkgs, ... }:
{
imports = [
./common/x11.nix
./common/user-account.nix
];
test-support.displayManager.auto.user = "alice";
services.xrdp.enable = true;
services.xrdp.audio.enable = true;
services.xrdp.defaultWindowManager = "${pkgs.icewm}/bin/icewm";
environment.systemPackages = [ pkgs.freerdp ];
services.pulseaudio = {
enable = true;
};
services.xrdp.enable = true;
services.xrdp.audio.enable = true;
services.xrdp.defaultWindowManager = "${pkgs.icewm}/bin/icewm";
services.pulseaudio = {
enable = true;
};
};
};
};
testScript =
{ nodes, ... }:
let
user = nodes.client.config.users.users.alice;
in
''
start_all()
testScript =
{ nodes, ... }:
let
user = nodes.client.config.users.users.alice;
in
''
start_all()
client.wait_for_x()
client.wait_for_file("${user.home}/.Xauthority")
client.succeed("xauth merge ${user.home}/.Xauthority")
client.wait_for_x()
client.wait_for_file("${user.home}/.Xauthority")
client.succeed("xauth merge ${user.home}/.Xauthority")
client.sleep(5)
client.sleep(5)
client.execute("xterm >&2 &")
client.sleep(1)
client.execute("xterm >&2 &")
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.sleep(5)
client.screenshot("localrdp")
client.succeed("[ -S /tmp/.xrdp/xrdp_chansrv_audio_in_socket_* ]") # checks if it's a socket
client.sleep(5)
client.screenshot("localrdp")
client.execute("xterm >&2 &")
client.sleep(1)
client.send_chars("xfreerdp /cert-tofu /w:640 /h:480 /v:server /u:${user.name} /p:${user.password} /sound\n")
client.sleep(10)
client.execute("xterm >&2 &")
client.sleep(1)
client.send_chars("xfreerdp /cert-tofu /w:640 /h:480 /v:server /u:${user.name} /p:${user.password} /sound\n")
client.sleep(10)
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-sink)" == "xrdp-sink" ]')
client.screenshot("remoterdp")
'';
}
)
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-sink)" == "xrdp-sink" ]')
client.screenshot("remoterdp")
'';
}

View file

@ -1,60 +1,58 @@
import ./make-test-python.nix (
{ pkgs, ... }:
{
name = "xrdp";
meta = with pkgs.lib.maintainers; {
maintainers = [ ];
};
{ pkgs, ... }:
{
name = "xrdp";
meta = with pkgs.lib.maintainers; {
maintainers = [ ];
};
nodes = {
server =
{ pkgs, ... }:
{
imports = [ ./common/user-account.nix ];
services.xrdp.enable = true;
services.xrdp.defaultWindowManager = "${pkgs.xterm}/bin/xterm";
networking.firewall.allowedTCPPorts = [ 3389 ];
};
nodes = {
server =
{ pkgs, ... }:
{
imports = [ ./common/user-account.nix ];
services.xrdp.enable = true;
services.xrdp.defaultWindowManager = "${pkgs.xterm}/bin/xterm";
networking.firewall.allowedTCPPorts = [ 3389 ];
};
client =
{ pkgs, ... }:
{
imports = [
./common/x11.nix
./common/user-account.nix
];
test-support.displayManager.auto.user = "alice";
environment.systemPackages = [ pkgs.freerdp ];
services.xrdp.enable = true;
services.xrdp.defaultWindowManager = "${pkgs.icewm}/bin/icewm";
};
};
client =
{ pkgs, ... }:
{
imports = [
./common/x11.nix
./common/user-account.nix
];
test-support.displayManager.auto.user = "alice";
environment.systemPackages = [ pkgs.freerdp ];
services.xrdp.enable = true;
services.xrdp.defaultWindowManager = "${pkgs.icewm}/bin/icewm";
};
};
testScript =
{ nodes, ... }:
let
user = nodes.client.config.users.users.alice;
in
''
start_all()
testScript =
{ nodes, ... }:
let
user = nodes.client.users.users.alice;
in
''
start_all()
client.wait_for_x()
client.wait_for_file("${user.home}/.Xauthority")
client.succeed("xauth merge ${user.home}/.Xauthority")
client.wait_for_x()
client.wait_for_file("${user.home}/.Xauthority")
client.succeed("xauth merge ${user.home}/.Xauthority")
client.sleep(5)
client.sleep(5)
client.execute("xterm >&2 &")
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.sleep(5)
client.screenshot("localrdp")
client.execute("xterm >&2 &")
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.sleep(5)
client.screenshot("localrdp")
client.execute("xterm >&2 &")
client.sleep(1)
client.send_chars("xfreerdp /cert-tofu /w:640 /h:480 /v:server /u:${user.name} /p:${user.password}\n")
client.sleep(5)
client.screenshot("remoterdp")
'';
}
)
client.execute("xterm >&2 &")
client.sleep(1)
client.send_chars("xfreerdp /cert-tofu /w:640 /h:480 /v:server /u:${user.name} /p:${user.password}\n")
client.sleep(5)
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 = {
simple = {
nodes = {
simple = {
imports = [
./common/x11.nix
./common/user-account.nix
];
programs.xss-lock.enable = true;
test-support.displayManager.auto.user = "alice";
};
custom_lockcmd =
{ pkgs, ... }:
{
imports = [
./common/x11.nix
./common/user-account.nix
];
programs.xss-lock.enable = true;
test-support.displayManager.auto.user = "alice";
};
custom_lockcmd =
{ pkgs, ... }:
{
imports = [
./common/x11.nix
./common/user-account.nix
programs.xss-lock = {
enable = true;
extraOptions = [
"-n"
"${pkgs.libnotify}/bin/notify-send 'About to sleep!'"
];
test-support.displayManager.auto.user = "alice";
programs.xss-lock = {
enable = true;
extraOptions = [
"-n"
"${pkgs.libnotify}/bin/notify-send 'About to sleep!'"
];
lockerCommand = "${pkgs.xlockmore}/bin/xlock -mode ant";
};
lockerCommand = "${pkgs.xlockmore}/bin/xlock -mode ant";
};
};
};
};
testScript = ''
def perform_xsslock_test(machine, lockCmd):
machine.start()
machine.wait_for_x()
machine.wait_for_unit("xss-lock.service", "alice")
machine.fail(f"pgrep {lockCmd}")
machine.succeed("su -l alice -c 'xset dpms force standby'")
machine.wait_until_succeeds(f"pgrep {lockCmd}")
testScript = ''
def perform_xsslock_test(machine, lockCmd):
machine.start()
machine.wait_for_x()
machine.wait_for_unit("xss-lock.service", "alice")
machine.fail(f"pgrep {lockCmd}")
machine.succeed("su -l alice -c 'xset dpms force standby'")
machine.wait_until_succeeds(f"pgrep {lockCmd}")
with subtest("simple"):
perform_xsslock_test(simple, "i3lock")
with subtest("simple"):
perform_xsslock_test(simple, "i3lock")
with subtest("custom_cmd"):
perform_xsslock_test(custom_lockcmd, "xlock")
'';
}
)
with subtest("custom_cmd"):
perform_xsslock_test(custom_lockcmd, "xlock")
'';
}

View file

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

View file

@ -1,76 +1,74 @@
import ./make-test-python.nix (
{ pkgs, lib, ... }:
{ pkgs, lib, ... }:
let
inherit (import ./ssh-keys.nix pkgs) snakeOilPrivateKey snakeOilPublicKey;
xxh-shell-zsh = pkgs.stdenv.mkDerivation {
pname = "xxh-shell-zsh";
version = "";
src = pkgs.fetchFromGitHub {
owner = "xxh";
repo = "xxh-shell-zsh";
# gets rarely updated, we can then just replace the hash
rev = "91e1f84f8d6e0852c3235d4813f341230cac439f";
sha256 = "sha256-Y1FrIRxTd0yooK+ZzKcCd6bLSy5E2fRXYAzrIsm7rIc=";
let
inherit (import ./ssh-keys.nix pkgs) snakeOilPrivateKey snakeOilPublicKey;
xxh-shell-zsh = pkgs.stdenv.mkDerivation {
pname = "xxh-shell-zsh";
version = "";
src = pkgs.fetchFromGitHub {
owner = "xxh";
repo = "xxh-shell-zsh";
# gets rarely updated, we can then just replace the hash
rev = "91e1f84f8d6e0852c3235d4813f341230cac439f";
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 = ''
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"
'';
client =
{ ... }:
{
programs.zsh.enable = true;
users.users.root.shell = pkgs.zsh;
environment.systemPackages = with pkgs; [
xxh
git
];
};
};
installPhase = ''
mkdir -p $out
mv * $out/
'';
};
testScript = ''
start_all()
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 ];
};
client.succeed("mkdir -m 700 /root/.ssh")
nodes = {
server =
{ ... }:
{
services.openssh.enable = true;
users.users.root.openssh.authorizedKeys.keys = [ snakeOilPublicKey ];
};
client.succeed(
"cat ${snakeOilPrivateKey} > /root/.ssh/id_ecdsa"
)
client.succeed("chmod 600 /root/.ssh/id_ecdsa")
client =
{ ... }:
{
programs.zsh.enable = true;
users.users.root.shell = pkgs.zsh;
environment.systemPackages = with pkgs; [
xxh
git
];
};
};
server.wait_for_unit("sshd")
testScript = ''
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'")
'';
}
)
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 = {
imports = [
./common/x11.nix
./common/user-account.nix
];
nodes.machine = {
imports = [
./common/x11.nix
./common/user-account.nix
];
test-support.displayManager.auto.user = "bob";
test-support.displayManager.auto.user = "bob";
programs.yabar.enable = true;
programs.yabar.bars = {
top.indicators.date.exec = "YABAR_DATE";
};
programs.yabar.enable = true;
programs.yabar.bars = {
top.indicators.date.exec = "YABAR_DATE";
};
};
testScript = ''
machine.start()
machine.wait_for_x()
testScript = ''
machine.start()
machine.wait_for_x()
# confirm proper startup
machine.wait_for_unit("yabar.service", "bob")
machine.sleep(10)
machine.wait_for_unit("yabar.service", "bob")
# confirm proper startup
machine.wait_for_unit("yabar.service", "bob")
machine.sleep(10)
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";
in
import ./make-test-python.nix (
{ pkgs, ... }:
{
name = "yggdrasil";
meta = with pkgs.lib.maintainers; {
maintainers = [ gazally ];
};
{ pkgs, ... }:
{
name = "yggdrasil";
meta = with pkgs.lib.maintainers; {
maintainers = [ gazally ];
};
nodes = rec {
# Alice is listening for peerings on a specified port,
# but has multicast peering disabled. Alice has part of her
# yggdrasil config in Nix and part of it in a file.
alice =
{ ... }:
{
networking = {
interfaces.eth1.ipv4.addresses = [
{
address = "192.168.1.200";
prefixLength = 24;
}
];
firewall.allowedTCPPorts = [
80
12345
];
nodes = {
# Alice is listening for peerings on a specified port,
# but has multicast peering disabled. Alice has part of her
# yggdrasil config in Nix and part of it in a file.
alice =
{ ... }:
{
networking = {
interfaces.eth1.ipv4.addresses = [
{
address = "192.168.1.200";
prefixLength = 24;
}
];
firewall.allowedTCPPorts = [
80
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;
services.httpd.adminAddr = "foo@example.org";
configFile = toString (
pkgs.writeTextFile {
name = "yggdrasil-alice-conf";
text = builtins.toJSON aliceKeys;
}
);
};
};
services.yggdrasil = {
enable = true;
settings = {
Listen = [ "tcp://0.0.0.0:12345" ];
MulticastInterfaces = [ ];
};
configFile = toString (
pkgs.writeTextFile {
name = "yggdrasil-alice-conf";
text = builtins.toJSON aliceKeys;
# Bob is set up to peer with Alice, and also to do local multicast
# peering. Bob's yggdrasil config is in a file.
bob =
{ ... }:
{
networking.firewall.allowedTCPPorts = [ 54321 ];
services.yggdrasil = {
enable = true;
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";
prefixLength = 64;
}
);
];
};
};
# Bob is set up to peer with Alice, and also to do local multicast
# peering. Bob's yggdrasil config is in a file.
bob =
{ ... }:
{
networking.firewall.allowedTCPPorts = [ 54321 ];
services.yggdrasil = {
enable = true;
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 = [
# dan is a node inside a container running on bob's host.
containers.dan = {
autoStart = true;
privateNetwork = true;
hostBridge = "br0";
config = {
networking.interfaces.eth0.ipv6 = {
addresses = [
{
address = bobPrefix + "::1";
address = bobPrefix + "::2";
prefixLength = 64;
}
];
};
};
# 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 = [
routes = [
{
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 = ''
import re
# 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;
}
];
openMulticastPort = true;
};
persistentKeys = true;
};
};
};
# Give Alice a head start so she is ready when Bob calls.
alice.start()
alice.wait_for_unit("yggdrasil.service")
testScript = ''
import re
bob.start()
carol.start()
bob.wait_for_unit("default.target")
carol.wait_for_unit("yggdrasil.service")
# Give Alice a head start so she is ready when Bob calls.
alice.start()
alice.wait_for_unit("yggdrasil.service")
ip_addr_show = "ip -o -6 addr show dev ygg0 scope global"
carol.wait_until_succeeds(f"[ `{ip_addr_show} | grep -v tentative | wc -l` -ge 1 ]")
carol_ip6 = re.split(" +|/", carol.succeed(ip_addr_show))[3]
bob.start()
carol.start()
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
# local peering have succeeded and everybody is connected.
alice.wait_until_succeeds(f"ping -c 1 {carol_ip6}")
alice.succeed("ping -c 1 ${bobIp6}")
ip_addr_show = "ip -o -6 addr show dev ygg0 scope global"
carol.wait_until_succeeds(f"[ `{ip_addr_show} | grep -v tentative | wc -l` -ge 1 ]")
carol_ip6 = re.split(" +|/", carol.succeed(ip_addr_show))[3]
bob.succeed("ping -c 1 ${aliceIp6}")
bob.succeed(f"ping -c 1 {carol_ip6}")
# If Alice can talk to Carol, then Bob's outbound peering and Carol's
# 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}")
carol.succeed("ping -c 1 ${bobIp6}")
carol.succeed("ping -c 1 ${bobPrefix}::1")
carol.succeed("ping -c 8 ${danIp6}")
bob.succeed("ping -c 1 ${aliceIp6}")
bob.succeed(f"ping -c 1 {carol_ip6}")
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.succeed("curl --fail -g http://[${aliceIp6}]")
carol.succeed("curl --fail -g http://[${danIp6}]")
'';
}
)
carol.fail("journalctl -u dhcpcd | grep ygg0")
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, ... }:
{
name = "your_spotify";
meta = with pkgs.lib.maintainers; {
maintainers = [ patrickdag ];
};
{ pkgs, ... }:
{
name = "your_spotify";
meta = with pkgs.lib.maintainers; {
maintainers = [ patrickdag ];
};
nodes.machine = {
services.your_spotify = {
enable = true;
spotifySecretFile = pkgs.writeText "spotifySecretFile" "deadbeef";
settings = {
CLIENT_ENDPOINT = "http://localhost";
API_ENDPOINT = "http://localhost:3000";
SPOTIFY_PUBLIC = "beefdead";
};
enableLocalDB = true;
nginxVirtualHost = "localhost";
nodes.machine = {
services.your_spotify = {
enable = true;
spotifySecretFile = pkgs.writeText "spotifySecretFile" "deadbeef";
settings = {
CLIENT_ENDPOINT = "http://localhost";
API_ENDPOINT = "http://localhost:3000";
SPOTIFY_PUBLIC = "beefdead";
};
enableLocalDB = true;
nginxVirtualHost = "localhost";
};
};
testScript = ''
machine.wait_for_unit("your_spotify.service")
testScript = ''
machine.wait_for_unit("your_spotify.service")
machine.wait_for_open_port(3000)
machine.wait_for_open_port(80)
machine.wait_for_open_port(3000)
machine.wait_for_open_port(80)
out = machine.succeed("curl --fail -X GET 'http://localhost:3000/'")
assert "Hello !" in out
out = machine.succeed("curl --fail -X GET 'http://localhost:3000/'")
assert "Hello !" in out
out = machine.succeed("curl --fail -X GET 'http://localhost:80/'")
assert "<title>Your Spotify</title>" in out
'';
}
)
out = machine.succeed("curl --fail -X GET 'http://localhost:80/'")
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; [
taeer
netali
];
meta.maintainers = with lib.maintainers; [
taeer
netali
];
nodes.machine =
{ config, ... }:
{
virtualisation = {
memorySize = 2048;
};
nodes.machine = {
virtualisation = {
memorySize = 2048;
};
services.zammad.enable = true;
services.zammad.secretKeyBaseFile = pkgs.writeText "secret" ''
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>'"
)
services.zammad.enable = true;
services.zammad.secretKeyBaseFile = pkgs.writeText "secret" ''
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>'"
)
'';
}

View file

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

View file

@ -1,30 +1,31 @@
{
lib,
...
}:
let
port = 43110;
in
import ./make-test-python.nix (
{ pkgs, ... }:
{
name = "zeronet-conservancy";
meta = with pkgs.lib.maintainers; {
maintainers = [ fgaz ];
{
name = "zeronet-conservancy";
meta = with lib.maintainers; {
maintainers = [ fgaz ];
};
nodes.machine =
{ pkgs, ... }:
{
services.zeronet = {
enable = true;
package = pkgs.zeronet-conservancy;
inherit port;
};
};
nodes.machine =
{ config, pkgs, ... }:
{
services.zeronet = {
enable = true;
package = pkgs.zeronet-conservancy;
inherit port;
};
};
testScript = ''
machine.wait_for_unit("zeronet.service")
testScript = ''
machine.wait_for_unit("zeronet.service")
machine.wait_for_open_port(${toString port})
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, ... }:
{
name = "zipline";
meta.maintainers = with lib.maintainers; [ defelo ];
{ lib, ... }:
{
name = "zipline";
meta.maintainers = with lib.maintainers; [ defelo ];
nodes.machine = {
services.zipline = {
enable = true;
settings = {
CORE_HOSTNAME = "127.0.0.1";
CORE_PORT = 8000;
};
environmentFiles = [
(builtins.toFile "zipline.env" ''
CORE_SECRET=DMlouex3W0QLRbVwkUafNnNws5jpgRDX
'')
];
nodes.machine = {
services.zipline = {
enable = true;
settings = {
CORE_HOSTNAME = "127.0.0.1";
CORE_PORT = 8000;
};
networking.hosts."127.0.0.1" = [ "zipline.local" ];
environmentFiles = [
(builtins.toFile "zipline.env" ''
CORE_SECRET=DMlouex3W0QLRbVwkUafNnNws5jpgRDX
'')
];
};
testScript = ''
import json
import re
networking.hosts."127.0.0.1" = [ "zipline.local" ];
};
machine.wait_for_unit("zipline.service")
machine.wait_for_open_port(8000)
testScript = ''
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")
data = json.loads(resp.splitlines()[-1])
assert data["firstSetup"] is True
assert data["user"]["username"] == "administrator"
assert data["user"]["role"] == "SUPERADMIN"
machine.wait_for_unit("zipline.service")
machine.wait_for_open_port(8000)
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(f"curl zipline.local:8000/api/user -H 'Cookie: {cookie[1]}'")
assert json.loads(resp)["user"]["id"] == data["user"]["id"]
'';
}
)
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")
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";
meta.maintainers = with lib.maintainers; [ danielfullmer ];
{
name = "zoneminder";
meta.maintainers = with lib.maintainers; [ danielfullmer ];
nodes.machine =
{ ... }:
{
services.zoneminder = {
enable = true;
database.createLocally = true;
database.username = "zoneminder";
};
time.timeZone = "America/New_York";
nodes.machine =
{ ... }:
{
services.zoneminder = {
enable = true;
database.createLocally = true;
database.username = "zoneminder";
};
time.timeZone = "America/New_York";
};
testScript = ''
machine.wait_for_unit("zoneminder.service")
machine.wait_for_unit("nginx.service")
machine.wait_for_open_port(8095)
machine.succeed("curl --fail http://localhost:8095/")
'';
}
)
testScript = ''
machine.wait_for_unit("zoneminder.service")
machine.wait_for_unit("nginx.service")
machine.wait_for_open_port(8095)
machine.succeed("curl --fail http://localhost:8095/")
'';
}

View file

@ -1,54 +1,52 @@
import ./make-test-python.nix (
{ pkgs, ... }:
let
{ pkgs, ... }:
let
perlEnv = pkgs.perl.withPackages (p: [ p.NetZooKeeper ]);
perlEnv = pkgs.perl.withPackages (p: [ p.NetZooKeeper ]);
in
{
name = "zookeeper";
meta = with pkgs.lib.maintainers; {
maintainers = [
nequissimus
ztzg
];
};
in
{
name = "zookeeper";
meta = with pkgs.lib.maintainers; {
maintainers = [
nequissimus
ztzg
];
};
nodes = {
server =
{ ... }:
{
services.zookeeper = {
enable = true;
};
networking.firewall.allowedTCPPorts = [ 2181 ];
nodes = {
server =
{ ... }:
{
services.zookeeper = {
enable = true;
};
};
testScript = ''
start_all()
networking.firewall.allowedTCPPorts = [ 2181 ];
};
};
server.wait_for_unit("zookeeper")
server.wait_for_unit("network.target")
server.wait_for_open_port(2181)
testScript = ''
start_all()
server.wait_until_succeeds(
"${pkgs.zookeeper}/bin/zkCli.sh -server localhost:2181 create /foo bar"
)
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_for_unit("zookeeper")
server.wait_for_unit("network.target")
server.wait_for_open_port(2181)
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()'"
)
'';
}
)
server.wait_until_succeeds(
"${pkgs.zookeeper}/bin/zkCli.sh -server localhost:2181 create /foo bar"
)
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(
"${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";
nodes = {

View file

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

View file

@ -1,40 +1,38 @@
import ./make-test-python.nix (
{ pkgs, ... }:
{
name = "zsh-history";
meta = with pkgs.lib.maintainers; {
maintainers = [ ];
{ pkgs, ... }:
{
name = "zsh-history";
meta = with pkgs.lib.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 =
{ ... }:
{
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";
};
testScript = ''
start_all()
default.wait_for_unit("multi-user.target")
default.wait_until_succeeds("pgrep -f 'agetty.*tty1'")
testScript = ''
start_all()
default.wait_for_unit("multi-user.target")
default.wait_until_succeeds("pgrep -f 'agetty.*tty1'")
# Login
default.wait_until_tty_matches("1", "login: ")
default.send_chars("root\n")
default.wait_until_tty_matches("1", r"\nroot@default\b")
# Login
default.wait_until_tty_matches("1", "login: ")
default.send_chars("root\n")
default.wait_until_tty_matches("1", r"\nroot@default\b")
# Generate some history
default.send_chars("echo foobar\n")
default.wait_until_tty_matches("1", "foobar")
# Generate some history
default.send_chars("echo foobar\n")
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")
'';
}
)
# 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, ... }:
{
name = "zwave-js-ui";
meta.maintainers = with lib.maintainers; [ cdombroski ];
{ lib, ... }:
{
name = "zwave-js-ui";
meta.maintainers = with lib.maintainers; [ cdombroski ];
nodes = {
machine =
{ ... }:
{
services.zwave-js-ui = {
enable = true;
serialPort = "/dev/null";
settings = {
HOST = "::";
PORT = "9999";
};
nodes = {
machine =
{ ... }:
{
services.zwave-js-ui = {
enable = true;
serialPort = "/dev/null";
settings = {
HOST = "::";
PORT = "9999";
};
};
};
};
};
testScript = ''
start_all()
testScript = ''
start_all()
machine.wait_for_unit("zwave-js-ui.service")
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_for_file("/var/lib/zwave-js-ui/users.json")
'';
}
)
machine.wait_for_unit("zwave-js-ui.service")
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_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
secretsConfigFile = pkgs.writeText "secrets.json" (
builtins.toJSON {
securityKeys = {
"S0_Legacy" = "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA";
};
}
);
in
{
name = "zwave-js";
meta.maintainers = with lib.maintainers; [ graham33 ];
let
secretsConfigFile = pkgs.writeText "secrets.json" (
builtins.toJSON {
securityKeys = {
"S0_Legacy" = "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA";
};
}
);
in
{
name = "zwave-js";
meta.maintainers = with lib.maintainers; [ graham33 ];
nodes = {
machine =
{ config, ... }:
{
services.zwave-js = {
enable = true;
serialPort = "/dev/null";
extraFlags = [ "--mock-driver" ];
inherit secretsConfigFile;
};
};
nodes = {
machine = {
services.zwave-js = {
enable = true;
serialPort = "/dev/null";
extraFlags = [ "--mock-driver" ];
inherit secretsConfigFile;
};
};
};
testScript = ''
start_all()
testScript = ''
start_all()
machine.wait_for_unit("zwave-js.service")
machine.wait_for_open_port(3000)
machine.wait_until_succeeds("journalctl --since -1m --unit zwave-js --grep 'ZwaveJS server listening'")
'';
}
)
machine.wait_for_unit("zwave-js.service")
machine.wait_for_open_port(3000)
machine.wait_until_succeeds("journalctl --since -1m --unit zwave-js --grep 'ZwaveJS server listening'")
'';
}