mirror of
https://github.com/ilyakooo0/nixpkgs.git
synced 2024-12-27 05:43:50 +03:00
test all postgresql versions, test server restart (#1735)
This commit is contained in:
parent
5e8499f447
commit
ab22a08039
@ -286,7 +286,7 @@ in rec {
|
|||||||
tests.openssh = callTest tests/openssh.nix {};
|
tests.openssh = callTest tests/openssh.nix {};
|
||||||
#tests.panamax = hydraJob (import tests/panamax.nix { system = "x86_64-linux"; });
|
#tests.panamax = hydraJob (import tests/panamax.nix { system = "x86_64-linux"; });
|
||||||
tests.peerflix = callTest tests/peerflix.nix {};
|
tests.peerflix = callTest tests/peerflix.nix {};
|
||||||
tests.postgresql = callTest tests/postgresql.nix {};
|
tests.postgresql = callSubTests tests/postgresql.nix {};
|
||||||
tests.printing = callTest tests/printing.nix {};
|
tests.printing = callTest tests/printing.nix {};
|
||||||
tests.proxy = callTest tests/proxy.nix {};
|
tests.proxy = callTest tests/proxy.nix {};
|
||||||
tests.pumpio = callTest tests/pump.io.nix {};
|
tests.pumpio = callTest tests/pump.io.nix {};
|
||||||
|
@ -1,26 +1,46 @@
|
|||||||
import ./make-test.nix ({ pkgs, ...} : {
|
{ system ? builtins.currentSystem }:
|
||||||
name = "postgresql";
|
with import ../lib/testing.nix { inherit system; };
|
||||||
meta = with pkgs.stdenv.lib.maintainers; {
|
with pkgs.lib;
|
||||||
maintainers = [ zagy ];
|
let
|
||||||
};
|
postgresql-versions = pkgs.callPackages ../../pkgs/servers/sql/postgresql { };
|
||||||
|
test-sql = pkgs.writeText "postgresql-test" ''
|
||||||
nodes = {
|
CREATE EXTENSION pgcrypto; -- just to check if lib loading works
|
||||||
master =
|
CREATE TABLE sth (
|
||||||
{ pkgs, config, ... }:
|
id int
|
||||||
|
);
|
||||||
{
|
INSERT INTO sth (id) VALUES (1);
|
||||||
services.postgresql.enable = true;
|
INSERT INTO sth (id) VALUES (1);
|
||||||
services.postgresql.initialScript = pkgs.writeText "postgresql-init.sql"
|
INSERT INTO sth (id) VALUES (1);
|
||||||
''
|
INSERT INTO sth (id) VALUES (1);
|
||||||
CREATE ROLE postgres WITH superuser login createdb;
|
INSERT INTO sth (id) VALUES (1);
|
||||||
'';
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
testScript = ''
|
|
||||||
startAll;
|
|
||||||
$master->waitForUnit("postgresql");
|
|
||||||
$master->sleep(10); # Hopefully this is long enough!!
|
|
||||||
$master->succeed("echo 'select 1' | sudo -u postgres psql");
|
|
||||||
'';
|
'';
|
||||||
})
|
make-postgresql-test = postgresql-name: postgresql-package: {
|
||||||
|
name = postgresql-name;
|
||||||
|
meta = with pkgs.stdenv.lib.maintainers; {
|
||||||
|
maintainers = [ zagy ];
|
||||||
|
};
|
||||||
|
|
||||||
|
machine = {pkgs, config, ...}:
|
||||||
|
{
|
||||||
|
services.postgresql.package=postgresql-package;
|
||||||
|
services.postgresql.enable = true;
|
||||||
|
};
|
||||||
|
|
||||||
|
testScript = ''
|
||||||
|
$machine->start;
|
||||||
|
$machine->waitForUnit("postgresql");
|
||||||
|
# postgresql should be available just after unit start
|
||||||
|
$machine->succeed("cat ${test-sql} | psql postgres");
|
||||||
|
$machine->shutdown; # make sure that postgresql survive restart (bug #1735)
|
||||||
|
sleep(2);
|
||||||
|
$machine->start;
|
||||||
|
$machine->waitForUnit("postgresql");
|
||||||
|
$machine->fail('test $(psql postgres -tAc "SELECT * FROM sth;"|wc -l) -eq 3');
|
||||||
|
$machine->succeed('test $(psql postgres -tAc "SELECT * FROM sth;"|wc -l) -eq 5');
|
||||||
|
$machine->fail('test $(psql postgres -tAc "SELECT * FROM sth;"|wc -l) -eq 4');
|
||||||
|
$machine->shutdown;
|
||||||
|
'';
|
||||||
|
|
||||||
|
};
|
||||||
|
in
|
||||||
|
mapAttrs' (p-name: p-package: {name=p-name; value=make-postgresql-test p-name p-package;}) postgresql-versions
|
||||||
|
Loading…
Reference in New Issue
Block a user