| 
									
										
										
										
											2014-04-14 14:02:44 +02:00
										 |  |  | # This test runs logstash and checks if messages flows and | 
					
						
							|  |  |  | # elasticsearch is started. | 
					
						
							| 
									
										
										
										
											2013-11-01 14:09:17 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-07-12 12:09:40 +02:00
										 |  |  | import ./make-test.nix ({ pkgs, ...} : { | 
					
						
							| 
									
										
										
										
											2014-06-28 16:04:49 +02:00
										 |  |  |   name = "logstash"; | 
					
						
							| 
									
										
										
										
											2015-07-12 12:09:40 +02:00
										 |  |  |   meta = with pkgs.stdenv.lib.maintainers; { | 
					
						
							|  |  |  |     maintainers = [ eelco chaoflow offline ]; | 
					
						
							|  |  |  |   }; | 
					
						
							| 
									
										
										
										
											2013-11-01 14:09:17 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |   nodes = { | 
					
						
							|  |  |  |     one = | 
					
						
							|  |  |  |       { config, pkgs, ... }: | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |           services = { | 
					
						
							|  |  |  |             logstash = { | 
					
						
							|  |  |  |               enable = true; | 
					
						
							|  |  |  |               inputConfig = ''
 | 
					
						
							|  |  |  |                 exec { command => "echo flowers" interval => 1 type => "test" } | 
					
						
							|  |  |  |                 exec { command => "echo dragons" interval => 1 type => "test" } | 
					
						
							|  |  |  |               '';
 | 
					
						
							|  |  |  |               filterConfig = ''
 | 
					
						
							| 
									
										
										
										
											2015-09-06 15:19:52 +02:00
										 |  |  |                 if [message] =~ /dragons/ { | 
					
						
							|  |  |  |                   drop {} | 
					
						
							| 
									
										
										
										
											2013-11-01 14:09:17 +01:00
										 |  |  |                 } | 
					
						
							|  |  |  |               '';
 | 
					
						
							|  |  |  |               outputConfig = ''
 | 
					
						
							|  |  |  |                 stdout { codec => rubydebug } | 
					
						
							|  |  |  |                 elasticsearch { embedded => true } | 
					
						
							|  |  |  |               '';
 | 
					
						
							|  |  |  |             }; | 
					
						
							|  |  |  |           }; | 
					
						
							|  |  |  |         }; | 
					
						
							|  |  |  |     }; | 
					
						
							| 
									
										
										
										
											2014-04-14 14:02:44 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-11-01 14:09:17 +01:00
										 |  |  |   testScript = ''
 | 
					
						
							|  |  |  |     startAll; | 
					
						
							| 
									
										
										
										
											2014-04-14 14:02:44 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-11-01 14:09:17 +01:00
										 |  |  |     $one->waitForUnit("logstash.service"); | 
					
						
							|  |  |  |     $one->waitUntilSucceeds("journalctl -n 20 _SYSTEMD_UNIT=logstash.service | grep flowers"); | 
					
						
							|  |  |  |     $one->fail("journalctl -n 20 _SYSTEMD_UNIT=logstash.service | grep dragons"); | 
					
						
							|  |  |  |     $one->waitUntilSucceeds("curl -s http://127.0.0.1:9200/_status?pretty=true | grep logstash"); | 
					
						
							|  |  |  |   '';
 | 
					
						
							| 
									
										
										
										
											2015-07-12 12:09:40 +02:00
										 |  |  | }) |