| 
									
										
										
										
											2019-01-31 10:38:48 +08:00
										 |  |  | 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 { | 
					
						
							| 
									
										
										
										
											2017-06-25 18:43:10 +02:00
										 |  |  |   name = "minio"; | 
					
						
							|  |  |  |   meta = with pkgs.stdenv.lib.maintainers; { | 
					
						
							|  |  |  |     maintainers = [ bachp ]; | 
					
						
							|  |  |  |   }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-07-08 00:11:44 +02:00
										 |  |  |   nodes = { | 
					
						
							| 
									
										
										
										
											2018-07-20 20:56:59 +00:00
										 |  |  |     machine = { pkgs, ... }: { | 
					
						
							| 
									
										
										
										
											2017-07-08 00:11:44 +02:00
										 |  |  |       services.minio = { | 
					
						
							|  |  |  |         enable = true; | 
					
						
							| 
									
										
										
										
											2019-01-31 10:38:48 +08:00
										 |  |  |         inherit accessKey secretKey; | 
					
						
							| 
									
										
										
										
											2017-07-08 00:11:44 +02:00
										 |  |  |       }; | 
					
						
							|  |  |  |       environment.systemPackages = [ pkgs.minio-client ]; | 
					
						
							| 
									
										
										
										
											2017-10-01 20:58:28 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |       # Minio requires at least 1GiB of free disk space to run. | 
					
						
							|  |  |  |       virtualisation.diskSize = 4 * 1024; | 
					
						
							| 
									
										
										
										
											2017-07-08 00:11:44 +02:00
										 |  |  |     }; | 
					
						
							| 
									
										
										
										
											2017-06-25 18:43:10 +02:00
										 |  |  |   }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   testScript = | 
					
						
							|  |  |  |     ''
 | 
					
						
							|  |  |  |       startAll; | 
					
						
							|  |  |  |       $machine->waitForUnit("minio.service"); | 
					
						
							|  |  |  |       $machine->waitForOpenPort(9000); | 
					
						
							| 
									
										
										
										
											2017-07-08 00:11:44 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |       # Create a test bucket on the server | 
					
						
							| 
									
										
										
										
											2019-01-31 10:38:48 +08:00
										 |  |  |       $machine->succeed("mc config host add minio http://localhost:9000 ${accessKey} ${secretKey} S3v4"); | 
					
						
							| 
									
										
										
										
											2017-07-08 00:11:44 +02:00
										 |  |  |       $machine->succeed("mc mb minio/test-bucket"); | 
					
						
							| 
									
										
										
										
											2019-01-31 10:38:48 +08:00
										 |  |  |       $machine->succeed("${minioPythonScript}"); | 
					
						
							| 
									
										
										
										
											2017-07-08 00:11:44 +02:00
										 |  |  |       $machine->succeed("mc ls minio") =~ /test-bucket/ or die; | 
					
						
							| 
									
										
										
										
											2019-01-31 10:38:48 +08:00
										 |  |  |       $machine->succeed("mc cat minio/test-bucket/test.txt") =~ /Test from Python/ or die; | 
					
						
							| 
									
										
										
										
											2017-06-25 18:43:10 +02:00
										 |  |  |       $machine->shutdown; | 
					
						
							| 
									
										
										
										
											2017-07-08 00:11:44 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-06-25 18:43:10 +02:00
										 |  |  |     '';
 | 
					
						
							|  |  |  | }) |