at 23.11-pre 3.3 kB view raw
1args@{ pkgs, nextcloudVersion ? 22, ... }: 2 3(import ../make-test-python.nix ({ pkgs, ...}: let 4 adminpass = "hunter2"; 5 adminuser = "custom-admin-username"; 6in { 7 name = "nextcloud-with-postgresql-and-redis"; 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, lib, ... }: { 17 networking.firewall.allowedTCPPorts = [ 80 ]; 18 19 services.nextcloud = { 20 enable = true; 21 hostName = "nextcloud"; 22 package = pkgs.${"nextcloud" + (toString nextcloudVersion)}; 23 caching = { 24 apcu = false; 25 redis = true; 26 memcached = false; 27 }; 28 database.createLocally = true; 29 config = { 30 dbtype = "pgsql"; 31 inherit adminuser; 32 adminpassFile = toString (pkgs.writeText "admin-pass-file" '' 33 ${adminpass} 34 ''); 35 trustedProxies = [ "::1" ]; 36 }; 37 notify_push = { 38 enable = true; 39 logLevel = "debug"; 40 }; 41 extraAppsEnable = true; 42 extraApps = { 43 inherit (pkgs."nextcloud${lib.versions.major config.services.nextcloud.package.version}Packages".apps) notify_push; 44 }; 45 }; 46 47 services.redis.servers."nextcloud".enable = true; 48 services.redis.servers."nextcloud".port = 6379; 49 }; 50 }; 51 52 testScript = let 53 configureRedis = pkgs.writeScript "configure-redis" '' 54 #!${pkgs.runtimeShell} 55 nextcloud-occ config:system:set redis 'host' --value 'localhost' --type string 56 nextcloud-occ config:system:set redis 'port' --value 6379 --type integer 57 nextcloud-occ config:system:set memcache.local --value '\OC\Memcache\Redis' --type string 58 nextcloud-occ config:system:set memcache.locking --value '\OC\Memcache\Redis' --type string 59 ''; 60 withRcloneEnv = pkgs.writeScript "with-rclone-env" '' 61 #!${pkgs.runtimeShell} 62 export RCLONE_CONFIG_NEXTCLOUD_TYPE=webdav 63 export RCLONE_CONFIG_NEXTCLOUD_URL="http://nextcloud/remote.php/webdav/" 64 export RCLONE_CONFIG_NEXTCLOUD_VENDOR="nextcloud" 65 export RCLONE_CONFIG_NEXTCLOUD_USER="${adminuser}" 66 export RCLONE_CONFIG_NEXTCLOUD_PASS="$(${pkgs.rclone}/bin/rclone obscure ${adminpass})" 67 "''${@}" 68 ''; 69 copySharedFile = pkgs.writeScript "copy-shared-file" '' 70 #!${pkgs.runtimeShell} 71 echo 'hi' | ${pkgs.rclone}/bin/rclone rcat nextcloud:test-shared-file 72 ''; 73 74 diffSharedFile = pkgs.writeScript "diff-shared-file" '' 75 #!${pkgs.runtimeShell} 76 diff <(echo 'hi') <(${pkgs.rclone}/bin/rclone cat nextcloud:test-shared-file) 77 ''; 78 in '' 79 start_all() 80 nextcloud.wait_for_unit("multi-user.target") 81 nextcloud.succeed("${configureRedis}") 82 nextcloud.succeed("curl -sSf http://nextcloud/login") 83 nextcloud.succeed( 84 "${withRcloneEnv} ${copySharedFile}" 85 ) 86 client.wait_for_unit("multi-user.target") 87 client.execute("${pkgs.nextcloud-notify_push.passthru.test_client}/bin/test_client http://nextcloud ${adminuser} ${adminpass} >&2 &") 88 client.succeed( 89 "${withRcloneEnv} ${diffSharedFile}" 90 ) 91 nextcloud.wait_until_succeeds("journalctl -u nextcloud-notify_push | grep -q \"Sending ping to ${adminuser}\"") 92 ''; 93})) args