#8004 fix load order to start webserver after pipeline

Fixes #9398
This commit is contained in:
Tamara Braun 2017-10-22 14:02:45 +02:00 committed by Armin Braun
parent 57e7a8a56b
commit d919e93322
5 changed files with 21 additions and 29 deletions

View file

@ -84,12 +84,12 @@ class LogStash::Agent
@thread = Thread.current # this var is implicitly used by Stud.stop?
logger.debug("Starting agent")
start_webserver
transition_to_running
converge_state_and_update
start_webserver
if auto_reload?
# `sleep_then_run` instead of firing the interval right away
Stud.interval(@reload_interval, :sleep_then_run => true) do

View file

@ -20,13 +20,11 @@ def wait_for_port(port, retry_attempts)
end
def is_port_open?(port)
begin
s = TCPSocket.open("localhost", port)
s.close
TCPSocket.open("localhost", port) do
return true
rescue Errno::ECONNREFUSED, Errno::EHOSTUNREACH
return false
end
rescue Errno::ECONNREFUSED, Errno::EHOSTUNREACH
return false
end
def send_data(port, data)

View file

@ -17,7 +17,7 @@ class LogstashService < Service
SETTINGS_CLI_FLAG = "--path.settings"
STDIN_CONFIG = "input {stdin {}} output { }"
RETRY_ATTEMPTS = 10
RETRY_ATTEMPTS = 60
@process = nil
@ -115,7 +115,6 @@ class LogstashService < Service
@env_variables.map { |k, v| @process.environment[k] = v} unless @env_variables.nil?
@process.io.inherit!
@process.start
wait_for_logstash
puts "Logstash started with PID #{@process.pid}" if @process.alive?
end
end
@ -164,12 +163,13 @@ class LogstashService < Service
tries = RETRY_ATTEMPTS
while tries > 0
if is_port_open?
break
return
else
sleep 1
end
tries -= 1
end
raise "Logstash REST API did not come up after #{RETRY_ATTEMPTS}s."
end
# this method only overwrites existing config with new config

View file

@ -69,7 +69,6 @@ describe "Test that Logstash" do
test_env["LOGSTASH_KEYSTORE_PASS"] = "WRONG_PASSWRD"
@logstash.env_variables = test_env
@logstash.spawn_logstash("-e", "input {generator { count => 1 }} output { }", "--path.settings", settings_dir)
@logstash.wait_for_logstash
try(num_retries) do
expect(@logstash.exited?).to be(true)
end
@ -83,7 +82,6 @@ describe "Test that Logstash" do
test_env["LOGSTASH_KEYSTORE_PASS"] = "WRONG_PASSWRD"
@logstash.env_variables = test_env
@logstash.spawn_logstash("-e", "input {generator { count => 1 }} output { }", "--path.settings", settings_dir)
@logstash.wait_for_logstash
try(num_retries) do
expect(@logstash.exited?).to be(true)
end
@ -97,7 +95,6 @@ describe "Test that Logstash" do
test_env["LOGSTASH_KEYSTORE_PASS"] = "keystore_pa9454w3rd"
@logstash.env_variables = test_env
@logstash.spawn_logstash("-e", "input {stdin {}} output { }", "--path.settings", settings_dir)
@logstash.wait_for_logstash
try(num_retries) do
expect(@logstash.exited?).to be(true)
end

View file

@ -127,11 +127,8 @@ describe "Test Logstash instance whose default settings are overridden" do
http_port = random_port
change_setting("http.port", http_port)
@logstash_service.spawn_logstash("-e", tcp_config)
@logstash_service.wait_for_logstash
try(num_retries) do
wait_for_port(http_port, 60)
expect(is_port_open?(http_port)).to be true
end
# check LS is up and running with new data path
try(num_retries) do
expect(is_port_open?(test_port)).to be true