2019-11-24 22:20:32 +03:00
|
|
|
import ./make-test-python.nix ({ pkgs, ...} :
|
2019-01-31 05:38:48 +03:00
|
|
|
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')
|
|
|
|
'';
|
2019-11-24 22:20:32 +03:00
|
|
|
in {
|
2017-06-25 19:43:10 +03:00
|
|
|
name = "minio";
|
2021-01-10 22:08:30 +03:00
|
|
|
meta = with pkgs.lib.maintainers; {
|
2017-06-25 19:43:10 +03:00
|
|
|
maintainers = [ bachp ];
|
|
|
|
};
|
|
|
|
|
2017-07-08 01:11:44 +03:00
|
|
|
nodes = {
|
2018-07-20 23:56:59 +03:00
|
|
|
machine = { pkgs, ... }: {
|
2017-07-08 01:11:44 +03:00
|
|
|
services.minio = {
|
|
|
|
enable = true;
|
2019-01-31 05:38:48 +03:00
|
|
|
inherit accessKey secretKey;
|
2017-07-08 01:11:44 +03:00
|
|
|
};
|
|
|
|
environment.systemPackages = [ pkgs.minio-client ];
|
2017-10-01 21:58:28 +03:00
|
|
|
|
|
|
|
# Minio requires at least 1GiB of free disk space to run.
|
|
|
|
virtualisation.diskSize = 4 * 1024;
|
2017-07-08 01:11:44 +03:00
|
|
|
};
|
2017-06-25 19:43:10 +03:00
|
|
|
};
|
|
|
|
|
2019-11-24 22:20:32 +03:00
|
|
|
testScript = ''
|
|
|
|
start_all()
|
|
|
|
machine.wait_for_unit("minio.service")
|
|
|
|
machine.wait_for_open_port(9000)
|
2017-07-08 01:11:44 +03:00
|
|
|
|
2019-11-24 22:20:32 +03:00
|
|
|
# Create a test bucket on the server
|
|
|
|
machine.succeed(
|
2020-05-02 12:20:00 +03:00
|
|
|
"mc config host add minio http://localhost:9000 ${accessKey} ${secretKey} --api s3v4"
|
2019-11-24 22:20:32 +03:00
|
|
|
)
|
|
|
|
machine.succeed("mc mb minio/test-bucket")
|
|
|
|
machine.succeed("${minioPythonScript}")
|
|
|
|
assert "test-bucket" in machine.succeed("mc ls minio")
|
|
|
|
assert "Test from Python" in machine.succeed("mc cat minio/test-bucket/test.txt")
|
|
|
|
machine.shutdown()
|
|
|
|
'';
|
2017-06-25 19:43:10 +03:00
|
|
|
})
|