From 364cbd088ef572a127731c140748d5a4be8c68d4 Mon Sep 17 00:00:00 2001 From: Peter Romfeld Date: Thu, 31 Jan 2019 10:38:48 +0800 Subject: minio: init at 4.0.13 --- nixos/tests/minio.nix | 29 +++++++++++++++++++++++++---- 1 file changed, 25 insertions(+), 4 deletions(-) (limited to 'nixos/tests/minio.nix') diff --git a/nixos/tests/minio.nix b/nixos/tests/minio.nix index 40a599546650a..f1218b537711a 100644 --- a/nixos/tests/minio.nix +++ b/nixos/tests/minio.nix @@ -1,4 +1,24 @@ -import ./make-test.nix ({ pkgs, ...} : { +import ./make-test.nix ({ pkgs, ...} : +let + accessKey = "BKIKJAA5BMMU2RHO6IBB"; + secretKey = "V7f1CwQqAcwo80UEIJEjc5gVQUSSx5ohQ9GSrr12"; + minioPythonScript = pkgs.writeScript "minio-test.py" '' + #! ${pkgs.python3.withPackages(ps: [ ps.minio ])}/bin/python + import io + import os + from minio import Minio + minioClient = Minio('localhost:9000', + access_key='${accessKey}', + secret_key='${secretKey}', + secure=False) + sio = io.BytesIO() + sio.write(b'Test from Python') + sio.seek(0, os.SEEK_END) + sio_len = sio.tell() + sio.seek(0) + minioClient.put_object('test-bucket', 'test.txt', sio, sio_len, content_type='text/plain') + ''; + in { name = "minio"; meta = with pkgs.stdenv.lib.maintainers; { maintainers = [ bachp ]; @@ -8,8 +28,7 @@ import ./make-test.nix ({ pkgs, ...} : { machine = { pkgs, ... }: { services.minio = { enable = true; - accessKey = "BKIKJAA5BMMU2RHO6IBB"; - secretKey = "V7f1CwQqAcwo80UEIJEjc5gVQUSSx5ohQ9GSrr12"; + inherit accessKey secretKey; }; environment.systemPackages = [ pkgs.minio-client ]; @@ -25,9 +44,11 @@ import ./make-test.nix ({ pkgs, ...} : { $machine->waitForOpenPort(9000); # Create a test bucket on the server - $machine->succeed("mc config host add minio http://localhost:9000 BKIKJAA5BMMU2RHO6IBB V7f1CwQqAcwo80UEIJEjc5gVQUSSx5ohQ9GSrr12 S3v4"); + $machine->succeed("mc config host add minio http://localhost:9000 ${accessKey} ${secretKey} S3v4"); $machine->succeed("mc mb minio/test-bucket"); + $machine->succeed("${minioPythonScript}"); $machine->succeed("mc ls minio") =~ /test-bucket/ or die; + $machine->succeed("mc cat minio/test-bucket/test.txt") =~ /Test from Python/ or die; $machine->shutdown; ''; -- cgit 1.4.1