notes: 2.3.0 -> 2.3.1 (#352950)
[NixPkgs.git] / nixos / tests / seafile.nix
blob7784d5fddaedd1438cf764cc3c02fd6c6139d1af
1 import ./make-test-python.nix ({ pkgs, ... }:
2   let
3     client = { config, pkgs, ... }: {
4       environment.systemPackages = [ pkgs.seafile-shared pkgs.curl ];
5     };
6   in {
7     name = "seafile";
8     meta = with pkgs.lib.maintainers; {
9       maintainers = [ kampfschlaefer schmittlauch ];
10     };
12     nodes = {
13       server = { config, pkgs, ... }: {
14         services.seafile = {
15           enable = true;
16           ccnetSettings.General.SERVICE_URL = "http://server";
17           seafileSettings.fileserver.host = "unix:/run/seafile/server.sock";
18           adminEmail = "admin@example.com";
19           initialAdminPassword = "seafile_password";
20         };
21         services.nginx = {
22           enable = true;
23           virtualHosts."server" = {
24             locations."/".proxyPass = "http://unix:/run/seahub/gunicorn.sock";
25             locations."/seafhttp" = {
26               proxyPass = "http://unix:/run/seafile/server.sock";
27               extraConfig = ''
28                 rewrite ^/seafhttp(.*)$ $1 break;
29                 client_max_body_size 0;
30                 proxy_connect_timeout  36000s;
31                 proxy_read_timeout  36000s;
32                 proxy_send_timeout  36000s;
33                 send_timeout  36000s;
34                 proxy_http_version 1.1;
35               '';
36             };
37           };
38         };
39         networking.firewall = { allowedTCPPorts = [ 80 ]; };
40       };
41       client1 = client pkgs;
42       client2 = client pkgs;
43     };
45     testScript = ''
46       start_all()
48       with subtest("start seaf-server"):
49           server.wait_for_unit("seaf-server.service")
50           server.wait_for_file("/run/seafile/seafile.sock")
52       with subtest("start seahub"):
53           server.wait_for_unit("seahub.service")
54           server.wait_for_unit("nginx.service")
55           server.wait_for_file("/run/seahub/gunicorn.sock")
57       with subtest("client1 fetch seahub page"):
58           client1.succeed("curl -L http://server | grep 'Log In' >&2")
60       with subtest("client1 connect"):
61           client1.wait_for_unit("default.target")
62           client1.succeed("seaf-cli init -d . >&2")
63           client1.succeed("seaf-cli start >&2")
64           client1.succeed(
65               "seaf-cli list-remote -s http://server -u admin\@example.com -p seafile_password >&2"
66           )
68           libid = client1.succeed(
69               'seaf-cli create -s http://server -n test01 -u admin\@example.com -p seafile_password -t "first test library"'
70           ).strip()
72           client1.succeed(
73               "seaf-cli list-remote -s http://server -u admin\@example.com -p seafile_password |grep test01"
74           )
75           client1.fail(
76               "seaf-cli list-remote -s http://server -u admin\@example.com -p seafile_password |grep test02"
77           )
79           client1.succeed(
80               f"seaf-cli download -l {libid} -s http://server -u admin\@example.com -p seafile_password -d . >&2"
81           )
83           client1.wait_until_succeeds("seaf-cli status |grep synchronized >&2")
85           client1.succeed("ls -la >&2")
86           client1.succeed("ls -la test01 >&2")
88           client1.execute("echo bla > test01/first_file")
90           client1.wait_until_succeeds("seaf-cli status |grep synchronized >&2")
92       with subtest("client2 sync"):
93           client2.wait_for_unit("default.target")
95           client2.succeed("seaf-cli init -d . >&2")
96           client2.succeed("seaf-cli start >&2")
98           client2.succeed(
99               "seaf-cli list-remote -s http://server -u admin\@example.com -p seafile_password >&2"
100           )
102           libid = client2.succeed(
103               "seaf-cli list-remote -s http://server -u admin\@example.com -p seafile_password |grep test01 |cut -d' ' -f 2"
104           ).strip()
106           client2.succeed(
107               f"seaf-cli download -l {libid} -s http://server -u admin\@example.com -p seafile_password -d . >&2"
108           )
110           client2.wait_until_succeeds("seaf-cli status |grep synchronized >&2")
112           client2.succeed("ls -la test01 >&2")
114           client2.succeed('[ `cat test01/first_file` = "bla" ]')
115     '';
116   })