1 { system ? builtins.currentSystem
3 , pkgs ? import ../.. { inherit system config; }
7 with import ../lib/testing-python.nix { inherit system pkgs; };
11 packages = builtins.attrNames (import ../../pkgs/servers/sql/postgresql pkgs);
13 mkJitTestFromName = name:
14 mkJitTest pkgs.${name};
16 mkJitTest = package: makeTest {
18 meta.maintainers = with lib.maintainers; [ ma27 ];
19 nodes.machine = { pkgs, lib, ... }: {
20 services.postgresql = {
24 initialScript = pkgs.writeText "init.sql" ''
25 create table demo (id int);
26 insert into demo (id) select generate_series(1, 5);
32 machine.wait_for_unit("postgresql.service")
34 with subtest("JIT is enabled"):
35 machine.succeed("sudo -u postgres psql <<<'show jit;' | grep 'on'")
37 with subtest("Test JIT works fine"):
38 output = machine.succeed(
39 "cat ${pkgs.writeText "test.sql" ''
40 set jit_above_cost = 1;
41 EXPLAIN ANALYZE SELECT CONCAT('jit result = ', SUM(id)) FROM demo;
42 SELECT CONCAT('jit result = ', SUM(id)) from demo;
43 ''} | sudo -u postgres psql"
45 assert "JIT:" in output
46 assert "jit result = 15" in output
52 if package == null then
53 lib.genAttrs packages mkJitTestFromName