1 import ./make-test-python.nix ({ pkgs, ...} :
3 accessKey = "BKIKJAA5BMMU2RHO6IBB";
4 secretKey = "V7f1CwQqAcwo80UEIJEjc5gVQUSSx5ohQ9GSrr12";
5 minioPythonScript = pkgs.writeScript "minio-test.py" ''
6 #! ${pkgs.python3.withPackages(ps: [ ps.minio ])}/bin/python
9 from minio import Minio
10 minioClient = Minio('localhost:9000',
11 access_key='${accessKey}',
12 secret_key='${secretKey}',
15 sio.write(b'Test from Python')
16 sio.seek(0, os.SEEK_END)
19 minioClient.put_object('test-bucket', 'test.txt', sio, sio_len, content_type='text/plain')
23 meta = with pkgs.lib.maintainers; {
24 maintainers = [ bachp ];
28 machine = { pkgs, ... }: {
31 rootCredentialsFile = pkgs.writeText "minio-credentials" ''
32 MINIO_ROOT_USER=${accessKey}
33 MINIO_ROOT_PASSWORD=${secretKey}
36 environment.systemPackages = [ pkgs.minio-client ];
38 # Minio requires at least 1GiB of free disk space to run.
39 virtualisation.diskSize = 4 * 1024;
45 machine.wait_for_unit("minio.service")
46 machine.wait_for_open_port(9000)
48 # Create a test bucket on the server
50 "mc config host add minio http://localhost:9000 ${accessKey} ${secretKey} --api s3v4"
52 machine.succeed("mc mb minio/test-bucket")
53 machine.succeed("${minioPythonScript}")
54 assert "test-bucket" in machine.succeed("mc ls minio")
55 assert "Test from Python" in machine.succeed("mc cat minio/test-bucket/test.txt")