Skip to content

Commit 6577643

Browse files
authored
Merge pull request #4 from mashhurs/ls2ls-test-fixes-suggestions
Suggestions to improve LS-to-LS spec.
2 parents 3376541 + b1b97aa commit 6577643

2 files changed

Lines changed: 3 additions & 27 deletions

File tree

qa/integration/services/logstash_service.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ def is_port_open?
220220
# check REST API is responsive
221221
def rest_active?
222222
result = monitoring_api.node_info
223-
started = !result.nil?
223+
!result.nil?
224224
end
225225

226226
def monitoring_api

qa/integration/specs/logstash_to_logstash_spec.rb

Lines changed: 2 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,7 @@
2525

2626
describe "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

Comments
 (0)