| 
									
										
										
										
											2016-09-13 16:38:45 +01:00
										 |  |  | # This test start mongodb, runs a query using mongo shell | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-03-26 13:46:22 +01:00
										 |  |  | import ./make-test-python.nix ({ pkgs, ... }: | 
					
						
							| 
									
										
										
										
											2019-08-04 16:25:56 +10:00
										 |  |  |   let | 
					
						
							|  |  |  |     testQuery = pkgs.writeScript "nixtest.js" ''
 | 
					
						
							|  |  |  |       db.greetings.insert({ "greeting": "hello" }); | 
					
						
							|  |  |  |       print(db.greetings.findOne().greeting); | 
					
						
							|  |  |  |     '';
 | 
					
						
							| 
									
										
										
										
											2016-09-13 16:38:45 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-08-04 16:25:56 +10:00
										 |  |  |     runMongoDBTest = pkg: ''
 | 
					
						
							| 
									
										
										
										
											2020-03-26 13:46:22 +01:00
										 |  |  |       node.execute("(rm -rf data || true) && mkdir data") | 
					
						
							|  |  |  |       node.execute( | 
					
						
							|  |  |  |           "${pkg}/bin/mongod --fork --logpath logs --dbpath data" | 
					
						
							|  |  |  |       ) | 
					
						
							|  |  |  |       node.wait_for_open_port(27017) | 
					
						
							| 
									
										
										
										
											2019-08-04 16:25:56 +10:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-03-26 13:46:22 +01:00
										 |  |  |       assert "hello" in node.succeed( | 
					
						
							|  |  |  |           "mongo ${testQuery}" | 
					
						
							|  |  |  |       ) | 
					
						
							| 
									
										
										
										
											2019-08-04 16:25:56 +10:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-03-26 13:46:22 +01:00
										 |  |  |       node.execute( | 
					
						
							|  |  |  |           "${pkg}/bin/mongod --shutdown --dbpath data" | 
					
						
							|  |  |  |       ) | 
					
						
							|  |  |  |       node.wait_for_closed_port(27017) | 
					
						
							| 
									
										
										
										
											2019-08-04 16:25:56 +10:00
										 |  |  |     '';
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   in { | 
					
						
							|  |  |  |     name = "mongodb"; | 
					
						
							|  |  |  |     meta = with pkgs.stdenv.lib.maintainers; { | 
					
						
							|  |  |  |       maintainers = [ bluescreen303 offline cstrahan rvl phile314 ]; | 
					
						
							|  |  |  |     }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     nodes = { | 
					
						
							|  |  |  |       node = {...}: { | 
					
						
							|  |  |  |         environment.systemPackages = with pkgs; [ | 
					
						
							| 
									
										
										
										
											2020-03-29 01:06:43 +01:00
										 |  |  |           mongodb-3_4 | 
					
						
							| 
									
										
										
										
											2019-08-04 16:25:56 +10:00
										 |  |  |           mongodb-3_6 | 
					
						
							|  |  |  |           mongodb-4_0 | 
					
						
							|  |  |  |         ]; | 
					
						
							|  |  |  |       }; | 
					
						
							| 
									
										
										
										
											2016-09-13 16:38:45 +01:00
										 |  |  |     }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-03-26 13:46:22 +01:00
										 |  |  |     testScript = ''
 | 
					
						
							|  |  |  |       node.start() | 
					
						
							|  |  |  |     ''
 | 
					
						
							| 
									
										
										
										
											2020-03-29 01:06:43 +01:00
										 |  |  |       + runMongoDBTest pkgs.mongodb-3_4 | 
					
						
							| 
									
										
										
										
											2019-08-04 16:25:56 +10:00
										 |  |  |       + runMongoDBTest pkgs.mongodb-3_6  | 
					
						
							|  |  |  |       + runMongoDBTest pkgs.mongodb-4_0 | 
					
						
							| 
									
										
										
										
											2020-03-26 13:46:22 +01:00
										 |  |  |       + ''
 | 
					
						
							|  |  |  |         node.shutdown() | 
					
						
							|  |  |  |       '';
 | 
					
						
							| 
									
										
										
										
											2019-08-04 16:25:56 +10:00
										 |  |  |   }) |