Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion qa/integration/services/logstash_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,9 @@ def is_port_open?
# check REST API is responsive
def rest_active?
result = monitoring_api.node_info
started = !result.nil?
!result.nil?
rescue
return false
end

def monitoring_api
Expand Down
29 changes: 5 additions & 24 deletions qa/integration/specs/logstash_to_logstash_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,9 @@

before(:all) {
@fixture = Fixture.new(__FILE__)
# backup original setting file since we change API port number, and restore after all tests
FileUtils.cp(@fixture.get_service('logstash').application_settings_file, "#{@fixture.get_service('logstash').application_settings_file}.original")
}

after(:all) {
FileUtils.mv("#{@fixture.get_service('logstash').application_settings_file}.original", @fixture.get_service('logstash').application_settings_file)
@fixture.teardown
}

Expand All @@ -57,26 +54,10 @@ def run_logstash_instance(config_name, options = {}, &block)
"--path.config", config_to_temp_file(@fixture.config(config_name, options)),
"--path.data", get_temp_path_dir,
"--api.http.port", api_port.to_s)
wait_for_logstash(logstash_service)

logstash_service.wait_for_rest_api
yield logstash_service

ensure
logstash_service&.teardown
end

def wait_for_logstash(service)
wait_in_seconds = 60
while wait_in_seconds > 0 do
begin
return if service.rest_active?
rescue => e
puts "Exception: #{e.message}"
wait_in_seconds -= 1
sleep 1
end
end
raise "Logstash is not responsive after 60 seconds."
logstash_service.teardown
end

let(:num_retries) { 60 }
Expand All @@ -97,8 +78,8 @@ def wait_for_logstash(service)

try(num_retries) do
downstream_event_stats = downstream_logstash_service.monitoring_api.event_stats

expect(downstream_event_stats).to include({"in" => num_events}), lambda { "expected #{num_events} events to have been received by downstream"}
expect(downstream_event_stats).to include({"in" => num_events}), lambda { "expected #{num_events} events to have been received by downstream" }
expect(downstream_event_stats).to include({"out" => num_events}), lambda { "expected #{num_events} events to have been processed by downstream" }
end

# make sure received events are in the file
Expand All @@ -122,4 +103,4 @@ def wait_for_logstash(service)
include_examples "send events"
end

end
end