1 import ./make-test-python.nix ({ pkgs, ...} :
2 let creds = pkgs.writeText ".monetdb" ''
6 createUser = pkgs.writeText "createUser.sql" ''
7 CREATE USER "voc" WITH PASSWORD 'voc' NAME 'VOC Explorer' SCHEMA "sys";
8 CREATE SCHEMA "voc" AUTHORIZATION "voc";
9 ALTER USER "voc" SET SCHEMA "voc";
11 credsVoc = pkgs.writeText ".monetdb" ''
15 transaction = pkgs.writeText "transaction" ''
17 CREATE TABLE test (id int, data varchar(30));
20 vocData = pkgs.fetchzip {
21 url = "https://dev.monetdb.org/Assets/VOC/voc_dump.zip";
22 hash = "sha256-sQ5acTsSAiXQfOgt2PhN7X7Z9TZGZtLrPPxgQT2pCGQ=";
24 onboardPeople = pkgs.writeText "onboardPeople" ''
25 CREATE VIEW onboard_people AS
27 SELECT 'craftsmen' AS type, craftsmen.* FROM craftsmen
29 SELECT 'impotenten' AS type, impotenten.* FROM impotenten
31 SELECT 'passengers' AS type, passengers.* FROM passengers
33 SELECT 'seafarers' AS type, seafarers.* FROM seafarers
35 SELECT 'soldiers' AS type, soldiers.* FROM soldiers
37 SELECT 'total' AS type, total.* FROM total
38 ) AS onboard_people_table;
39 SELECT type, COUNT(*) AS total
40 FROM onboard_people GROUP BY type ORDER BY type;
42 onboardExpected = pkgs.lib.strings.replaceStrings ["\n"] ["\\n"] ''
43 +------------+-------+
45 +============+=======+
52 +------------+-------+
56 meta = with pkgs.lib.maintainers; {
57 maintainers = [ StillerHarpo ];
59 nodes.machine.services.monetdb.enable = true;
62 machine.wait_for_unit("monetdb")
63 machine.succeed("monetdbd create mydbfarm")
64 machine.succeed("monetdbd start mydbfarm")
65 machine.succeed("monetdb create voc")
66 machine.succeed("monetdb release voc")
67 machine.succeed("cp ${creds} ./.monetdb")
68 assert "hello world" in machine.succeed("mclient -d voc -s \"SELECT 'hello world'\"")
69 machine.succeed("mclient -d voc ${createUser}")
70 machine.succeed("cp ${credsVoc} ./.monetdb")
71 machine.succeed("mclient -d voc ${transaction}")
72 machine.succeed("mclient -d voc ${vocData}/voc_dump.sql")
73 assert "8131" in machine.succeed("mclient -d voc -s \"SELECT count(*) FROM voyages\"")
74 assert "${onboardExpected}" in machine.succeed("mclient -d voc ${onboardPeople}")