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