mirror of
https://github.com/elastic/logstash.git
synced 2025-04-24 06:37:19 -04:00
Test fixes: This should fix a couple different test failures.
* Fixes #8344 - Ruby Unit Test can hang with no information as to why * Fixes #7227 - MetricStore::MetricNotFound * Fixes #8204 - `config.reload.automatic` is set to`FALSE I am only certain it fixes #8344 and #7227, since I can not reproduce #8204. Fixes #8376
This commit is contained in:
parent
53fe0cd350
commit
129519df67
3 changed files with 33 additions and 11 deletions
|
@ -71,9 +71,16 @@ describe LogStash::Agent do
|
|||
TestSourceLoader.new(infinite_pipeline_config, system_pipeline_config)
|
||||
end
|
||||
|
||||
before(:each) do
|
||||
@agent_task = start_agent(subject)
|
||||
end
|
||||
|
||||
after(:each) do
|
||||
@agent_task.stop!
|
||||
end
|
||||
|
||||
describe "#running_user_defined_pipelines" do
|
||||
it "returns the user defined pipelines" do
|
||||
start_agent(subject)
|
||||
wait_for do
|
||||
subject.with_running_user_defined_pipelines {|pipelines| pipelines.keys }
|
||||
end.to eq([:main])
|
||||
|
@ -82,7 +89,6 @@ describe LogStash::Agent do
|
|||
|
||||
describe "#running_user_defined_pipelines?" do
|
||||
it "returns true" do
|
||||
start_agent(subject)
|
||||
wait_for do
|
||||
subject.running_user_defined_pipelines?
|
||||
end.to be_truthy
|
||||
|
@ -102,14 +108,19 @@ describe LogStash::Agent do
|
|||
context "and successfully load the config" do
|
||||
let(:agent_settings) { mock_settings("config.reload.automatic" => false) }
|
||||
|
||||
it "converge only once" do
|
||||
agent_task = start_agent(subject)
|
||||
before(:each) do
|
||||
@agent_task = start_agent(subject)
|
||||
end
|
||||
|
||||
after(:each) do
|
||||
@agent_task.stop!
|
||||
end
|
||||
|
||||
it "converge only once" do
|
||||
expect(source_loader.fetch_count).to eq(1)
|
||||
expect(subject).to have_running_pipeline?(pipeline_config)
|
||||
|
||||
subject.shutdown
|
||||
agent_task.stop!
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -137,11 +148,16 @@ describe LogStash::Agent do
|
|||
"config.reload.interval" => interval
|
||||
)
|
||||
end
|
||||
before(:each) do
|
||||
@agent_task = start_agent(subject)
|
||||
end
|
||||
|
||||
after(:each) do
|
||||
@agent_task.stop!
|
||||
end
|
||||
|
||||
context "and successfully load the config" do
|
||||
it "converges periodically the pipelines from the configs source" do
|
||||
agent_task = start_agent(subject)
|
||||
|
||||
sleep(2) # let the interval reload a few times
|
||||
expect(subject).to have_running_pipeline?(pipeline_config)
|
||||
|
||||
|
@ -152,7 +168,6 @@ describe LogStash::Agent do
|
|||
end
|
||||
|
||||
subject.shutdown
|
||||
agent_task.stop!
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -162,14 +177,12 @@ describe LogStash::Agent do
|
|||
end
|
||||
|
||||
it "it will keep trying to converge" do
|
||||
agent_task = start_agent(subject)
|
||||
|
||||
sleep(agent_settings.get("config.reload.interval") / 1_000_000_000.0 * 20) # let the interval reload a few times
|
||||
expect(subject.pipelines_count).to eq(0)
|
||||
expect(source_loader.fetch_count).to be > 1
|
||||
|
||||
subject.shutdown
|
||||
agent_task.stop!
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -77,7 +77,7 @@ def start_agent(agent)
|
|||
end
|
||||
end
|
||||
|
||||
sleep(0.1) unless subject.running?
|
||||
wait(30).for { agent.running? }.to be(true)
|
||||
agent_task
|
||||
end
|
||||
|
||||
|
|
|
@ -21,12 +21,21 @@ shared_context "api setup" do
|
|||
settings = mock_settings
|
||||
config_string = "input { generator {id => 'api-generator-pipeline' count => 100 } } output { dummyoutput {} }"
|
||||
settings.set("config.string", config_string)
|
||||
settings.set("config.reload.automatic", false)
|
||||
@agent = make_test_agent(settings)
|
||||
@agent.execute
|
||||
pipeline_config = mock_pipeline_config(:main, "input { generator { id => '123' } } output { null {} }")
|
||||
pipeline_creator = LogStash::PipelineAction::Create.new(pipeline_config, @agent.metric)
|
||||
@pipelines = Hash.new
|
||||
expect(pipeline_creator.execute(@agent, @pipelines)).to be_truthy
|
||||
end
|
||||
|
||||
after :all do
|
||||
@agent.shutdown
|
||||
@pipelines.each do |_, pipeline|
|
||||
pipeline.shutdown
|
||||
pipeline.thread.join
|
||||
end
|
||||
end
|
||||
|
||||
include Rack::Test::Methods
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue