From d235e9cd90b0522dc8ffc0b13e45caf8db373aef Mon Sep 17 00:00:00 2001 From: Piotr Kwiecinski <2151333+piotrkwiecinski@users.noreply.github.com> Date: Mon, 31 Mar 2025 22:56:18 +0200 Subject: [PATCH 1/2] nixosTests.firefly-iii: migrate to runTest Part of #386873 --- nixos/tests/all-tests.nix | 2 +- nixos/tests/firefly-iii.nix | 212 ++++++++++++++++++------------------ 2 files changed, 106 insertions(+), 108 deletions(-) diff --git a/nixos/tests/all-tests.nix b/nixos/tests/all-tests.nix index 7d8af87cd9eb..b9b58e3d7ff6 100644 --- a/nixos/tests/all-tests.nix +++ b/nixos/tests/all-tests.nix @@ -398,7 +398,7 @@ in { fider = runTest ./fider.nix; filesender = handleTest ./filesender.nix {}; filesystems-overlayfs = runTest ./filesystems-overlayfs.nix; - firefly-iii = handleTest ./firefly-iii.nix {}; + firefly-iii = runTest ./firefly-iii.nix; firefly-iii-data-importer = handleTest ./firefly-iii-data-importer.nix {}; firefox = runTest { imports = [./firefox.nix ]; diff --git a/nixos/tests/firefly-iii.nix b/nixos/tests/firefly-iii.nix index 290d07711002..35a695a057ac 100644 --- a/nixos/tests/firefly-iii.nix +++ b/nixos/tests/firefly-iii.nix @@ -1,119 +1,117 @@ -import ./make-test-python.nix ( - { lib, ... }: +{ lib, ... }: - let - db-pass = "Test2Test2"; - app-key = "TestTestTestTestTestTestTestTest"; - in - { - name = "firefly-iii"; - meta.maintainers = [ lib.maintainers.savyajha ]; +let + db-pass = "Test2Test2"; + app-key = "TestTestTestTestTestTestTestTest"; +in +{ + name = "firefly-iii"; + meta.maintainers = [ lib.maintainers.savyajha ]; - nodes.fireflySqlite = - { config, ... }: - { - environment.etc = { - "firefly-iii-appkey".text = app-key; + nodes.fireflySqlite = + { config, ... }: + { + environment.etc = { + "firefly-iii-appkey".text = app-key; + }; + services.firefly-iii = { + enable = true; + enableNginx = true; + settings = { + APP_KEY_FILE = "/etc/firefly-iii-appkey"; + LOG_CHANNEL = "stdout"; + SITE_OWNER = "mail@example.com"; }; - services.firefly-iii = { - enable = true; - enableNginx = true; - settings = { - APP_KEY_FILE = "/etc/firefly-iii-appkey"; - LOG_CHANNEL = "stdout"; - SITE_OWNER = "mail@example.com"; - }; + }; + }; + + nodes.fireflyPostgresql = + { config, pkgs, ... }: + { + environment.etc = { + "firefly-iii-appkey".text = app-key; + "postgres-pass".text = db-pass; + }; + services.firefly-iii = { + enable = true; + enableNginx = true; + settings = { + APP_KEY_FILE = "/etc/firefly-iii-appkey"; + LOG_CHANNEL = "stdout"; + SITE_OWNER = "mail@example.com"; + DB_CONNECTION = "pgsql"; + DB_DATABASE = "firefly"; + DB_USERNAME = "firefly"; + DB_PASSWORD_FILE = "/etc/postgres-pass"; + PGSQL_SCHEMA = "firefly"; }; }; - nodes.fireflyPostgresql = - { config, pkgs, ... }: - { - environment.etc = { - "firefly-iii-appkey".text = app-key; - "postgres-pass".text = db-pass; - }; - services.firefly-iii = { - enable = true; - enableNginx = true; - settings = { - APP_KEY_FILE = "/etc/firefly-iii-appkey"; - LOG_CHANNEL = "stdout"; - SITE_OWNER = "mail@example.com"; - DB_CONNECTION = "pgsql"; - DB_DATABASE = "firefly"; - DB_USERNAME = "firefly"; - DB_PASSWORD_FILE = "/etc/postgres-pass"; - PGSQL_SCHEMA = "firefly"; - }; - }; + services.postgresql = { + enable = true; + package = pkgs.postgresql_16; + authentication = '' + local all postgres peer + local firefly firefly password + ''; + initialScript = pkgs.writeText "firefly-init.sql" '' + CREATE USER "firefly" WITH LOGIN PASSWORD '${db-pass}'; + CREATE DATABASE "firefly" WITH OWNER "firefly"; + \c firefly + CREATE SCHEMA AUTHORIZATION firefly; + ''; + }; + }; - services.postgresql = { - enable = true; - package = pkgs.postgresql_16; - authentication = '' - local all postgres peer - local firefly firefly password - ''; - initialScript = pkgs.writeText "firefly-init.sql" '' - CREATE USER "firefly" WITH LOGIN PASSWORD '${db-pass}'; - CREATE DATABASE "firefly" WITH OWNER "firefly"; - \c firefly - CREATE SCHEMA AUTHORIZATION firefly; - ''; + nodes.fireflyMysql = + { config, pkgs, ... }: + { + environment.etc = { + "firefly-iii-appkey".text = app-key; + "mysql-pass".text = db-pass; + }; + services.firefly-iii = { + enable = true; + enableNginx = true; + settings = { + APP_KEY_FILE = "/etc/firefly-iii-appkey"; + LOG_CHANNEL = "stdout"; + SITE_OWNER = "mail@example.com"; + DB_CONNECTION = "mysql"; + DB_DATABASE = "firefly"; + DB_USERNAME = "firefly"; + DB_PASSWORD_FILE = "/etc/mysql-pass"; + DB_SOCKET = "/run/mysqld/mysqld.sock"; }; }; - nodes.fireflyMysql = - { config, pkgs, ... }: - { - environment.etc = { - "firefly-iii-appkey".text = app-key; - "mysql-pass".text = db-pass; - }; - services.firefly-iii = { - enable = true; - enableNginx = true; - settings = { - APP_KEY_FILE = "/etc/firefly-iii-appkey"; - LOG_CHANNEL = "stdout"; - SITE_OWNER = "mail@example.com"; - DB_CONNECTION = "mysql"; - DB_DATABASE = "firefly"; - DB_USERNAME = "firefly"; - DB_PASSWORD_FILE = "/etc/mysql-pass"; - DB_SOCKET = "/run/mysqld/mysqld.sock"; - }; - }; - - services.mysql = { - enable = true; - package = pkgs.mariadb; - initialScript = pkgs.writeText "firefly-init.sql" '' - create database firefly DEFAULT CHARACTER SET utf8mb4; - create user 'firefly'@'localhost' identified by '${db-pass}'; - grant all on firefly.* to 'firefly'@'localhost'; - ''; - settings.mysqld.character-set-server = "utf8mb4"; - }; + services.mysql = { + enable = true; + package = pkgs.mariadb; + initialScript = pkgs.writeText "firefly-init.sql" '' + create database firefly DEFAULT CHARACTER SET utf8mb4; + create user 'firefly'@'localhost' identified by '${db-pass}'; + grant all on firefly.* to 'firefly'@'localhost'; + ''; + settings.mysqld.character-set-server = "utf8mb4"; }; + }; - testScript = '' - fireflySqlite.wait_for_unit("phpfpm-firefly-iii.service") - fireflySqlite.wait_for_unit("nginx.service") - fireflySqlite.succeed("curl -fvvv -Ls http://localhost/ | grep 'Firefly III'") - fireflySqlite.succeed("curl -fvvv -Ls http://localhost/v1/js/app.js") - fireflySqlite.succeed("systemctl start firefly-iii-cron.service") - fireflyPostgresql.wait_for_unit("phpfpm-firefly-iii.service") - fireflyPostgresql.wait_for_unit("nginx.service") - fireflyPostgresql.wait_for_unit("postgresql.service") - fireflyPostgresql.succeed("curl -fvvv -Ls http://localhost/ | grep 'Firefly III'") - fireflyPostgresql.succeed("systemctl start firefly-iii-cron.service") - fireflyMysql.wait_for_unit("phpfpm-firefly-iii.service") - fireflyMysql.wait_for_unit("nginx.service") - fireflyMysql.wait_for_unit("mysql.service") - fireflyMysql.succeed("curl -fvvv -Ls http://localhost/ | grep 'Firefly III'") - fireflyMysql.succeed("systemctl start firefly-iii-cron.service") - ''; - } -) + testScript = '' + fireflySqlite.wait_for_unit("phpfpm-firefly-iii.service") + fireflySqlite.wait_for_unit("nginx.service") + fireflySqlite.succeed("curl -fvvv -Ls http://localhost/ | grep 'Firefly III'") + fireflySqlite.succeed("curl -fvvv -Ls http://localhost/v1/js/app.js") + fireflySqlite.succeed("systemctl start firefly-iii-cron.service") + fireflyPostgresql.wait_for_unit("phpfpm-firefly-iii.service") + fireflyPostgresql.wait_for_unit("nginx.service") + fireflyPostgresql.wait_for_unit("postgresql.service") + fireflyPostgresql.succeed("curl -fvvv -Ls http://localhost/ | grep 'Firefly III'") + fireflyPostgresql.succeed("systemctl start firefly-iii-cron.service") + fireflyMysql.wait_for_unit("phpfpm-firefly-iii.service") + fireflyMysql.wait_for_unit("nginx.service") + fireflyMysql.wait_for_unit("mysql.service") + fireflyMysql.succeed("curl -fvvv -Ls http://localhost/ | grep 'Firefly III'") + fireflyMysql.succeed("systemctl start firefly-iii-cron.service") + ''; +} From e8ea207b5f3043f77a6f6e7acb6131dfda9236d8 Mon Sep 17 00:00:00 2001 From: Piotr Kwiecinski <2151333+piotrkwiecinski@users.noreply.github.com> Date: Mon, 31 Mar 2025 22:57:48 +0200 Subject: [PATCH 2/2] nixosTests.firefly-iii-data-importer: migrate to runTest Part of #386873 --- nixos/tests/all-tests.nix | 2 +- nixos/tests/firefly-iii-data-importer.nix | 43 +++++++++++------------ 2 files changed, 21 insertions(+), 24 deletions(-) diff --git a/nixos/tests/all-tests.nix b/nixos/tests/all-tests.nix index b9b58e3d7ff6..ec0935a3e3dc 100644 --- a/nixos/tests/all-tests.nix +++ b/nixos/tests/all-tests.nix @@ -399,7 +399,7 @@ in { filesender = handleTest ./filesender.nix {}; filesystems-overlayfs = runTest ./filesystems-overlayfs.nix; firefly-iii = runTest ./firefly-iii.nix; - firefly-iii-data-importer = handleTest ./firefly-iii-data-importer.nix {}; + firefly-iii-data-importer = runTest ./firefly-iii-data-importer.nix; firefox = runTest { imports = [./firefox.nix ]; _module.args.firefoxPackage = pkgs.firefox; diff --git a/nixos/tests/firefly-iii-data-importer.nix b/nixos/tests/firefly-iii-data-importer.nix index aba41576d797..d43a30650bc2 100644 --- a/nixos/tests/firefly-iii-data-importer.nix +++ b/nixos/tests/firefly-iii-data-importer.nix @@ -1,27 +1,24 @@ -import ./make-test-python.nix ( - { lib, ... }: +{ lib, ... }: +{ + name = "firefly-iii-data-importer"; + meta.maintainers = [ lib.maintainers.savyajha ]; - { - name = "firefly-iii-data-importer"; - meta.maintainers = [ lib.maintainers.savyajha ]; - - nodes.dataImporter = - { ... }: - { - services.firefly-iii-data-importer = { - enable = true; - enableNginx = true; - settings = { - LOG_CHANNEL = "stdout"; - USE_CACHE = true; - }; + nodes.dataImporter = + { ... }: + { + services.firefly-iii-data-importer = { + enable = true; + enableNginx = true; + settings = { + LOG_CHANNEL = "stdout"; + USE_CACHE = true; }; }; + }; - testScript = '' - dataImporter.wait_for_unit("phpfpm-firefly-iii-data-importer.service") - dataImporter.wait_for_unit("nginx.service") - dataImporter.succeed("curl -fvvv -Ls http://localhost/token | grep 'Firefly III Data Import Tool'") - ''; - } -) + testScript = '' + dataImporter.wait_for_unit("phpfpm-firefly-iii-data-importer.service") + dataImporter.wait_for_unit("nginx.service") + dataImporter.succeed("curl -fvvv -Ls http://localhost/token | grep 'Firefly III Data Import Tool'") + ''; +}