python310Packages.pydeconz: 104 -> 105
[NixPkgs.git] / nixos / tests / web-apps / peertube.nix
blobecc45bff2e2ca1cf63c26ef027c1db547fe8a24c
1 import ../make-test-python.nix ({pkgs, ...}:
3   name = "peertube";
4   meta.maintainers = with pkgs.lib.maintainers; [ izorkin ];
6   nodes = {
7     database = {
8       networking = {
9        interfaces.eth1 = {
10           ipv4.addresses = [
11             { address = "192.168.2.10"; prefixLength = 24; }
12           ];
13         };
14         firewall.allowedTCPPorts = [ 5432 31638 ];
15       };
17       services.postgresql = {
18         enable = true;
19         enableTCPIP = true;
20         authentication = ''
21           hostnossl peertube_local peertube_test 192.168.2.11/32 md5
22         '';
23         initialScript = pkgs.writeText "postgresql_init.sql" ''
24           CREATE ROLE peertube_test LOGIN PASSWORD '0gUN0C1mgST6czvjZ8T9';
25           CREATE DATABASE peertube_local TEMPLATE template0 ENCODING UTF8;
26           GRANT ALL PRIVILEGES ON DATABASE peertube_local TO peertube_test;
27           \connect peertube_local
28           CREATE EXTENSION IF NOT EXISTS pg_trgm;
29           CREATE EXTENSION IF NOT EXISTS unaccent;
30         '';
31       };
33       services.redis.servers.peertube = {
34         enable = true;
35         bind = "0.0.0.0";
36         requirePass = "turrQfaQwnanGbcsdhxy";
37         port = 31638;
38       };
39     };
41     server = { pkgs, ... }: {
42       environment = {
43         etc = {
44           "peertube/password-posgressql-db".text = ''
45             0gUN0C1mgST6czvjZ8T9
46           '';
47           "peertube/password-redis-db".text = ''
48             turrQfaQwnanGbcsdhxy
49           '';
50         };
51       };
53       networking = {
54         interfaces.eth1 = {
55           ipv4.addresses = [
56             { address = "192.168.2.11"; prefixLength = 24; }
57           ];
58         };
59         extraHosts = ''
60           192.168.2.11 peertube.local
61         '';
62         firewall.allowedTCPPorts = [ 9000 ];
63       };
65       services.peertube = {
66         enable = true;
67         localDomain = "peertube.local";
68         enableWebHttps = false;
70         database = {
71           host = "192.168.2.10";
72           name = "peertube_local";
73           user = "peertube_test";
74           passwordFile = "/etc/peertube/password-posgressql-db";
75         };
77         redis = {
78           host = "192.168.2.10";
79           port = 31638;
80           passwordFile = "/etc/peertube/password-redis-db";
81         };
83         settings = {
84           listen = {
85             hostname = "0.0.0.0";
86           };
87           instance = {
88             name = "PeerTube Test Server";
89           };
90         };
91       };
92     };
94     client = {
95       environment.systemPackages = [ pkgs.jq ];
96       networking = {
97        interfaces.eth1 = {
98           ipv4.addresses = [
99             { address = "192.168.2.12"; prefixLength = 24; }
100           ];
101         };
102         extraHosts = ''
103           192.168.2.11 peertube.local
104         '';
105       };
106     };
108   };
110   testScript = ''
111     start_all()
113     database.wait_for_unit("postgresql.service")
114     database.wait_for_unit("redis-peertube.service")
116     database.wait_for_open_port(5432)
117     database.wait_for_open_port(31638)
119     server.wait_for_unit("peertube.service")
120     server.wait_for_open_port(9000)
122     # Check if PeerTube is running
123     client.succeed("curl --fail http://peertube.local:9000/api/v1/config/about | jq -r '.instance.name' | grep 'PeerTube\ Test\ Server'")
125     # Check PeerTube CLI version
126     assert "${pkgs.peertube.version}" in server.succeed('su - peertube -s /bin/sh -c "peertube --version"')
128     client.shutdown()
129     server.shutdown()
130     database.shutdown()
131   '';