|
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 | | - ''; |
30 | 46 |
|
31 | 47 | makeTestForWithBackupAll = |
32 | 48 | package: backupAll: |
| 49 | + let |
| 50 | + enablePLv8Check = !package.pkgs.plv8.meta.broken; |
| 51 | + in |
33 | 52 | makeTest { |
34 | 53 | name = "postgresql${lib.optionalString backupAll "-backup-all"}-${package.name}"; |
35 | 54 | meta = with lib.maintainers; { |
36 | 55 | maintainers = [ zagy ]; |
37 | 56 | }; |
38 | 57 |
|
39 | 58 | nodes.machine = |
40 | | - { ... }: |
| 59 | + { config, ... }: |
41 | 60 | { |
42 | 61 | services.postgresql = { |
43 | 62 | inherit package; |
44 | 63 | enable = true; |
45 | 64 | enableJIT = lib.hasInfix "-jit-" package.name; |
| 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 ]); |
46 | 70 | }; |
47 | 71 |
|
48 | 72 | services.postgresqlBackup = { |
|
69 | 93 |
|
70 | 94 | with subtest("Postgresql is available just after unit start"): |
71 | 95 | machine.succeed( |
72 | | - "cat ${test-sql} | sudo -u postgres psql" |
| 96 | + "cat ${test-sql enablePLv8Check} | sudo -u postgres psql" |
73 | 97 | ) |
74 | 98 |
|
75 | 99 | with subtest("Postgresql survives restart (bug #1735)"): |
|
0 commit comments