2727
2828 before ( :all ) {
2929 @fixture = Fixture . new ( __FILE__ )
30- # backup original setting file since we change API port number, and restore after all tests
31- FileUtils . cp ( @fixture . get_service ( 'logstash' ) . application_settings_file , "#{ @fixture . get_service ( 'logstash' ) . application_settings_file } .original" )
3230 }
3331
3432 after ( :all ) {
35- FileUtils . mv ( "#{ @fixture . get_service ( 'logstash' ) . application_settings_file } .original" , @fixture . get_service ( 'logstash' ) . application_settings_file )
3633 @fixture . teardown
3734 }
3835
@@ -58,26 +55,10 @@ def run_logstash_instance(config_name, options = {}, &block)
5855 "--path.data" , get_temp_path_dir ,
5956 "--api.http.port" , api_port . to_s ,
6057 "--config.reload.automatic" )
61- wait_for_logstash ( logstash_service )
62-
58+ logstash_service . wait_for_rest_api
6359 yield logstash_service
64-
6560 ensure
66- logstash_service &.teardown
67- end
68-
69- def wait_for_logstash ( service )
70- wait_in_seconds = 60
71- while wait_in_seconds > 0 do
72- begin
73- return if service . rest_active?
74- rescue => e
75- puts "Exception: #{ e . message } "
76- wait_in_seconds -= 1
77- sleep 1
78- end
79- end
80- raise "Logstash is not responsive after 60 seconds."
61+ logstash_service . teardown
8162 end
8263
8364 let ( :num_retries ) { 60 }
@@ -98,8 +79,8 @@ def wait_for_logstash(service)
9879
9980 try ( num_retries ) do
10081 downstream_event_stats = downstream_logstash_service . monitoring_api . event_stats
101-
102- expect ( downstream_event_stats ) . to include ( { "in " => num_events } ) , lambda { "expected #{ num_events } events to have been received by downstream" }
82+ expect ( downstream_event_stats ) . to include ( { "in" => num_events } ) , lambda { "expected #{ num_events } events to have been received by downstream" }
83+ expect ( downstream_event_stats ) . to include ( { "out " => num_events } ) , lambda { "expected #{ num_events } events to have been processed by downstream" }
10384 end
10485
10586 # make sure received events are in the file
@@ -123,4 +104,4 @@ def wait_for_logstash(service)
123104 include_examples "send events"
124105 end
125106
126- end
107+ end
0 commit comments