|
14 | 14 | postgresql-clauses = makeEnsureTestFor package; |
15 | 15 | }; |
16 | 16 |
|
17 | | - test-sql = pkgs.writeText "postgresql-test" '' |
18 | | - CREATE EXTENSION pgcrypto; -- just to check if lib loading works |
19 | | - CREATE TABLE sth ( |
20 | | - id int |
| 17 | + test-sql = |
| 18 | + enablePLv8Test: |
| 19 | + pkgs.writeText "postgresql-test" ( |
| 20 | + '' |
| 21 | + CREATE EXTENSION pgcrypto; -- just to check if lib loading works |
| 22 | + CREATE TABLE sth ( |
| 23 | + id int |
| 24 | + ); |
| 25 | + INSERT INTO sth (id) VALUES (1); |
| 26 | + INSERT INTO sth (id) VALUES (1); |
| 27 | + INSERT INTO sth (id) VALUES (1); |
| 28 | + INSERT INTO sth (id) VALUES (1); |
| 29 | + INSERT INTO sth (id) VALUES (1); |
| 30 | + CREATE TABLE xmltest ( doc xml ); |
| 31 | + INSERT INTO xmltest (doc) VALUES ('<test>ok</test>'); -- check if libxml2 enabled |
| 32 | + '' |
| 33 | + + lib.optionalString enablePLv8Test '' |
| 34 | + -- check if hardening gets relaxed |
| 35 | + CREATE EXTENSION plv8; |
| 36 | + -- try to trigger the V8 JIT, which requires MemoryDenyWriteExecute |
| 37 | + DO $$ |
| 38 | + let xs = []; |
| 39 | + for (let i = 0, n = 400000; i < n; i++) { |
| 40 | + xs.push(Math.round(Math.random() * n)) |
| 41 | + } |
| 42 | + console.log(xs.reduce((acc, x) => acc + x, 0)); |
| 43 | + $$ LANGUAGE plv8; |
| 44 | + '' |
21 | 45 | ); |
22 | | - INSERT INTO sth (id) VALUES (1); |
23 | | - INSERT INTO sth (id) VALUES (1); |
24 | | - INSERT INTO sth (id) VALUES (1); |
25 | | - INSERT INTO sth (id) VALUES (1); |
26 | | - INSERT INTO sth (id) VALUES (1); |
27 | | - CREATE TABLE xmltest ( doc xml ); |
28 | | - INSERT INTO xmltest (doc) VALUES ('<test>ok</test>'); -- check if libxml2 enabled |
29 | | - -- check if hardening gets relaxed |
30 | | - CREATE EXTENSION plv8; |
31 | | - -- try to trigger the V8 JIT, which requires MemoryDenyWriteExecute |
32 | | - DO $$ |
33 | | - let xs = []; |
34 | | - for (let i = 0, n = 400000; i < n; i++) { |
35 | | - xs.push(Math.round(Math.random() * n)) |
36 | | - } |
37 | | - console.log(xs.reduce((acc, x) => acc + x, 0)); |
38 | | - $$ LANGUAGE plv8; |
39 | | - ''; |
40 | 46 |
|
41 | 47 | makeTestForWithBackupAll = |
42 | 48 | package: backupAll: |
| 49 | + let |
| 50 | + enablePLv8Check = !package.pkgs.plv8.meta.broken; |
| 51 | + in |
43 | 52 | makeTest { |
44 | 53 | name = "postgresql${lib.optionalString backupAll "-backup-all"}-${package.name}"; |
45 | 54 | meta = with lib.maintainers; { |
46 | 55 | maintainers = [ zagy ]; |
47 | 56 | }; |
48 | 57 |
|
49 | 58 | nodes.machine = |
50 | | - { ... }: |
| 59 | + { config, ... }: |
51 | 60 | { |
52 | 61 | services.postgresql = { |
53 | 62 | inherit package; |
54 | 63 | enable = true; |
55 | 64 | enableJIT = lib.hasInfix "-jit-" package.name; |
56 | | - extensions = ps: with ps; [ plv8 ]; |
| 65 | + # plv8 doesn't support postgresql with JIT, so we only run the test |
| 66 | + # for the non-jit variant. |
| 67 | + # TODO(@Ma27) split this off into its own VM test and move a few other |
| 68 | + # extension tests to use postgresqlTestExtension. |
| 69 | + extensions = lib.mkIf enablePLv8Check (ps: with ps; [ plv8 ]); |
57 | 70 | }; |
58 | 71 |
|
59 | 72 | services.postgresqlBackup = { |
|
80 | 93 |
|
81 | 94 | with subtest("Postgresql is available just after unit start"): |
82 | 95 | machine.succeed( |
83 | | - "cat ${test-sql} | sudo -u postgres psql" |
| 96 | + "cat ${test-sql enablePLv8Check} | sudo -u postgres psql" |
84 | 97 | ) |
85 | 98 |
|
86 | 99 | with subtest("Postgresql survives restart (bug #1735)"): |
|
0 commit comments