logstash-core 5.3.3-java → 5.4.0-java

Sign up to get free protection for your applications and to get access to all the features.
Files changed (85) hide show
  1. checksums.yaml +4 -4
  2. data/gemspec_jars.rb +2 -0
  3. data/lib/logstash-core/logstash-core.jar +0 -0
  4. data/lib/logstash-core/version.rb +1 -1
  5. data/lib/logstash-core_jars.rb +4 -0
  6. data/lib/logstash/agent.rb +15 -6
  7. data/lib/logstash/api/modules/base.rb +1 -1
  8. data/lib/logstash/api/rack_app.rb +1 -1
  9. data/lib/logstash/config/config_ast.rb +13 -13
  10. data/lib/logstash/config/mixin.rb +33 -28
  11. data/lib/logstash/environment.rb +11 -0
  12. data/lib/logstash/event.rb +56 -0
  13. data/lib/logstash/event_dispatcher.rb +2 -2
  14. data/lib/logstash/execution_context.rb +10 -0
  15. data/lib/logstash/filter_delegator.rb +3 -2
  16. data/lib/logstash/inputs/base.rb +15 -1
  17. data/lib/logstash/instrument/collector.rb +1 -1
  18. data/lib/logstash/instrument/metric.rb +4 -2
  19. data/lib/logstash/instrument/metric_store.rb +9 -5
  20. data/lib/logstash/instrument/null_metric.rb +1 -0
  21. data/lib/logstash/instrument/periodic_poller/cgroup.rb +3 -3
  22. data/lib/logstash/instrument/periodic_poller/jvm.rb +11 -8
  23. data/lib/logstash/instrument/periodic_poller/load_average.rb +4 -2
  24. data/lib/logstash/instrument/wrapped_write_client.rb +59 -0
  25. data/lib/logstash/java_integration.rb +2 -2
  26. data/lib/logstash/output_delegator.rb +2 -2
  27. data/lib/logstash/output_delegator_strategies/legacy.rb +5 -2
  28. data/lib/logstash/output_delegator_strategies/shared.rb +2 -1
  29. data/lib/logstash/output_delegator_strategies/single.rb +2 -1
  30. data/lib/logstash/outputs/base.rb +8 -0
  31. data/lib/logstash/patches/cabin.rb +1 -1
  32. data/lib/logstash/patches/stronger_openssl_defaults.rb +1 -1
  33. data/lib/logstash/pipeline.rb +47 -19
  34. data/lib/logstash/plugin.rb +3 -1
  35. data/lib/logstash/plugins/hooks_registry.rb +6 -6
  36. data/lib/logstash/plugins/registry.rb +2 -2
  37. data/lib/logstash/queue_factory.rb +7 -5
  38. data/lib/logstash/runner.rb +15 -1
  39. data/lib/logstash/settings.rb +14 -2
  40. data/lib/logstash/string_interpolation.rb +18 -0
  41. data/lib/logstash/timestamp.rb +27 -0
  42. data/lib/logstash/util.rb +1 -1
  43. data/lib/logstash/util/prctl.rb +1 -1
  44. data/lib/logstash/util/retryable.rb +1 -1
  45. data/lib/logstash/util/wrapped_acked_queue.rb +53 -22
  46. data/lib/logstash/util/wrapped_synchronous_queue.rb +51 -33
  47. data/lib/logstash/version.rb +1 -1
  48. data/locales/en.yml +4 -2
  49. data/logstash-core.gemspec +0 -3
  50. data/spec/api/lib/api/node_stats_spec.rb +2 -1
  51. data/spec/api/spec_helper.rb +1 -1
  52. data/spec/logstash/acked_queue_concurrent_stress_spec.rb +291 -0
  53. data/spec/logstash/agent_spec.rb +24 -0
  54. data/spec/logstash/config/mixin_spec.rb +11 -2
  55. data/spec/logstash/event_dispatcher_spec.rb +8 -1
  56. data/spec/logstash/event_spec.rb +346 -0
  57. data/spec/logstash/execution_context_spec.rb +13 -0
  58. data/spec/logstash/filter_delegator_spec.rb +4 -2
  59. data/spec/logstash/inputs/base_spec.rb +41 -0
  60. data/spec/logstash/instrument/metric_spec.rb +2 -1
  61. data/spec/logstash/instrument/metric_store_spec.rb +14 -0
  62. data/spec/logstash/instrument/namespaced_metric_spec.rb +2 -1
  63. data/spec/logstash/instrument/periodic_poller/cgroup_spec.rb +1 -1
  64. data/spec/logstash/instrument/periodic_poller/jvm_spec.rb +35 -0
  65. data/spec/logstash/instrument/periodic_poller/load_average_spec.rb +1 -5
  66. data/spec/logstash/instrument/wrapped_write_client_spec.rb +113 -0
  67. data/spec/logstash/json_spec.rb +1 -1
  68. data/spec/logstash/legacy_ruby_event_spec.rb +636 -0
  69. data/spec/logstash/legacy_ruby_timestamp_spec.rb +170 -0
  70. data/spec/logstash/output_delegator_spec.rb +6 -3
  71. data/spec/logstash/outputs/base_spec.rb +23 -0
  72. data/spec/logstash/pipeline_pq_file_spec.rb +18 -8
  73. data/spec/logstash/pipeline_spec.rb +41 -5
  74. data/spec/logstash/plugin_spec.rb +15 -3
  75. data/spec/logstash/plugins/hooks_registry_spec.rb +2 -2
  76. data/spec/logstash/runner_spec.rb +33 -2
  77. data/spec/logstash/settings/port_range_spec.rb +1 -1
  78. data/spec/logstash/settings_spec.rb +21 -0
  79. data/spec/logstash/timestamp_spec.rb +29 -0
  80. data/spec/logstash/util/accessors_spec.rb +179 -0
  81. data/spec/logstash/util/wrapped_synchronous_queue_spec.rb +4 -11
  82. data/spec/logstash/util_spec.rb +1 -1
  83. data/spec/logstash/webserver_spec.rb +1 -1
  84. data/spec/support/mocks_classes.rb +65 -53
  85. metadata +25 -30
@@ -0,0 +1,170 @@
1
+ # encoding: utf-8
2
+ require "spec_helper"
3
+ require "logstash/timestamp"
4
+ require "bigdecimal"
5
+
6
+ describe LogStash::Timestamp do
7
+
8
+ it "should parse its own iso8601 output" do
9
+ t = Time.now
10
+ ts = LogStash::Timestamp.new(t)
11
+ expect(LogStash::Timestamp.parse_iso8601(ts.to_iso8601).to_i).to eq(t.to_i)
12
+ end
13
+
14
+ it "should coerce iso8601 string" do
15
+ t = Time.now
16
+ ts = LogStash::Timestamp.new(t)
17
+ expect(LogStash::Timestamp.coerce(ts.to_iso8601).to_i).to eq(t.to_i)
18
+ end
19
+
20
+ it "should coerce Time" do
21
+ t = Time.now
22
+ expect(LogStash::Timestamp.coerce(t).to_i).to eq(t.to_i)
23
+ end
24
+
25
+ it "should coerce Timestamp" do
26
+ t = LogStash::Timestamp.now
27
+ expect(LogStash::Timestamp.coerce(t).to_i).to eq(t.to_i)
28
+ end
29
+
30
+ it "should raise on invalid string coerce" do
31
+ expect{LogStash::Timestamp.coerce("foobar")}.to raise_error LogStash::TimestampParserError
32
+ end
33
+
34
+ it "should return nil on invalid object coerce" do
35
+ expect(LogStash::Timestamp.coerce(:foobar)).to be_nil
36
+ end
37
+
38
+ it "should support to_json" do
39
+ expect(LogStash::Timestamp.parse_iso8601("2014-09-23T00:00:00-0800").to_json).to eq("\"2014-09-23T08:00:00.000Z\"")
40
+ end
41
+
42
+ it "should support to_json and ignore arguments" do
43
+ expect(LogStash::Timestamp.parse_iso8601("2014-09-23T00:00:00-0800").to_json(:some => 1, :arguments => "test")).to eq("\"2014-09-23T08:00:00.000Z\"")
44
+ end
45
+
46
+ it "should support timestamp comparison" do
47
+ current = LogStash::Timestamp.new(Time.now)
48
+ future = LogStash::Timestamp.new(Time.now + 100)
49
+
50
+ expect(future > current).to eq(true)
51
+ expect(future < current).to eq(false)
52
+ expect(current == current).to eq(true)
53
+
54
+ expect(current <=> current).to eq(0)
55
+ expect(current <=> future).to eq(-1)
56
+ expect(future <=> current).to eq(1)
57
+ end
58
+
59
+ it "should allow unary operation +" do
60
+ current = Time.now
61
+ t = LogStash::Timestamp.new(current) + 10
62
+ expect(t).to eq(current + 10)
63
+ end
64
+
65
+ describe "subtraction" do
66
+ it "should work on a timestamp object" do
67
+ t = Time.now
68
+ current = LogStash::Timestamp.new(t)
69
+ future = LogStash::Timestamp.new(t + 10)
70
+ expect(future - current).to eq(10)
71
+ end
72
+
73
+ it "should work on with time object" do
74
+ current = Time.now
75
+ t = LogStash::Timestamp.new(current + 10)
76
+ expect(t - current).to eq(10)
77
+ end
78
+
79
+ it "should work with numeric value" do
80
+ current = Time.now
81
+ t = LogStash::Timestamp.new(current + 10)
82
+ expect(t - 10).to eq(current)
83
+ end
84
+ end
85
+
86
+ context "identity methods" do
87
+ subject { LogStash::Timestamp.new }
88
+
89
+ it "should support utc" do
90
+ expect(subject.utc).to eq(subject)
91
+ end
92
+
93
+ it "should support gmtime" do
94
+ expect(subject.gmtime).to eq(subject)
95
+ end
96
+ end
97
+
98
+ context "numeric casting methods" do
99
+ let (:now) {Time.now}
100
+ subject { LogStash::Timestamp.new(now) }
101
+
102
+ it "should support to_i" do
103
+ expect(subject.to_i).to eq(now.to_i)
104
+ end
105
+
106
+ it "should support to_f" do
107
+ expect(subject.to_f).to eq(now.to_f)
108
+ end
109
+ end
110
+
111
+ context "at" do
112
+ context "with integer epoch" do
113
+ it "should convert to correct date" do
114
+ expect(LogStash::Timestamp.at(946702800).to_iso8601).to eq("2000-01-01T05:00:00.000Z")
115
+ end
116
+
117
+ it "should return zero usec" do
118
+ expect(LogStash::Timestamp.at(946702800).usec).to eq(0)
119
+ end
120
+
121
+ it "should return prior to epoch date on negative input" do
122
+ expect(LogStash::Timestamp.at(-1).to_iso8601).to eq("1969-12-31T23:59:59.000Z")
123
+ end
124
+ end
125
+
126
+ context "with float epoch" do
127
+ it "should convert to correct date" do
128
+ expect(LogStash::Timestamp.at(946702800.123456.to_f).to_iso8601).to eq("2000-01-01T05:00:00.123Z")
129
+ end
130
+
131
+ it "should return usec with a minimum of millisec precision" do
132
+ expect(LogStash::Timestamp.at(946702800.123456.to_f).usec).to be_within(1000).of(123456)
133
+ end
134
+ end
135
+
136
+ context "with BigDecimal epoch" do
137
+ it "should convert to correct date" do
138
+ expect(LogStash::Timestamp.at(BigDecimal.new("946702800.123456")).to_iso8601).to eq("2000-01-01T05:00:00.123Z")
139
+ end
140
+
141
+ it "should return usec with a minimum of millisec precision" do
142
+ # since Java Timestamp relies on JodaTime which supports only milliseconds precision
143
+ # the usec method will only be precise up to milliseconds.
144
+ expect(LogStash::Timestamp.at(BigDecimal.new("946702800.123456")).usec).to be_within(1000).of(123456)
145
+ end
146
+ end
147
+
148
+ context "with illegal parameters" do
149
+ it "should raise exception on nil input" do
150
+ expect{LogStash::Timestamp.at(nil)}.to raise_error
151
+ end
152
+
153
+ it "should raise exception on invalid input type" do
154
+ expect{LogStash::Timestamp.at(:foo)}.to raise_error
155
+ end
156
+ end
157
+ end
158
+
159
+ context "usec" do
160
+ it "should support millisecond precision" do
161
+ expect(LogStash::Timestamp.at(946702800.123).usec).to eq(123000)
162
+ end
163
+
164
+ it "should try to preserve and report microseconds precision if possible" do
165
+ # since Java Timestamp relies on JodaTime which supports only milliseconds precision
166
+ # the usec method will only be precise up to milliseconds.
167
+ expect(LogStash::Timestamp.at(946702800.123456).usec).to be_within(1000).of(123456)
168
+ end
169
+ end
170
+ end
@@ -1,6 +1,7 @@
1
1
  # encoding: utf-8
2
2
  require "logstash/output_delegator"
3
- require 'spec_helper'
3
+ require "logstash/execution_context"
4
+ require "spec_helper"
4
5
 
5
6
  describe LogStash::OutputDelegator do
6
7
  let(:logger) { double("logger") }
@@ -8,8 +9,9 @@ describe LogStash::OutputDelegator do
8
9
  let(:plugin_args) { {"id" => "foo", "arg1" => "val1"} }
9
10
  let(:collector) { [] }
10
11
  let(:metric) { LogStash::Instrument::NamespacedNullMetric.new(collector, :null) }
12
+ let(:default_execution_context) { LogStash::ExecutionContext.new(:main) }
11
13
 
12
- subject { described_class.new(logger, out_klass, metric, ::LogStash::OutputDelegatorStrategyRegistry.instance, plugin_args) }
14
+ subject { described_class.new(logger, out_klass, metric, default_execution_context, ::LogStash::OutputDelegatorStrategyRegistry.instance, plugin_args) }
13
15
 
14
16
  context "with a plain output plugin" do
15
17
  let(:out_klass) { double("output klass") }
@@ -27,6 +29,7 @@ describe LogStash::OutputDelegator do
27
29
  allow(out_inst).to receive(:register)
28
30
  allow(out_inst).to receive(:multi_receive)
29
31
  allow(out_inst).to receive(:metric=).with(any_args)
32
+ allow(out_inst).to receive(:execution_context=).with(default_execution_context)
30
33
  allow(out_inst).to receive(:id).and_return("a-simple-plugin")
31
34
 
32
35
  allow(subject.metric_events).to receive(:increment).with(any_args)
@@ -39,7 +42,7 @@ describe LogStash::OutputDelegator do
39
42
 
40
43
  it "should push the name of the plugin to the metric" do
41
44
  expect(metric).to receive(:gauge).with(:name, out_klass.config_name)
42
- described_class.new(logger, out_klass, metric, ::LogStash::OutputDelegatorStrategyRegistry.instance, plugin_args)
45
+ described_class.new(logger, out_klass, metric, default_execution_context, ::LogStash::OutputDelegatorStrategyRegistry.instance, plugin_args)
43
46
  end
44
47
 
45
48
  context "after having received a batch of events" do
@@ -1,5 +1,7 @@
1
1
  # encoding: utf-8
2
2
  require "spec_helper"
3
+ require "logstash/outputs/base"
4
+ require "logstash/execution_context"
3
5
 
4
6
  # use a dummy NOOP output to test Outputs::Base
5
7
  class LogStash::Outputs::NOOPSingle < LogStash::Outputs::Base
@@ -77,6 +79,27 @@ describe "LogStash::Outputs::Base#new" do
77
79
  end
78
80
  end
79
81
 
82
+ context "execution context" do
83
+ let(:default_execution_context) { LogStash::ExecutionContext.new(:main) }
84
+ let(:klass) { LogStash::Outputs::NOOPSingle }
85
+
86
+ subject(:instance) { klass.new(params.dup) }
87
+
88
+ it "allow to set the context" do
89
+ expect(instance.execution_context).to be_nil
90
+ instance.execution_context = default_execution_context
91
+
92
+ expect(instance.execution_context).to eq(default_execution_context)
93
+ end
94
+
95
+ it "propagate the context to the codec" do
96
+ expect(instance.codec.execution_context).to be_nil
97
+ instance.execution_context = default_execution_context
98
+
99
+ expect(instance.codec.execution_context).to eq(default_execution_context)
100
+ end
101
+ end
102
+
80
103
  describe "dispatching multi_receive" do
81
104
  let(:event) { double("event") }
82
105
  let(:events) { [event] }
@@ -82,6 +82,13 @@ describe LogStash::Pipeline do
82
82
  let(:queue_type) { "persisted" } # "memory" "memory_acked"
83
83
  let(:times) { [] }
84
84
 
85
+ let(:pipeline_thread) do
86
+ # subject has to be called for the first time outside the thread because it will create a race condition
87
+ # with the subject.ready? call since subject is lazily initialized
88
+ s = subject
89
+ Thread.new { s.run }
90
+ end
91
+
85
92
  before :each do
86
93
  FileUtils.mkdir_p(this_queue_folder)
87
94
 
@@ -97,19 +104,22 @@ describe LogStash::Pipeline do
97
104
  pipeline_settings.each {|k, v| pipeline_settings_obj.set(k, v) }
98
105
  pipeline_settings_obj.set("queue.page_capacity", page_capacity)
99
106
  pipeline_settings_obj.set("queue.max_bytes", max_bytes)
100
- Thread.new do
101
- # make sure we have received all the generated events
102
- while counting_output.event_count < number_of_events do
103
- sleep 1
104
- end
105
- subject.shutdown
106
- end
107
107
  times.push(Time.now.to_f)
108
- subject.run
108
+
109
+ pipeline_thread
110
+ sleep(0.1) until subject.ready?
111
+
112
+ # make sure we have received all the generated events
113
+ while counting_output.event_count < number_of_events do
114
+ sleep(0.5)
115
+ end
116
+
109
117
  times.unshift(Time.now.to_f - times.first)
110
118
  end
111
119
 
112
120
  after :each do
121
+ subject.shutdown
122
+ pipeline_thread.join
113
123
  # Dir.rm_rf(this_queue_folder)
114
124
  end
115
125
 
@@ -3,6 +3,7 @@ require "spec_helper"
3
3
  require "logstash/inputs/generator"
4
4
  require "logstash/filters/multiline"
5
5
  require_relative "../support/mocks_classes"
6
+ require_relative "../logstash/pipeline_reporter_spec" # for DummyOutput class
6
7
 
7
8
  class DummyInput < LogStash::Inputs::Base
8
9
  config_name "dummyinput"
@@ -133,7 +134,7 @@ describe LogStash::Pipeline do
133
134
  CONFIG
134
135
  end
135
136
 
136
- it "should not propage cancelled events from filter to output" do
137
+ it "should not propagate cancelled events from filter to output" do
137
138
  abort_on_exception_state = Thread.abort_on_exception
138
139
  Thread.abort_on_exception = true
139
140
 
@@ -249,7 +250,6 @@ describe LogStash::Pipeline do
249
250
  }
250
251
 
251
252
  it "starts multiple filter threads" do
252
- skip("This test has been failing periodically since November 2016. Tracked as https://github.com/elastic/logstash/issues/6245")
253
253
  pipeline = TestPipeline.new(test_config_with_filters)
254
254
  pipeline.run
255
255
  expect(pipeline.worker_threads.size).to eq(worker_thread_count)
@@ -389,7 +389,7 @@ describe LogStash::Pipeline do
389
389
  allow(LogStash::Plugin).to receive(:lookup).with("output", "dummyoutput").and_return(::LogStash::Outputs::DummyOutput)
390
390
  allow(logger).to receive(:warn)
391
391
 
392
- # pipeline must be first called outside the thread context because it lazyly initialize and will create a
392
+ # pipeline must be first called outside the thread context because it lazily initialize and will create a
393
393
  # race condition if called in the thread
394
394
  p = pipeline
395
395
  t = Thread.new { p.run }
@@ -411,7 +411,7 @@ describe LogStash::Pipeline do
411
411
  end
412
412
  end
413
413
 
414
- context "compiled filter funtions" do
414
+ context "compiled filter functions" do
415
415
  context "new events should propagate down the filters" do
416
416
  config <<-CONFIG
417
417
  filter {
@@ -630,7 +630,7 @@ describe LogStash::Pipeline do
630
630
 
631
631
  it "should handle evaluating different config" do
632
632
  # When the functions are compiled from the AST it will generate instance
633
- # variables that are unique to the actual config, the intances are pointing
633
+ # variables that are unique to the actual config, the instances are pointing
634
634
  # to conditionals and/or plugins.
635
635
  #
636
636
  # Before the `defined_singleton_method`, the definition of the method was
@@ -854,4 +854,40 @@ describe LogStash::Pipeline do
854
854
  expect(pipeline1.instance_variables).to eq(pipeline2.instance_variables)
855
855
  end
856
856
  end
857
+
858
+ describe "#system?" do
859
+ after do
860
+ pipeline.close # close the queue
861
+ end
862
+
863
+ let(:pipeline) { LogStash::Pipeline.new(config_string, settings) }
864
+ let(:config_string) { "input { generator {} } output { null {} }" }
865
+
866
+ context "when the pipeline is a system pipeline" do
867
+ let(:settings) do
868
+ s = LogStash::SETTINGS.clone
869
+ s.set("pipeline.system", true)
870
+ s.set("config.string", config_string)
871
+ s
872
+ end
873
+
874
+
875
+ it "returns true" do
876
+ expect(pipeline.system?).to be_truthy
877
+ end
878
+ end
879
+
880
+ context "when the pipeline is not a system pipeline" do
881
+ let(:settings) do
882
+ s = LogStash::SETTINGS.clone
883
+ s.set("pipeline.system", false)
884
+ s.set("config.string", config_string)
885
+ s
886
+ end
887
+
888
+ it "returns true" do
889
+ expect(pipeline.system?).to be_falsey
890
+ end
891
+ end
892
+ end
857
893
  end
@@ -5,6 +5,7 @@ require "logstash/outputs/base"
5
5
  require "logstash/codecs/base"
6
6
  require "logstash/inputs/base"
7
7
  require "logstash/filters/base"
8
+ require "logstash/execution_context"
8
9
 
9
10
  describe LogStash::Plugin do
10
11
  context "reloadable" do
@@ -42,12 +43,23 @@ describe LogStash::Plugin do
42
43
  end
43
44
  end
44
45
 
45
- it "should fail lookup on inexisting type" do
46
+ context "#execution_context" do
47
+ subject { Class.new(LogStash::Plugin).new({}) }
48
+
49
+ it "can be set and get" do
50
+ expect(subject.execution_context).to be_nil
51
+ execution_context = LogStash::ExecutionContext.new(:main)
52
+ subject.execution_context = execution_context
53
+ expect(subject.execution_context).to eq(execution_context)
54
+ end
55
+ end
56
+
57
+ it "should fail lookup on nonexistent type" do
46
58
  #expect_any_instance_of(Cabin::Channel).to receive(:debug).once
47
59
  expect { LogStash::Plugin.lookup("badbadtype", "badname") }.to raise_error(LogStash::PluginLoadingError)
48
60
  end
49
61
 
50
- it "should fail lookup on inexisting name" do
62
+ it "should fail lookup on nonexistent name" do
51
63
  #expect_any_instance_of(Cabin::Channel).to receive(:debug).once
52
64
  expect { LogStash::Plugin.lookup("filter", "badname") }.to raise_error(LogStash::PluginLoadingError)
53
65
  end
@@ -217,7 +229,7 @@ describe LogStash::Plugin do
217
229
  config_name "simple_plugin"
218
230
 
219
231
  config :host, :validate => :string
220
- config :export, :validte => :boolean
232
+ config :export, :validate => :boolean
221
233
 
222
234
  def register; end
223
235
  end
@@ -35,12 +35,12 @@ describe LogStash::Plugins::HooksRegistry do
35
35
  let(:listener) { DummyListener.new }
36
36
 
37
37
  it "allow to register an emitter" do
38
- expect { subject.register_emitter(emitter.class, emitter.dispatcher) }.to change { subject.emmitters_count }.by(1)
38
+ expect { subject.register_emitter(emitter.class, emitter.dispatcher) }.to change { subject.emitters_count }.by(1)
39
39
  end
40
40
 
41
41
  it "allow to remove an emitter" do
42
42
  subject.register_emitter(emitter.class, emitter.dispatcher)
43
- expect { subject.remove_emitter(emitter.class)}.to change { subject.emmitters_count }.by(-1)
43
+ expect { subject.remove_emitter(emitter.class)}.to change { subject.emitters_count }.by(-1)
44
44
  end
45
45
 
46
46
  it "allow to register hooks to emitters" do
@@ -141,7 +141,7 @@ describe LogStash::Runner do
141
141
 
142
142
  context "with a good configuration" do
143
143
  let(:pipeline_string) { "input { } filter { } output { }" }
144
- it "should exit successfuly" do
144
+ it "should exit successfully" do
145
145
  expect(subject.run(args)).to eq(0)
146
146
  end
147
147
  end
@@ -165,7 +165,38 @@ describe LogStash::Runner do
165
165
  allow(pipeline).to receive(:run).and_return(task)
166
166
  allow(pipeline).to receive(:shutdown)
167
167
  end
168
-
168
+
169
+ context "when :path.data is defined by the user" do
170
+ let(:test_data_path) { "/tmp/ls-test-data" }
171
+ let(:test_queue_path) { test_data_path + "/" + "queue" }
172
+
173
+ it "should set data paths" do
174
+ expect(LogStash::Agent).to receive(:new) do |settings|
175
+ expect(settings.get("path.data")).to eq(test_data_path)
176
+ expect(settings.get("path.queue")).to eq(test_queue_path)
177
+ end
178
+
179
+ args = ["--path.data", test_data_path, "-e", pipeline_string]
180
+ subject.run("bin/logstash", args)
181
+ end
182
+
183
+ context "and path.queue is manually set" do
184
+ let(:queue_override_path) { "/tmp/queue-override_path" }
185
+
186
+ it "should set data paths" do
187
+ expect(LogStash::Agent).to receive(:new) do |settings|
188
+ expect(settings.get("path.data")).to eq(test_data_path)
189
+ expect(settings.get("path.queue")).to eq(queue_override_path)
190
+ end
191
+
192
+ LogStash::SETTINGS.set("path.queue", queue_override_path)
193
+
194
+ args = ["--path.data", test_data_path, "-e", pipeline_string]
195
+ subject.run("bin/logstash", args)
196
+ end
197
+ end
198
+ end
199
+
169
200
  context "when :http.host is defined by the user" do
170
201
  it "should pass the value to the webserver" do
171
202
  expect(LogStash::Agent).to receive(:new) do |settings|