2525
2626describe "Logstash to Logstash communication Integration test" do
2727
28- before ( :all ) {
29- @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" )
32- }
33-
3428 after ( :all ) {
35- FileUtils . mv ( "#{ @fixture . get_service ( 'logstash' ) . application_settings_file } .original" , @fixture . get_service ( 'logstash' ) . application_settings_file )
3629 @fixture . teardown
3730 }
3831
@@ -57,26 +50,10 @@ def run_logstash_instance(config_name, options = {}, &block)
5750 "--path.config" , config_to_temp_file ( @fixture . config ( config_name , options ) ) ,
5851 "--path.data" , get_temp_path_dir ,
5952 "--api.http.port" , api_port . to_s )
60- wait_for_logstash ( logstash_service )
61-
53+ logstash_service . wait_for_rest_api
6254 yield logstash_service
63-
6455 ensure
65- logstash_service &.teardown
66- end
67-
68- def wait_for_logstash ( service )
69- wait_in_seconds = 60
70- while wait_in_seconds > 0 do
71- begin
72- return if service . rest_active?
73- rescue => e
74- puts "Exception: #{ e . message } "
75- wait_in_seconds -= 1
76- sleep 1
77- end
78- end
79- raise "Logstash is not responsive after 60 seconds."
56+ logstash_service . teardown
8057 end
8158
8259 let ( :num_retries ) { 60 }
@@ -97,7 +74,6 @@ def wait_for_logstash(service)
9774
9875 try ( num_retries ) do
9976 downstream_event_stats = downstream_logstash_service . monitoring_api . event_stats
100-
10177 expect ( downstream_event_stats ) . to include ( { "in" => num_events } ) , lambda { "expected #{ num_events } events to have been received by downstream" }
10278 expect ( downstream_event_stats ) . to include ( { "out" => num_events } ) , lambda { "expected #{ num_events } events to have been processed by downstream" }
10379 end
0 commit comments