mirror of
https://github.com/ilyakooo0/nixpkgs.git
synced 2024-10-06 12:39:54 +03:00
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.
This commit is contained in:
parent
de1f4538e8
commit
6ecafb1c38
@ -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(
|
||||
"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}"
|
||||
)
|
||||
client.wait_for_unit("multi-user.target")
|
||||
nextcloud.succeed("${withRcloneEnv} ${diffSharedFile}")
|
||||
client.wait_until_succeeds(
|
||||
"${diffSharedFile}"
|
||||
"${withRcloneEnv} ${diffSharedFile}"
|
||||
)
|
||||
|
||||
nextcloud.succeed("mc ls --recursive minio >&2")
|
||||
'';
|
||||
})) args
|
||||
|
Loading…
Reference in New Issue
Block a user