mirror of
https://github.com/elastic/logstash.git
synced 2025-06-29 02:03:30 -04:00
* Add helper method to wait for log message to be observed There appears to be a race condition in tests whereby log messages are not observed with a single interogation of the container logs. This commit adds a helper method to wait for log messages. This should make the tests more resilient when there is a delay in log messages being captured. * Use local scop container ref Due to a copy paste error, the wrong reference to container (instance var) was being used. When test file that did not define this uses the helper it failed. The helper should use the ref explicitly passed to the method.
94 lines
2.9 KiB
Ruby
94 lines
2.9 KiB
Ruby
shared_examples_for 'it applies settings correctly' do |flavor|
|
|
before do
|
|
@image = find_image(flavor)
|
|
@container = start_container(@image, options)
|
|
wait_for_pipeline(@container)
|
|
end
|
|
|
|
after do
|
|
cleanup_container(@container)
|
|
end
|
|
|
|
context 'when setting pipeline workers shell style' do
|
|
let(:options) { { 'ENV' => ['PIPELINE_WORKERS=32'] } }
|
|
|
|
it "should correctly set the number of pipeline workers" do
|
|
expect(get_pipeline_setting(@container, 'workers')).to eql 32
|
|
end
|
|
end
|
|
|
|
context 'when setting pipeline workers dot style' do
|
|
let(:options) { { 'ENV' => ['pipeline.workers=64'] } }
|
|
|
|
it "should correctly set the number of pipeline workers" do
|
|
expect(get_pipeline_setting(@container, 'workers')).to eql 64
|
|
end
|
|
end
|
|
|
|
context 'when setting pipeline batch size' do
|
|
let(:options) { { 'ENV' => ['pipeline.batch.size=123'] } }
|
|
|
|
it "should correctly set the batch size" do
|
|
expect(get_pipeline_setting(@container, 'batch_size')).to eql 123
|
|
end
|
|
end
|
|
|
|
context 'when setting pipeline batch delay' do
|
|
let(:options) { { 'ENV' => ['pipeline.batch.delay=36'] } }
|
|
|
|
it 'should correctly set batch delay' do
|
|
expect(get_pipeline_setting(@container, 'batch_delay')).to eql 36
|
|
end
|
|
end
|
|
|
|
context 'when setting unsafe shutdown to true shell style' do
|
|
let(:options) { { 'ENV' => ['pipeline.unsafe_shutdown=true'] } }
|
|
|
|
it 'should set unsafe shutdown to true' do
|
|
expect(get_settings(@container)['pipeline.unsafe_shutdown']).to be_truthy
|
|
end
|
|
end
|
|
|
|
context 'when setting unsafe shutdown to true dot style' do
|
|
let(:options) { { 'ENV' => ['pipeline.unsafe_shutdown=true'] } }
|
|
|
|
it 'should set unsafe shutdown to true' do
|
|
expect(get_settings(@container)['pipeline.unsafe_shutdown']).to be_truthy
|
|
end
|
|
end
|
|
|
|
context 'when setting config.string' do
|
|
let(:options) {
|
|
{
|
|
'ENV' => [
|
|
'USER=kimchy',
|
|
'CONFIG_STRING=input {
|
|
beats { port => 5040 }
|
|
}
|
|
output {
|
|
elasticsearch {
|
|
hosts => ["https://es:9200"]
|
|
user => "${USER}"
|
|
password => \'changeme\'
|
|
}
|
|
}'
|
|
]
|
|
}
|
|
}
|
|
|
|
it "persists ${CONFIG_STRING} key in logstash.yml, resolves when running and spins up without issue" do
|
|
settings = get_settings(@container)
|
|
expect(settings['config.string']).to eq("${CONFIG_STRING}")
|
|
|
|
pipeline_config = get_pipeline_stats(@container)
|
|
input_plugins = pipeline_config.dig('plugins', 'inputs')
|
|
expect(input_plugins[0].dig('name')).to eql('beats')
|
|
|
|
output_plugins = pipeline_config.dig('plugins', 'outputs')
|
|
expect(output_plugins[0].dig('name')).to eql('elasticsearch')
|
|
|
|
# check if logs contain the ES request with the resolved ${USER}
|
|
wait_for_log_message(@container, 'https://kimchy:xxxxxx@es:9200')
|
|
end
|
|
end
|
|
end
|