Finish the example

.. which was accidentally commited, partially, in parent commit.

Pending a FIXME in tests.
This commit is contained in:
Sridhar Ratnakumar 2023-06-21 15:47:09 -04:00
parent 20b63ecf79
commit b364792c33
4 changed files with 139 additions and 5 deletions

1
example/.gitignore vendored Normal file
View File

@ -0,0 +1 @@
/data

129
example/flake.lock Normal file
View File

@ -0,0 +1,129 @@
{
"nodes": {
"flake-parts": {
"inputs": {
"nixpkgs-lib": "nixpkgs-lib"
},
"locked": {
"lastModified": 1685662779,
"narHash": "sha256-cKDDciXGpMEjP1n6HlzKinN0H+oLmNpgeCTzYnsA2po=",
"owner": "hercules-ci",
"repo": "flake-parts",
"rev": "71fb97f0d875fd4de4994dfb849f2c75e17eb6c3",
"type": "github"
},
"original": {
"owner": "hercules-ci",
"repo": "flake-parts",
"type": "github"
}
},
"nixpkgs": {
"locked": {
"lastModified": 1687274257,
"narHash": "sha256-TutzPriQcZ8FghDhEolnHcYU2oHIG5XWF+/SUBNnAOE=",
"owner": "nixos",
"repo": "nixpkgs",
"rev": "2c9ecd1f0400076a4d6b2193ad468ff0a7e7fdc5",
"type": "github"
},
"original": {
"owner": "nixos",
"ref": "nixpkgs-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"nixpkgs-lib": {
"locked": {
"dir": "lib",
"lastModified": 1685564631,
"narHash": "sha256-8ywr3AkblY4++3lIVxmrWZFzac7+f32ZEhH/A8pNscI=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "4f53efe34b3a8877ac923b9350c874e3dcd5dc0a",
"type": "github"
},
"original": {
"dir": "lib",
"owner": "NixOS",
"ref": "nixos-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"northwind": {
"flake": false,
"locked": {
"lastModified": 1666887048,
"narHash": "sha256-wwqHEkZUTNkg78OLnRDX5JPoRYop8v5UI2hxZTclxs8=",
"owner": "pthom",
"repo": "northwind_psql",
"rev": "3d271b23f3357532e63f92ffb10c4f258dfd20af",
"type": "github"
},
"original": {
"owner": "pthom",
"repo": "northwind_psql",
"type": "github"
}
},
"process-compose-flake": {
"locked": {
"lastModified": 1687298948,
"narHash": "sha256-7Lu4/odCkkwrzR8Mo+3D+URv4oLap8WWLESzi/75eb0=",
"owner": "Platonic-Systems",
"repo": "process-compose-flake",
"rev": "5bdb90b85642901cf9a5dccfe8c907091c261604",
"type": "github"
},
"original": {
"owner": "Platonic-Systems",
"repo": "process-compose-flake",
"type": "github"
}
},
"root": {
"inputs": {
"flake-parts": "flake-parts",
"nixpkgs": "nixpkgs",
"northwind": "northwind",
"process-compose-flake": "process-compose-flake",
"services-flake": "services-flake",
"systems": "systems"
}
},
"services-flake": {
"locked": {
"lastModified": 1687358997,
"narHash": "sha256-TjBp031+x3gHM2fRPA2GITXJWTwCstIeQb04rp8Iokk=",
"owner": "juspay",
"repo": "services-flake",
"rev": "27c3221de252b393d9ddbb5cc31ba71b94477cf9",
"type": "github"
},
"original": {
"owner": "juspay",
"repo": "services-flake",
"type": "github"
}
},
"systems": {
"locked": {
"lastModified": 1681028828,
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
"owner": "nix-systems",
"repo": "default",
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
"type": "github"
},
"original": {
"owner": "nix-systems",
"repo": "default",
"type": "github"
}
}
},
"root": "root",
"version": 7
}

View File

@ -28,25 +28,26 @@
enable = true;
listen_addresses = "127.0.0.1";
initialDatabases = [
{
name = "sample";
{
name = "sample";
schema = "${inputs.northwind}/northwind.sql";
}
}
];
};
settings.processes.pgweb = {
environment.PGWEB_DATABASE_URL = "postgres://srid@127.0.0.1:5432/sample";
command = pkgs.pgweb;
depends_on."postgres".condition = "process_started";
depends_on."postgres".condition = "process_healthy";
};
# Set this attribute and get NixOS VM tests, as a flake check, for free.
testScript = ''
# FIXME: pgweb is still pending, but only in VM tests for some reason.
process_compose.wait_until(lambda procs:
procs["postgres"]["status"] == "Running"
)
machine.succeed("echo 'SELECT version();' | ${config.services.postgres.package}/bin/psql -h 127.0.0.1 -U tester chinook")
machine.succeed("echo 'SELECT version();' | ${config.services.postgres.package}/bin/psql -h 127.0.0.1 -U tester sample")
'';
};
};

View File

@ -4,6 +4,9 @@ cd "$(dirname "$0")"
# On NixOS, run the VM tests to test runtime behaviour
if command -v nixos-rebuild &> /dev/null; then
# example test
nix flake check -L ./example --override-input services-flake .
# service tests
nix flake check -L ./test --override-input services-flake .
fi