about summary refs log tree commit diff
path: root/nixos/tests
diff options
context:
space:
mode:
authorMaximilian Bosch <maximilian@mbosch.me>2024-06-10 13:52:47 +0200
committerMaximilian Bosch <maximilian@mbosch.me>2024-06-11 12:37:42 +0200
commit6ecafb1c38b5d443834f6040b861d8169bf26b9a (patch)
tree2952cd4b03742e81f8ef9dc663960c79a0eedbb8 /nixos/tests
parentde1f4538e8c711fd5a2d9d17d7537414867e5a6e (diff)
nixos/nextcloud: fix objectstore/s3 test
* Make sure `withRcloneEnv` actually invokes the command it gets as
  `argv`. Until no, nothing was uploaded. This mistake was copied from
  the MySQL test that appears to have the same issue (will be addressed
  in the next commit).

* Test upload/download through with rclone once to see if Nextcloud
  interaction with S3 works fine.

* Make sure we actually have something in the bucket (until now with an
  `ls` and no real check, will do some larger cleanups and make this
  better in the next commit).

* Use actual AWS-style access keys.
Diffstat (limited to 'nixos/tests')
-rw-r--r--nixos/tests/nextcloud/with-objectstore.nix35
1 files changed, 22 insertions, 13 deletions
diff --git a/nixos/tests/nextcloud/with-objectstore.nix b/nixos/tests/nextcloud/with-objectstore.nix
index 6fec63b4aee22..1ca297c1c4d9e 100644
--- a/nixos/tests/nextcloud/with-objectstore.nix
+++ b/nixos/tests/nextcloud/with-objectstore.nix
@@ -4,8 +4,8 @@ args@{ pkgs, nextcloudVersion ? 28, ... }:
   adminpass = "hunter2";
   adminuser = "root";
 
-  accessKey = "nextcloud";
-  secretKey = "test12345";
+  accessKey = "BKIKJAA5BMMU2RHO6IBB";
+  secretKey = "V7f1CwQqAcwo80UEIJEjc5gVQUSSx5ohQ9GSrr12";
 
   rootCredentialsFile = pkgs.writeText "minio-credentials-full" ''
     MINIO_ROOT_USER=${accessKey}
@@ -15,7 +15,7 @@ args@{ pkgs, nextcloudVersion ? 28, ... }:
 in {
   name = "nextcloud-with-objectstore";
   meta = with pkgs.lib.maintainers; {
-    maintainers = [ onny ];
+    maintainers = [ onny ma27 ];
   };
 
   nodes = {
@@ -23,7 +23,8 @@ in {
     client = { ... }: {};
 
     nextcloud = { config, pkgs, ... }: {
-      networking.firewall.allowedTCPPorts = [ 9000 ];
+      networking.firewall.allowedTCPPorts = [ 80 9000 ];
+      environment.systemPackages = [ pkgs.minio-client ];
 
       services.nextcloud = {
         enable = true;
@@ -35,8 +36,8 @@ in {
         config.objectstore.s3 = {
           enable = true;
           bucket = "nextcloud";
-          autocreate = true;
-          key = "nextcloud";
+          autocreate = false;
+          key = accessKey;
           secretFile = "${pkgs.writeText "secretKey" secretKey}";
           hostname = "nextcloud";
           useSsl = false;
@@ -64,31 +65,39 @@ in {
       export RCLONE_CONFIG_NEXTCLOUD_VENDOR="nextcloud"
       export RCLONE_CONFIG_NEXTCLOUD_USER="${adminuser}"
       export RCLONE_CONFIG_NEXTCLOUD_PASS="$(${pkgs.rclone}/bin/rclone obscure ${adminpass})"
+      "''${@}"
     '';
     copySharedFile = pkgs.writeScript "copy-shared-file" ''
       #!${pkgs.runtimeShell}
+      set -euxo pipefail
       echo 'hello world' | ${pkgs.rclone}/bin/rclone rcat nextcloud:test-shared-file
     '';
 
     diffSharedFile = pkgs.writeScript "diff-shared-file" ''
       #!${pkgs.runtimeShell}
-      export AWS_ACCESS_KEY_ID=${accessKey}
-      export AWS_SECRET_ACCESS_KEY=${secretKey}
-      ${pkgs.awscli2}/bin/aws s3 cp s3://nextcloud /tmp/. --recursive --endpoint-url http://nextcloud:9000 --region us-east-1
-      grep -r "hello world" /tmp
+      set -euxo pipefail
+      diff <(echo 'hello world') <(${pkgs.rclone}/bin/rclone cat nextcloud:test-shared-file)
     '';
   in ''
     start_all()
     nextcloud.wait_for_unit("multi-user.target")
     nextcloud.wait_for_unit("minio.service")
     nextcloud.wait_for_open_port(9000)
-    nextcloud.succeed("curl -sSf http://nextcloud/login")
     nextcloud.succeed(
-        "${withRcloneEnv} ${copySharedFile}"
+        "mc config host add minio http://localhost:9000 ${accessKey} ${secretKey} --api s3v4"
     )
+    nextcloud.succeed("mc mb minio/nextcloud")
+    nextcloud.succeed("curl -sSf http://nextcloud/login")
+
     client.wait_for_unit("multi-user.target")
+    client.succeed(
+        "${withRcloneEnv} ${copySharedFile}"
+    )
+    nextcloud.succeed("${withRcloneEnv} ${diffSharedFile}")
     client.wait_until_succeeds(
-        "${diffSharedFile}"
+        "${withRcloneEnv} ${diffSharedFile}"
     )
+
+    nextcloud.succeed("mc ls --recursive minio >&2")
   '';
 })) args