diff options
Diffstat (limited to 'nixpkgs/nixos/tests')
-rw-r--r-- | nixpkgs/nixos/tests/activation/etc-overlay-immutable.nix | 14 | ||||
-rw-r--r-- | nixpkgs/nixos/tests/activation/etc-overlay-mutable.nix | 18 | ||||
-rw-r--r-- | nixpkgs/nixos/tests/all-tests.nix | 2 | ||||
-rw-r--r-- | nixpkgs/nixos/tests/ccache.nix | 24 | ||||
-rw-r--r-- | nixpkgs/nixos/tests/geoserver.nix | 65 | ||||
-rw-r--r-- | nixpkgs/nixos/tests/incus/container.nix | 4 | ||||
-rw-r--r-- | nixpkgs/nixos/tests/incus/default.nix | 6 | ||||
-rw-r--r-- | nixpkgs/nixos/tests/installer.nix | 3 | ||||
-rw-r--r-- | nixpkgs/nixos/tests/matomo.nix | 4 | ||||
-rw-r--r-- | nixpkgs/nixos/tests/morph-browser.nix | 53 | ||||
-rw-r--r-- | nixpkgs/nixos/tests/nextcloud/with-postgresql-and-redis.nix | 6 | ||||
-rw-r--r-- | nixpkgs/nixos/tests/power-profiles-daemon.nix | 21 | ||||
-rw-r--r-- | nixpkgs/nixos/tests/scrutiny.nix | 70 | ||||
-rw-r--r-- | nixpkgs/nixos/tests/systemd-boot.nix | 26 |
14 files changed, 289 insertions, 27 deletions
diff --git a/nixpkgs/nixos/tests/activation/etc-overlay-immutable.nix b/nixpkgs/nixos/tests/activation/etc-overlay-immutable.nix index 70c3623b929c..f347f9cf8efe 100644 --- a/nixpkgs/nixos/tests/activation/etc-overlay-immutable.nix +++ b/nixpkgs/nixos/tests/activation/etc-overlay-immutable.nix @@ -20,11 +20,17 @@ }; testScript = '' - machine.succeed("findmnt --kernel --type overlay /etc") - machine.fail("stat /etc/newgen") + with subtest("/etc is mounted as an overlay"): + machine.succeed("findmnt --kernel --type overlay /etc") - machine.succeed("/run/current-system/specialisation/new-generation/bin/switch-to-configuration switch") + with subtest("switching to the same generation"): + machine.succeed("/run/current-system/bin/switch-to-configuration test") - assert machine.succeed("cat /etc/newgen") == "newgen" + with subtest("switching to a new generation"): + machine.fail("stat /etc/newgen") + + machine.succeed("/run/current-system/specialisation/new-generation/bin/switch-to-configuration switch") + + assert machine.succeed("cat /etc/newgen") == "newgen" ''; } diff --git a/nixpkgs/nixos/tests/activation/etc-overlay-mutable.nix b/nixpkgs/nixos/tests/activation/etc-overlay-mutable.nix index cfe7604fceb8..087c06408a71 100644 --- a/nixpkgs/nixos/tests/activation/etc-overlay-mutable.nix +++ b/nixpkgs/nixos/tests/activation/etc-overlay-mutable.nix @@ -18,13 +18,19 @@ }; testScript = '' - machine.succeed("findmnt --kernel --type overlay /etc") - machine.fail("stat /etc/newgen") - machine.succeed("echo -n 'mutable' > /etc/mutable") + with subtest("/etc is mounted as an overlay"): + machine.succeed("findmnt --kernel --type overlay /etc") - machine.succeed("/run/current-system/specialisation/new-generation/bin/switch-to-configuration switch") + with subtest("switching to the same generation"): + machine.succeed("/run/current-system/bin/switch-to-configuration test") - assert machine.succeed("cat /etc/newgen") == "newgen" - assert machine.succeed("cat /etc/mutable") == "mutable" + with subtest("switching to a new generation"): + machine.fail("stat /etc/newgen") + machine.succeed("echo -n 'mutable' > /etc/mutable") + + machine.succeed("/run/current-system/specialisation/new-generation/bin/switch-to-configuration switch") + + assert machine.succeed("cat /etc/newgen") == "newgen" + assert machine.succeed("cat /etc/mutable") == "mutable" ''; } diff --git a/nixpkgs/nixos/tests/all-tests.nix b/nixpkgs/nixos/tests/all-tests.nix index 8193c3dfe840..1144a5611dcf 100644 --- a/nixpkgs/nixos/tests/all-tests.nix +++ b/nixpkgs/nixos/tests/all-tests.nix @@ -539,6 +539,7 @@ in { mongodb = handleTest ./mongodb.nix {}; moodle = handleTest ./moodle.nix {}; moonraker = handleTest ./moonraker.nix {}; + morph-browser = handleTest ./morph-browser.nix { }; morty = handleTest ./morty.nix {}; mosquitto = handleTest ./mosquitto.nix {}; moosefs = handleTest ./moosefs.nix {}; @@ -771,6 +772,7 @@ in { sanoid = handleTest ./sanoid.nix {}; scaphandre = handleTest ./scaphandre.nix {}; schleuder = handleTest ./schleuder.nix {}; + scrutiny = handleTest ./scrutiny.nix {}; sddm = handleTest ./sddm.nix {}; seafile = handleTest ./seafile.nix {}; searx = handleTest ./searx.nix {}; diff --git a/nixpkgs/nixos/tests/ccache.nix b/nixpkgs/nixos/tests/ccache.nix new file mode 100644 index 000000000000..a97ae0501767 --- /dev/null +++ b/nixpkgs/nixos/tests/ccache.nix @@ -0,0 +1,24 @@ +import ./make-test-python.nix ({ pkgs, ...} : { + name = "ccache"; + meta = with pkgs.lib.maintainers; { + maintainers = [ ehmry ]; + }; + + nodes.machine = { ... }: { + imports = [ ../modules/profiles/minimal.nix ]; + environment.systemPackages = [ pkgs.hello ]; + programs.ccache = { + enable = true; + packageNames = [ "hello" ]; + }; + }; + + testScript = + '' + start_all() + machine.wait_for_unit("multi-user.target") + machine.succeed("nix-ccache --show-stats") + machine.succeed("hello") + machine.shutdown() + ''; +}) diff --git a/nixpkgs/nixos/tests/geoserver.nix b/nixpkgs/nixos/tests/geoserver.nix index 7e5507a296ea..4f6f2b209d07 100644 --- a/nixpkgs/nixos/tests/geoserver.nix +++ b/nixpkgs/nixos/tests/geoserver.nix @@ -1,4 +1,18 @@ -{ pkgs, lib, ... }: { +{ pkgs, lib, ... }: + +let + geoserver = pkgs.geoserver; + geoserverWithImporterExtension = pkgs.geoserver.withExtensions (ps: with ps; [ importer ]); + + # Blacklisted extensions: + # - wps-jdbc needs a running (Postrgres) db server. + blacklist = [ "wps-jdbc" ]; + + blacklistedToNull = n: v: if ! builtins.elem n blacklist then v else null; + getNonBlackistedExtensionsAsList = ps: builtins.filter (x: x != null) (lib.attrsets.mapAttrsToList blacklistedToNull ps); + geoserverWithAllExtensions = pkgs.geoserver.withExtensions (ps: getNonBlackistedExtensionsAsList ps); +in +{ name = "geoserver"; meta = { @@ -9,16 +23,57 @@ machine = { pkgs, ... }: { virtualisation.diskSize = 2 * 1024; - environment.systemPackages = [ pkgs.geoserver ]; + environment.systemPackages = [ + geoserver + geoserverWithImporterExtension + geoserverWithAllExtensions + ]; }; }; testScript = '' + from contextlib import contextmanager + + curl_cmd = "curl --fail --connect-timeout 2" + curl_cmd_rest = f"{curl_cmd} -u admin:geoserver -X GET" + base_url = "http://localhost:8080/geoserver" + log_file = "./log.txt" + + @contextmanager + def running_geoserver(pkg): + try: + print(f"Launching geoserver from {pkg}...") + machine.execute(f"{pkg}/bin/geoserver-startup > {log_file} 2>&1 &") + machine.wait_until_succeeds(f"{curl_cmd} {base_url} 2>&1", timeout=60) + yield + finally: + # We need to wait a little bit to make sure the server is properly + # shutdown before launching a new instance. + machine.execute(f"{pkg}/bin/geoserver-shutdown; sleep 1") + start_all() - machine.execute("${pkgs.geoserver}/bin/geoserver-startup > /dev/null 2>&1 &") - machine.wait_until_succeeds("curl --fail --connect-timeout 2 http://localhost:8080/geoserver", timeout=60) + with running_geoserver("${geoserver}"): + machine.succeed(f"{curl_cmd} {base_url}/ows?service=WMS&version=1.3.0&request=GetCapabilities") + + # No extensions yet. + machine.fail(f"{curl_cmd_rest} {base_url}/rest/imports") + machine.fail(f"{curl_cmd_rest} {base_url}/rest/monitor/requests.csv") + + + with running_geoserver("${geoserverWithImporterExtension}"): + machine.succeed(f"{curl_cmd_rest} {base_url}/rest/imports") + machine.fail(f"{curl_cmd_rest} {base_url}/rest/monitor/requests.csv") + + with running_geoserver("${geoserverWithAllExtensions}"): + machine.succeed(f"{curl_cmd_rest} {base_url}/rest/imports") + machine.succeed(f"{curl_cmd_rest} {base_url}/rest/monitor/requests.csv") + _, stdout = machine.execute(f"cat {log_file}") + print(stdout.replace("\\n", "\n")) + assert "GDAL Native Library loaded" in stdout, "gdal" + assert "The turbo jpeg encoder is available for usage" in stdout, "libjpeg-turbo" + assert "org.geotools.imageio.netcdf.utilities.NetCDFUtilities" in stdout, "netcdf" + assert "Unable to load library 'netcdf'" not in stdout, "netcdf" - machine.succeed("curl --fail --connect-timeout 2 http://localhost:8080/geoserver/ows?service=WMS&version=1.3.0&request=GetCapabilities") ''; } diff --git a/nixpkgs/nixos/tests/incus/container.nix b/nixpkgs/nixos/tests/incus/container.nix index 0e65cc1e1529..0f42d16f133d 100644 --- a/nixpkgs/nixos/tests/incus/container.nix +++ b/nixpkgs/nixos/tests/incus/container.nix @@ -1,11 +1,11 @@ -import ../make-test-python.nix ({ pkgs, lib, ... } : +import ../make-test-python.nix ({ pkgs, lib, extra ? {}, ... } : let releases = import ../../release.nix { configuration = { # Building documentation makes the test unnecessarily take a longer time: documentation.enable = lib.mkForce false; - }; + } // extra; }; container-image-metadata = releases.lxdContainerMeta.${pkgs.stdenv.hostPlatform.system}; diff --git a/nixpkgs/nixos/tests/incus/default.nix b/nixpkgs/nixos/tests/incus/default.nix index c8e53774599b..ff36fe9d6730 100644 --- a/nixpkgs/nixos/tests/incus/default.nix +++ b/nixpkgs/nixos/tests/incus/default.nix @@ -5,7 +5,11 @@ handleTestOn, }: { - container = import ./container.nix { inherit system pkgs; }; + container-old-init = import ./container.nix { inherit system pkgs; }; + container-new-init = import ./container.nix { inherit system pkgs; extra = { + # Enable new systemd init + boot.initrd.systemd.enable = true; + }; }; lxd-to-incus = import ./lxd-to-incus.nix { inherit system pkgs; }; preseed = import ./preseed.nix { inherit system pkgs; }; socket-activated = import ./socket-activated.nix { inherit system pkgs; }; diff --git a/nixpkgs/nixos/tests/installer.nix b/nixpkgs/nixos/tests/installer.nix index 7576fae41f83..b6cb6a0c6d45 100644 --- a/nixpkgs/nixos/tests/installer.nix +++ b/nixpkgs/nixos/tests/installer.nix @@ -526,8 +526,7 @@ let curl ] ++ optionals (bootLoader == "grub") (let - zfsSupport = lib.any (x: x == "zfs") - (extraInstallerConfig.boot.supportedFilesystems or []); + zfsSupport = extraInstallerConfig.boot.supportedFilesystems.zfs or false; in [ (pkgs.grub2.override { inherit zfsSupport; }) (pkgs.grub2_efi.override { inherit zfsSupport; }) diff --git a/nixpkgs/nixos/tests/matomo.nix b/nixpkgs/nixos/tests/matomo.nix index 7dbef63136aa..130f3dd8485a 100644 --- a/nixpkgs/nixos/tests/matomo.nix +++ b/nixpkgs/nixos/tests/matomo.nix @@ -47,4 +47,8 @@ in { name = "matomo-beta"; meta.maintainers = with maintainers; [ florianjacob kiwi mmilata twey boozedog ]; }; + matomo_5 = matomoTest pkgs.matomo_5 // { + name = "matomo-5"; + meta.maintainers = with maintainers; [ florianjacob kiwi mmilata twey boozedog ] ++ lib.teams.flyingcircus.members; + }; } diff --git a/nixpkgs/nixos/tests/morph-browser.nix b/nixpkgs/nixos/tests/morph-browser.nix new file mode 100644 index 000000000000..859e6bb47646 --- /dev/null +++ b/nixpkgs/nixos/tests/morph-browser.nix @@ -0,0 +1,53 @@ +import ./make-test-python.nix ({ pkgs, lib, ... }: { + name = "morph-browser-standalone"; + meta.maintainers = lib.teams.lomiri.members; + + nodes.machine = { config, pkgs, ... }: { + imports = [ + ./common/x11.nix + ]; + + services.xserver.enable = true; + + environment = { + systemPackages = with pkgs.lomiri; [ + suru-icon-theme + morph-browser + ]; + variables = { + UITK_ICON_THEME = "suru"; + }; + }; + + i18n.supportedLocales = [ "all" ]; + + fonts.packages = with pkgs; [ + # Intended font & helps with OCR + ubuntu_font_family + ]; + }; + + enableOCR = true; + + testScript = + '' + machine.wait_for_x() + + with subtest("morph browser launches"): + machine.execute("morph-browser >&2 &") + machine.wait_for_text(r"Web Browser|New|sites|Bookmarks") + machine.screenshot("morph_open") + + with subtest("morph browser displays HTML"): + machine.send_chars("file://${pkgs.valgrind.doc}/share/doc/valgrind/html/index.html\n") + machine.wait_for_text("Valgrind Documentation") + machine.screenshot("morph_htmlcontent") + + machine.succeed("pkill -f morph-browser") + + with subtest("morph browser localisation works"): + machine.execute("env LANG=de_DE.UTF-8 morph-browser >&2 &") + machine.wait_for_text(r"Web-Browser|Neuer|Seiten|Lesezeichen") + machine.screenshot("morph_localised") + ''; +}) diff --git a/nixpkgs/nixos/tests/nextcloud/with-postgresql-and-redis.nix b/nixpkgs/nixos/tests/nextcloud/with-postgresql-and-redis.nix index 3c090f0d3c3b..06afc589403d 100644 --- a/nixpkgs/nixos/tests/nextcloud/with-postgresql-and-redis.nix +++ b/nixpkgs/nixos/tests/nextcloud/with-postgresql-and-redis.nix @@ -39,7 +39,7 @@ in { }; extraAppsEnable = true; extraApps = { - inherit (pkgs."nextcloud${lib.versions.major config.services.nextcloud.package.version}Packages".apps) notify_push; + inherit (pkgs."nextcloud${lib.versions.major config.services.nextcloud.package.version}Packages".apps) notify_push notes; }; settings.trusted_proxies = [ "::1" ]; }; @@ -84,7 +84,7 @@ in { "${withRcloneEnv} ${copySharedFile}" ) client.wait_for_unit("multi-user.target") - client.execute("${pkgs.nextcloud-notify_push.passthru.test_client}/bin/test_client http://nextcloud ${adminuser} ${adminpass} >&2 &") + client.execute("${pkgs.lib.getExe pkgs.nextcloud-notify_push.passthru.test_client} http://nextcloud ${adminuser} ${adminpass} >&2 &") client.succeed( "${withRcloneEnv} ${diffSharedFile}" ) @@ -92,5 +92,7 @@ in { # redis cache should not be empty nextcloud.fail('test "[]" = "$(redis-cli --json KEYS "*")"') + + nextcloud.fail("curl -f http://nextcloud/nix-apps/notes/lib/AppInfo/Application.php") ''; })) args diff --git a/nixpkgs/nixos/tests/power-profiles-daemon.nix b/nixpkgs/nixos/tests/power-profiles-daemon.nix index c887cde4b829..8a54d8e8bab8 100644 --- a/nixpkgs/nixos/tests/power-profiles-daemon.nix +++ b/nixpkgs/nixos/tests/power-profiles-daemon.nix @@ -8,22 +8,22 @@ import ./make-test-python.nix ({ pkgs, ... }: nodes.machine = { pkgs, ... }: { security.polkit.enable = true; services.power-profiles-daemon.enable = true; - environment.systemPackages = [ pkgs.glib ]; + environment.systemPackages = [ pkgs.glib pkgs.power-profiles-daemon ]; }; testScript = '' def get_profile(): return machine.succeed( - """gdbus call --system --dest net.hadess.PowerProfiles --object-path /net/hadess/PowerProfiles \ - --method org.freedesktop.DBus.Properties.Get 'net.hadess.PowerProfiles' 'ActiveProfile' + """gdbus call --system --dest org.freedesktop.UPower.PowerProfiles --object-path /org/freedesktop/UPower/PowerProfiles \ + --method org.freedesktop.DBus.Properties.Get 'org.freedesktop.UPower.PowerProfiles' 'ActiveProfile' """ ) def set_profile(profile): return machine.succeed( - """gdbus call --system --dest net.hadess.PowerProfiles --object-path /net/hadess/PowerProfiles \ - --method org.freedesktop.DBus.Properties.Set 'net.hadess.PowerProfiles' 'ActiveProfile' "<'{profile}'>" + """gdbus call --system --dest org.freedesktop.UPower.PowerProfiles --object-path /org/freedesktop/UPower/PowerProfiles \ + --method org.freedesktop.DBus.Properties.Set 'org.freedesktop.UPower.PowerProfiles' 'ActiveProfile' "<'{profile}'>" """.format( profile=profile ) @@ -42,5 +42,16 @@ import ./make-test-python.nix ({ pkgs, ... }: profile = get_profile() if not "balanced" in profile: raise Exception("Unable to set balanced profile") + + # test powerprofilectl CLI + machine.succeed("powerprofilesctl set power-saver") + profile = get_profile() + if not "power-saver" in profile: + raise Exception("Unable to set power-saver profile with powerprofilectl") + + machine.succeed("powerprofilesctl set balanced") + profile = get_profile() + if not "balanced" in profile: + raise Exception("Unable to set balanced profile with powerprofilectl") ''; }) diff --git a/nixpkgs/nixos/tests/scrutiny.nix b/nixpkgs/nixos/tests/scrutiny.nix new file mode 100644 index 000000000000..33160a6b3088 --- /dev/null +++ b/nixpkgs/nixos/tests/scrutiny.nix @@ -0,0 +1,70 @@ +import ./make-test-python.nix ({ lib, ... }: + +{ + name = "scrutiny"; + meta.maintainers = with lib.maintainers; [ jnsgruk ]; + + nodes = { + machine = { self, pkgs, lib, ... }: { + services = { + scrutiny.enable = true; + scrutiny.collector.enable = true; + }; + + environment.systemPackages = + let + seleniumScript = pkgs.writers.writePython3Bin "selenium-script" + { + libraries = with pkgs.python3Packages; [ selenium ]; + } '' + from selenium import webdriver + from selenium.webdriver.common.by import By + from selenium.webdriver.firefox.options import Options + from selenium.webdriver.support.ui import WebDriverWait + from selenium.webdriver.support import expected_conditions as EC + + options = Options() + options.add_argument("--headless") + service = webdriver.FirefoxService(executable_path="${lib.getExe pkgs.geckodriver}") # noqa: E501 + + driver = webdriver.Firefox(options=options, service=service) + driver.implicitly_wait(10) + driver.get("http://localhost:8080/web/dashboard") + + wait = WebDriverWait(driver, 10).until( + EC.text_to_be_present_in_element( + (By.TAG_NAME, "body"), "Drive health at a glance") + ) + + body_text = driver.find_element(By.TAG_NAME, "body").text + assert "Temperature history for each device" in body_text + + driver.close() + ''; + in + with pkgs; [ curl firefox-unwrapped geckodriver seleniumScript ]; + }; + }; + # This is the test code that will check if our service is running correctly: + testScript = '' + start_all() + + # Wait for InfluxDB to be available + machine.wait_for_unit("influxdb2") + machine.wait_for_open_port(8086) + + # Wait for Scrutiny to be available + machine.wait_for_unit("scrutiny") + machine.wait_for_open_port(8080) + + # Ensure the API responds as we expect + output = machine.succeed("curl localhost:8080/api/health") + assert output == '{"success":true}' + + # Start the collector service to send some metrics + collect = machine.succeed("systemctl start scrutiny-collector.service") + + # Ensure the application is actually rendered by the Javascript + machine.succeed("PYTHONUNBUFFERED=1 selenium-script") + ''; +}) diff --git a/nixpkgs/nixos/tests/systemd-boot.nix b/nixpkgs/nixos/tests/systemd-boot.nix index c0b37a230df0..ce3245f3d862 100644 --- a/nixpkgs/nixos/tests/systemd-boot.nix +++ b/nixpkgs/nixos/tests/systemd-boot.nix @@ -39,6 +39,32 @@ in ''; }; + # Test that systemd-boot works with secure boot + secureBoot = makeTest { + name = "systemd-boot-secure-boot"; + + nodes.machine = { + imports = [ common ]; + environment.systemPackages = [ pkgs.sbctl ]; + virtualisation.useSecureBoot = true; + }; + + testScript = '' + machine.start(allow_reboot=True) + machine.wait_for_unit("multi-user.target") + + machine.succeed("sbctl create-keys") + machine.succeed("sbctl enroll-keys --yes-this-might-brick-my-machine") + machine.succeed('sbctl sign /boot/EFI/systemd/systemd-bootx64.efi') + machine.succeed('sbctl sign /boot/EFI/BOOT/BOOTX64.EFI') + machine.succeed('sbctl sign /boot/EFI/nixos/*bzImage.efi') + + machine.reboot() + + assert "Secure Boot: enabled (user)" in machine.succeed("bootctl status") + ''; + }; + # Check that specialisations create corresponding boot entries. specialisation = makeTest { name = "systemd-boot-specialisation"; |