at 23.05-pre 3.1 kB view raw
1args@{ pkgs, nextcloudVersion ? 22, ... }: 2 3(import ../make-test-python.nix ({ pkgs, ...}: let 4 adminpass = "hunter2"; 5 adminuser = "root"; 6in { 7 name = "nextcloud-with-mysql-and-memcached"; 8 meta = with pkgs.lib.maintainers; { 9 maintainers = [ eqyiel ]; 10 }; 11 12 nodes = { 13 # The only thing the client needs to do is download a file. 14 client = { ... }: {}; 15 16 nextcloud = { config, pkgs, ... }: { 17 networking.firewall.allowedTCPPorts = [ 80 ]; 18 19 services.nextcloud = { 20 enable = true; 21 hostName = "nextcloud"; 22 https = true; 23 package = pkgs.${"nextcloud" + (toString nextcloudVersion)}; 24 caching = { 25 apcu = true; 26 redis = false; 27 memcached = true; 28 }; 29 database.createLocally = true; 30 config = { 31 dbtype = "mysql"; 32 dbname = "nextcloud"; 33 dbuser = "nextcloud"; 34 dbhost = "127.0.0.1"; 35 dbport = 3306; 36 dbpassFile = "${pkgs.writeText "dbpass" "hunter2" }"; 37 # Don't inherit adminuser since "root" is supposed to be the default 38 adminpassFile = "${pkgs.writeText "adminpass" adminpass}"; # Don't try this at home! 39 }; 40 }; 41 42 systemd.services.nextcloud-setup= { 43 requires = ["mysql.service"]; 44 after = ["mysql.service"]; 45 }; 46 47 services.memcached.enable = true; 48 }; 49 }; 50 51 testScript = let 52 configureMemcached = pkgs.writeScript "configure-memcached" '' 53 #!${pkgs.runtimeShell} 54 nextcloud-occ config:system:set memcached_servers 0 0 --value 127.0.0.1 --type string 55 nextcloud-occ config:system:set memcached_servers 0 1 --value 11211 --type integer 56 nextcloud-occ config:system:set memcache.local --value '\OC\Memcache\APCu' --type string 57 nextcloud-occ config:system:set memcache.distributed --value '\OC\Memcache\Memcached' --type string 58 ''; 59 withRcloneEnv = pkgs.writeScript "with-rclone-env" '' 60 #!${pkgs.runtimeShell} 61 export RCLONE_CONFIG_NEXTCLOUD_TYPE=webdav 62 export RCLONE_CONFIG_NEXTCLOUD_URL="http://nextcloud/remote.php/webdav/" 63 export RCLONE_CONFIG_NEXTCLOUD_VENDOR="nextcloud" 64 export RCLONE_CONFIG_NEXTCLOUD_USER="${adminuser}" 65 export RCLONE_CONFIG_NEXTCLOUD_PASS="$(${pkgs.rclone}/bin/rclone obscure ${adminpass})" 66 ''; 67 copySharedFile = pkgs.writeScript "copy-shared-file" '' 68 #!${pkgs.runtimeShell} 69 echo 'hi' | ${pkgs.rclone}/bin/rclone rcat nextcloud:test-shared-file 70 ''; 71 72 diffSharedFile = pkgs.writeScript "diff-shared-file" '' 73 #!${pkgs.runtimeShell} 74 diff <(echo 'hi') <(${pkgs.rclone}/bin/rclone cat nextcloud:test-shared-file) 75 ''; 76 in '' 77 start_all() 78 nextcloud.wait_for_unit("multi-user.target") 79 nextcloud.succeed("${configureMemcached}") 80 nextcloud.succeed("curl -sSf http://nextcloud/login") 81 nextcloud.succeed( 82 "${withRcloneEnv} ${copySharedFile}" 83 ) 84 client.wait_for_unit("multi-user.target") 85 client.succeed( 86 "${withRcloneEnv} ${diffSharedFile}" 87 ) 88 ''; 89})) args