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