908c37f73f
Module manages PostgreSQL (both databases + schema init), qBittorrent (VPN-confined via VPN-Confinement), Jackett, metadata-agregator, musicfs, and the main orchestrator. All services are independently enableable with auto-wired inter-service configuration. Includes NixOS VM test validating PostgreSQL setup, schema initialization, service startup, and directory creation. Ultraworked with [Sisyphus](https://github.com/code-yeongyu/claude-agent) Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
105 lines
3.5 KiB
Nix
105 lines
3.5 KiB
Nix
{
|
|
pkgs,
|
|
nixosModules,
|
|
}:
|
|
|
|
pkgs.testers.nixosTest {
|
|
name = "agregators-simple-test";
|
|
|
|
nodes.machine =
|
|
{
|
|
config,
|
|
pkgs,
|
|
...
|
|
}:
|
|
{
|
|
imports = [ nixosModules.default ];
|
|
|
|
networking.firewall.enable = false;
|
|
|
|
virtualisation.memorySize = 4096;
|
|
virtualisation.diskSize = 8192;
|
|
|
|
services.agregators = {
|
|
enable = true;
|
|
mediaDir = "/data/music";
|
|
|
|
# No VPN in test — no WireGuard endpoint to connect to
|
|
# qbittorrent.vpn.enable is false by implication
|
|
|
|
qbittorrent = {
|
|
enable = true;
|
|
vpn.enable = false;
|
|
};
|
|
|
|
jackett.enable = true;
|
|
|
|
metadata-agregator = {
|
|
enable = true;
|
|
package = config.services.agregators.music-agregator.package;
|
|
# In real usage this would be the actual metadata-agregator package.
|
|
# For the simple test we just check the module evaluates and
|
|
# systemd units are created. The service itself won't start
|
|
# without the real binary — that's fine, we test structure here.
|
|
};
|
|
|
|
musicfs = {
|
|
enable = true;
|
|
package = config.services.agregators.music-agregator.package;
|
|
};
|
|
|
|
music-agregator = {
|
|
enable = true;
|
|
package = pkgs.hello; # placeholder — real package tested separately
|
|
jackettApiKeyFile = "/dev/null";
|
|
};
|
|
};
|
|
};
|
|
|
|
testScript = ''
|
|
machine.wait_for_unit("multi-user.target")
|
|
|
|
# PostgreSQL should be running with both databases
|
|
machine.succeed("systemctl is-active postgresql")
|
|
machine.succeed("sudo -u postgres psql -lqt | grep -q music_agregator")
|
|
machine.succeed("sudo -u postgres psql -lqt | grep -q metadata_agregator")
|
|
|
|
# Schema init oneshots should have completed
|
|
machine.succeed("systemctl is-active agregators-schema-music")
|
|
machine.succeed("systemctl is-active agregators-schema-metadata")
|
|
|
|
# Verify schemas were applied (marker files exist)
|
|
machine.succeed("test -f /var/lib/agregators/postgres/.schema-music-initialized")
|
|
machine.succeed("test -f /var/lib/agregators/postgres/.schema-metadata-initialized")
|
|
|
|
# Verify tables exist in music_agregator
|
|
machine.succeed("sudo -u music_agregator psql -d music_agregator -c 'SELECT 1 FROM river_job LIMIT 0'")
|
|
machine.succeed("sudo -u music_agregator psql -d music_agregator -c 'SELECT 1 FROM artists LIMIT 0'")
|
|
machine.succeed("sudo -u music_agregator psql -d music_agregator -c 'SELECT 1 FROM workflow_runs LIMIT 0'")
|
|
|
|
# Verify tables exist in metadata_agregator
|
|
machine.succeed("sudo -u metadata_agregator psql -d metadata_agregator -c 'SELECT 1 FROM artists LIMIT 0'")
|
|
machine.succeed("sudo -u metadata_agregator psql -d metadata_agregator -c 'SELECT 1 FROM albums LIMIT 0'")
|
|
|
|
# Verify extensions
|
|
machine.succeed("sudo -u metadata_agregator psql -d metadata_agregator -c \"SELECT 1 FROM pg_extension WHERE extname='pg_trgm'\" | grep -q 1")
|
|
|
|
# qBittorrent should be running (no VPN in test)
|
|
machine.succeed("systemctl is-active qbittorrent")
|
|
|
|
# Jackett should be running
|
|
machine.succeed("systemctl is-active jackett")
|
|
|
|
# Directories should exist with correct ownership
|
|
machine.succeed("test -d /data/music")
|
|
machine.succeed("test -d /data/music/downloads")
|
|
machine.succeed("test -d /var/lib/agregators")
|
|
|
|
# Verify the agregators user/group exist
|
|
machine.succeed("id agregators")
|
|
machine.succeed("getent group agregators")
|
|
|
|
print("\n=== Agregators Simple Test Completed ===")
|
|
'';
|
|
}
|