logstash-core 6.6.0-java → 6.6.1-java

Sign up to get free protection for your applications and to get access to all the features.
@@ -118,7 +118,7 @@ describe LogStash::Agent do
118
118
  context "if state is clean" do
119
119
  before :each do
120
120
  allow(subject).to receive(:running_user_defined_pipelines?).and_return(true)
121
- allow(subject).to receive(:clean_state?).and_return(false)
121
+ allow(subject).to receive(:no_pipeline?).and_return(false)
122
122
  end
123
123
 
124
124
  it "should not converge state more than once" do
@@ -141,7 +141,7 @@ describe LogStash::Agent do
141
141
  it "does not upgrade the new config" do
142
142
  t = Thread.new { subject.execute }
143
143
  wait(timeout)
144
- .for { subject.running_pipelines? && subject.pipelines.values.first.ready? }
144
+ .for { subject.running_pipelines? && subject.running_pipelines.values.first.ready? }
145
145
  .to eq(true)
146
146
  expect(subject.converge_state_and_update).not_to be_a_successful_converge
147
147
  expect(subject).to have_running_pipeline?(mock_config_pipeline)
@@ -161,7 +161,7 @@ describe LogStash::Agent do
161
161
  it "does upgrade the new config" do
162
162
  t = Thread.new { subject.execute }
163
163
  Timeout.timeout(timeout) do
164
- sleep(0.1) until subject.pipelines_count > 0 && subject.pipelines.values.first.ready?
164
+ sleep(0.1) until subject.running_pipelines_count > 0 && subject.running_pipelines.values.first.ready?
165
165
  end
166
166
 
167
167
  expect(subject.converge_state_and_update).to be_a_successful_converge
@@ -185,7 +185,7 @@ describe LogStash::Agent do
185
185
  it "does not try to reload the pipeline" do
186
186
  t = Thread.new { subject.execute }
187
187
  Timeout.timeout(timeout) do
188
- sleep(0.1) until subject.running_pipelines? && subject.pipelines.values.first.running?
188
+ sleep(0.1) until subject.running_pipelines? && subject.running_pipelines.values.first.running?
189
189
  end
190
190
  expect(subject.converge_state_and_update).not_to be_a_successful_converge
191
191
  expect(subject).to have_running_pipeline?(mock_config_pipeline)
@@ -205,7 +205,7 @@ describe LogStash::Agent do
205
205
  it "tries to reload the pipeline" do
206
206
  t = Thread.new { subject.execute }
207
207
  Timeout.timeout(timeout) do
208
- sleep(0.1) until subject.running_pipelines? && subject.pipelines.values.first.running?
208
+ sleep(0.1) until subject.running_pipelines? && subject.running_pipelines.values.first.running?
209
209
  end
210
210
 
211
211
  expect(subject.converge_state_and_update).to be_a_successful_converge
@@ -2,13 +2,14 @@
2
2
  require "spec_helper"
3
3
  require_relative "../../support/helpers"
4
4
  require_relative "../../support/matchers"
5
+ require "logstash/pipelines_registry"
5
6
  require "logstash/pipeline_action/create"
6
7
  require "logstash/inputs/generator"
7
8
 
8
9
  describe LogStash::PipelineAction::Create do
9
10
  let(:metric) { LogStash::Instrument::NullMetric.new(LogStash::Instrument::Collector.new) }
10
- let(:pipeline_config) { mock_pipeline_config(:main, "input { generator { id => '123' } } output { null {} }") }
11
- let(:pipelines) { java.util.concurrent.ConcurrentHashMap.new }
11
+ let(:pipeline_config) { mock_pipeline_config(:main, "input { dummyblockinginput { id => '123' } } output { null {} }") }
12
+ let(:pipelines) { LogStash::PipelinesRegistry.new }
12
13
  let(:agent) { double("agent") }
13
14
 
14
15
  before do
@@ -18,7 +19,7 @@ describe LogStash::PipelineAction::Create do
18
19
  subject { described_class.new(pipeline_config, metric) }
19
20
 
20
21
  after do
21
- pipelines.each do |_, pipeline|
22
+ pipelines.running_pipelines do |_, pipeline|
22
23
  pipeline.shutdown
23
24
  pipeline.thread.join
24
25
  end
@@ -47,7 +48,7 @@ describe LogStash::PipelineAction::Create do
47
48
  it "starts the pipeline" do
48
49
  allow(agent).to receive(:exclusive) { |&arg| arg.call }
49
50
  subject.execute(agent, pipelines)
50
- expect(pipelines[:main].running?).to be_truthy
51
+ expect(pipelines.get_pipeline(:main).running?).to be_truthy
51
52
  end
52
53
 
53
54
  it "returns a successful execution status" do
@@ -58,7 +59,7 @@ describe LogStash::PipelineAction::Create do
58
59
 
59
60
  context "when the pipeline doesn't start" do
60
61
  context "with a syntax error" do
61
- let(:pipeline_config) { mock_pipeline_config(:main, "input { generator { id => '123' } } output { stdout ") } # bad syntax
62
+ let(:pipeline_config) { mock_pipeline_config(:main, "input { dummyblockinginput { id => '123' } } output { stdout ") } # bad syntax
62
63
 
63
64
  it "raises the exception upstream" do
64
65
  expect { subject.execute(agent, pipelines) }.to raise_error
@@ -66,7 +67,7 @@ describe LogStash::PipelineAction::Create do
66
67
  end
67
68
 
68
69
  context "with an error raised during `#register`" do
69
- let(:pipeline_config) { mock_pipeline_config(:main, "input { generator { id => '123' } } filter { ruby { init => '1/0' code => '1+2' } } output { null {} }") }
70
+ let(:pipeline_config) { mock_pipeline_config(:main, "input { dummyblockinginput { id => '123' } } filter { ruby { init => '1/0' code => '1+2' } } output { null {} }") }
70
71
 
71
72
  it "returns false" do
72
73
  allow(agent).to receive(:exclusive) { |&arg| arg.call }
@@ -76,8 +77,8 @@ describe LogStash::PipelineAction::Create do
76
77
  end
77
78
 
78
79
  context "when sorting create action" do
79
- let(:pipeline_config) { mock_pipeline_config(:main, "input { generator { id => '123' } } output { null {} }") }
80
- let(:system_pipeline_config) { mock_pipeline_config(:main_2, "input { generator { id => '123' } } output { null {} }", { "pipeline.system" => true }) }
80
+ let(:pipeline_config) { mock_pipeline_config(:main, "input { dummyblockinginput { id => '123' } } output { null {} }") }
81
+ let(:system_pipeline_config) { mock_pipeline_config(:main_2, "input { dummyblockinginput { id => '123' } } output { null {} }", { "pipeline.system" => true }) }
81
82
 
82
83
  it "should give higher priority to system pipeline" do
83
84
  action_user_pipeline = described_class.new(pipeline_config, metric)
@@ -2,15 +2,16 @@
2
2
  require "spec_helper"
3
3
  require_relative "../../support/helpers"
4
4
  require_relative "../../support/matchers"
5
+ require "logstash/pipelines_registry"
5
6
  require "logstash/pipeline_action/reload"
6
7
 
7
8
  describe LogStash::PipelineAction::Reload do
8
9
  let(:metric) { LogStash::Instrument::NullMetric.new(LogStash::Instrument::Collector.new) }
9
10
  let(:pipeline_id) { :main }
10
- let(:new_pipeline_config) { mock_pipeline_config(pipeline_id, "input { generator { id => 'new' } } output { null {} }", { "pipeline.reloadable" => true}) }
11
- let(:pipeline_config) { "input { generator {} } output { null {} }" }
11
+ let(:new_pipeline_config) { mock_pipeline_config(pipeline_id, "input { dummyblockinginput { id => 'new' } } output { null {} }", { "pipeline.reloadable" => true}) }
12
+ let(:pipeline_config) { "input { dummyblockinginput {} } output { null {} }" }
12
13
  let(:pipeline) { mock_pipeline_from_string(pipeline_config, mock_settings("pipeline.reloadable" => true)) }
13
- let(:pipelines) { chm = java.util.concurrent.ConcurrentHashMap.new; chm[pipeline_id] = pipeline; chm }
14
+ let(:pipelines) { r = LogStash::PipelinesRegistry.new; r.create_pipeline(pipeline_id, pipeline) { true }; r }
14
15
  let(:agent) { double("agent") }
15
16
 
16
17
  subject { described_class.new(new_pipeline_config, metric) }
@@ -21,7 +22,7 @@ describe LogStash::PipelineAction::Reload do
21
22
  end
22
23
 
23
24
  after do
24
- pipelines.each do |_, pipeline|
25
+ pipelines.running_pipelines do |_, pipeline|
25
26
  pipeline.shutdown
26
27
  pipeline.thread.join
27
28
  end
@@ -40,13 +41,13 @@ describe LogStash::PipelineAction::Reload do
40
41
  it "start the new pipeline" do
41
42
  allow(agent).to receive(:exclusive) { |&arg| arg.call }
42
43
  subject.execute(agent, pipelines)
43
- expect(pipelines[pipeline_id].running?).to be_truthy
44
+ expect(pipelines.get_pipeline(pipeline_id).running?).to be_truthy
44
45
  end
45
46
 
46
47
  it "run the new pipeline code" do
47
48
  allow(agent).to receive(:exclusive) { |&arg| arg.call }
48
49
  subject.execute(agent, pipelines)
49
- expect(pipelines[pipeline_id].config_hash).to eq(new_pipeline_config.config_hash)
50
+ expect(pipelines.get_pipeline(pipeline_id).config_hash).to eq(new_pipeline_config.config_hash)
50
51
  end
51
52
  end
52
53
 
@@ -61,7 +62,7 @@ describe LogStash::PipelineAction::Reload do
61
62
  end
62
63
 
63
64
  context "when the new pipeline is not reloadable" do
64
- let(:new_pipeline_config) { mock_pipeline_config(pipeline_id, "input { generator { id => 'new' } } output { null {} }", { "pipeline.reloadable" => false}) }
65
+ let(:new_pipeline_config) { mock_pipeline_config(pipeline_id, "input { dummyblockinginput { id => 'new' } } output { null {} }", { "pipeline.reloadable" => false}) }
65
66
 
66
67
  it "cannot successfully execute the action" do
67
68
  allow(agent).to receive(:exclusive) { |&arg| arg.call }
@@ -70,7 +71,7 @@ describe LogStash::PipelineAction::Reload do
70
71
  end
71
72
 
72
73
  context "when the new pipeline has syntax errors" do
73
- let(:new_pipeline_config) { mock_pipeline_config(pipeline_id, "input generator { id => 'new' } } output { null {} }", { "pipeline.reloadable" => false}) }
74
+ let(:new_pipeline_config) { mock_pipeline_config(pipeline_id, "input dummyblockinginput { id => 'new' } } output { null {} }", { "pipeline.reloadable" => false}) }
74
75
 
75
76
  it "cannot successfully execute the action" do
76
77
  allow(agent).to receive(:exclusive) { |&arg| arg.call }
@@ -80,7 +81,7 @@ describe LogStash::PipelineAction::Reload do
80
81
 
81
82
  context "when there is an error in the register" do
82
83
  before do
83
- allow_any_instance_of(LogStash::Inputs::Generator).to receive(:register).and_raise("Bad value")
84
+ allow_any_instance_of(LogStash::Inputs::DummyBlockingInput).to receive(:register).and_raise("Bad value")
84
85
  end
85
86
 
86
87
  it "cannot successfully execute the action" do
@@ -1,14 +1,15 @@
1
1
  # encoding: utf-8
2
2
  require "spec_helper"
3
3
  require_relative "../../support/helpers"
4
+ require "logstash/pipelines_registry"
4
5
  require "logstash/pipeline_action/stop"
5
6
  require "logstash/pipeline"
6
7
 
7
8
  describe LogStash::PipelineAction::Stop do
8
- let(:pipeline_config) { "input { generator {} } output { null {} }" }
9
+ let(:pipeline_config) { "input { dummyblockinginput {} } output { null {} }" }
9
10
  let(:pipeline_id) { :main }
10
11
  let(:pipeline) { mock_pipeline_from_string(pipeline_config) }
11
- let(:pipelines) { chm = java.util.concurrent.ConcurrentHashMap.new; chm[:main] = pipeline; chm }
12
+ let(:pipelines) { chm = LogStash::PipelinesRegistry.new; chm.create_pipeline(pipeline_id, pipeline) { true }; chm }
12
13
  let(:agent) { double("agent") }
13
14
 
14
15
  subject { described_class.new(pipeline_id) }
@@ -31,6 +32,6 @@ describe LogStash::PipelineAction::Stop do
31
32
  end
32
33
 
33
34
  it "removes the pipeline from the running pipelines" do
34
- expect { subject.execute(agent, pipelines) }.to change { pipelines.include?(pipeline_id) }.from(true).to(false)
35
+ expect { subject.execute(agent, pipelines) }.to change { pipelines.running_pipelines.keys }.from([:main]).to([])
35
36
  end
36
37
  end
@@ -0,0 +1,220 @@
1
+ # encoding: utf-8
2
+ require "spec_helper"
3
+ require "logstash/pipelines_registry"
4
+
5
+ describe LogStash::PipelinesRegistry do
6
+
7
+ let(:pipeline_id) { "test" }
8
+ let(:pipeline) { double("Pipeline") }
9
+ let (:logger) { double("Logger") }
10
+
11
+ context "at object creation" do
12
+ it "should be empty" do
13
+ expect(subject.size).to eq(0)
14
+ expect(subject.empty?).to be_truthy
15
+ expect(subject.running_pipelines).to be_empty
16
+ expect(subject.non_running_pipelines).to be_empty
17
+ expect(subject.running_user_defined_pipelines).to be_empty
18
+ end
19
+ end
20
+
21
+ context "creating a pipeline" do
22
+ context "without existing same pipeline id" do
23
+ it "registry should not have a state for pipeline_id" do
24
+ expect(subject.get_pipeline(pipeline_id)).to be_nil
25
+ end
26
+
27
+ it "should return block return value" do
28
+ expect(subject.create_pipeline(pipeline_id, pipeline) { "dummy" }).to eq("dummy")
29
+ end
30
+
31
+ it "should register the new pipeline upon successful create block" do
32
+ subject.create_pipeline(pipeline_id, pipeline) { true }
33
+ expect(subject.get_pipeline(pipeline_id)).to eq(pipeline)
34
+ end
35
+
36
+ it "should not register the new pipeline upon unsuccessful create block" do
37
+ subject.create_pipeline(pipeline_id, pipeline) { false }
38
+ expect(subject.get_pipeline(pipeline_id)).to be_nil
39
+ end
40
+ end
41
+
42
+ context "with existing pipeline id" do
43
+ before :each do
44
+ subject.create_pipeline(pipeline_id, pipeline) { true }
45
+ end
46
+
47
+ it "registry should have a state for pipeline_id" do
48
+ expect(subject.get_pipeline(pipeline_id)).to eq(pipeline)
49
+ end
50
+
51
+ context "when existing pipeline is not terminated" do
52
+ before :each do
53
+ expect(pipeline).to receive(:finished_execution?).and_return(false)
54
+ end
55
+
56
+ it "should return false" do
57
+ expect(subject.create_pipeline(pipeline_id, pipeline) { "dummy" }).to be_falsey
58
+ end
59
+
60
+ it "should not call block and log error if pipeline is not terminated" do
61
+ expect(LogStash::PipelinesRegistry).to receive(:logger).and_return(logger)
62
+ expect(logger).to receive(:error)
63
+ expect { |b| subject.create_pipeline(pipeline_id, pipeline, &b) }.not_to yield_control
64
+ end
65
+ end
66
+
67
+ context "when existing pipeline is terminated" do
68
+ let (:new_pipeline) { double("New Pipeline") }
69
+
70
+ before :each do
71
+ expect(pipeline).to receive(:finished_execution?).and_return(true)
72
+ end
73
+
74
+ it "should return block value" do
75
+ expect(subject.create_pipeline(pipeline_id, new_pipeline) { "dummy" }).to eq("dummy")
76
+ end
77
+
78
+ it "should return block value" do
79
+ expect(subject.create_pipeline(pipeline_id, new_pipeline) { "dummy" }).to eq("dummy")
80
+ end
81
+
82
+ it "should register new pipeline" do
83
+ subject.create_pipeline(pipeline_id, new_pipeline) { true }
84
+ expect(subject.get_pipeline(pipeline_id)).to eq(new_pipeline)
85
+ end
86
+ end
87
+ end
88
+ end
89
+
90
+ context "terminating a pipeline" do
91
+ context "without existing pipeline id" do
92
+ it "should log error" do
93
+ expect(LogStash::PipelinesRegistry).to receive(:logger).and_return(logger)
94
+ expect(logger).to receive(:error)
95
+ subject.terminate_pipeline(pipeline_id) { "dummy" }
96
+ end
97
+
98
+ it "should not yield to block" do
99
+ expect { |b| subject.terminate_pipeline(pipeline_id, &b) }.not_to yield_control
100
+ end
101
+ end
102
+
103
+ context "with existing pipeline id" do
104
+ before :each do
105
+ subject.create_pipeline(pipeline_id, pipeline) { true }
106
+ end
107
+
108
+ it "should yield to block" do
109
+ expect { |b| subject.terminate_pipeline(pipeline_id, &b) }.to yield_control
110
+ end
111
+
112
+ it "should keep pipeline id" do
113
+ subject.terminate_pipeline(pipeline_id) { "dummy" }
114
+ expect(subject.get_pipeline(pipeline_id)).to eq(pipeline)
115
+ end
116
+ end
117
+ end
118
+
119
+ context "reloading a pipeline" do
120
+ it "should log error with inexistent pipeline id" do
121
+ expect(LogStash::PipelinesRegistry).to receive(:logger).and_return(logger)
122
+ expect(logger).to receive(:error)
123
+ subject.reload_pipeline(pipeline_id) { }
124
+ end
125
+
126
+ context "with existing pipeline id" do
127
+ before :each do
128
+ subject.create_pipeline(pipeline_id, pipeline) { true }
129
+ end
130
+
131
+ it "should return block value" do
132
+ expect(subject.reload_pipeline(pipeline_id) { ["dummy", pipeline] }).to eq("dummy")
133
+ end
134
+
135
+ it "should not be terminated while reloading" do
136
+ expect(pipeline).to receive(:finished_execution?).and_return(false, true, true)
137
+
138
+ # 1st call: finished_execution? is false
139
+ expect(subject.running_pipelines).not_to be_empty
140
+
141
+ # 2nd call: finished_execution? is true
142
+ expect(subject.running_pipelines).to be_empty
143
+
144
+
145
+ queue = Queue.new # threadsafe queue
146
+ in_block = Concurrent::AtomicBoolean.new(false)
147
+
148
+ thread = Thread.new(subject, pipeline_id, pipeline, queue, in_block) do |subject, pipeline_id, pipeline, queue, in_block|
149
+ subject.reload_pipeline(pipeline_id) do
150
+ in_block.make_true
151
+ queue.pop
152
+ [true, pipeline]
153
+ end
154
+ end
155
+
156
+ # make sure we entered the block executioin
157
+ wait(10).for {in_block.true?}.to be_truthy
158
+
159
+ # at this point the thread is suspended waiting on queue
160
+
161
+ # since in reloading state, running_pipelines is not empty
162
+ expect(subject.running_pipelines).not_to be_empty
163
+
164
+ # unblock thread
165
+ queue.push(:dummy)
166
+ thread.join
167
+
168
+ # 3rd call: finished_execution? is true
169
+ expect(subject.running_pipelines).to be_empty
170
+ end
171
+ end
172
+ end
173
+
174
+ context "pipelines collections" do
175
+ context "with a non terminated pipelines" do
176
+ before :each do
177
+ subject.create_pipeline(pipeline_id, pipeline) { true }
178
+ expect(pipeline).to receive(:finished_execution?).and_return(false)
179
+ end
180
+
181
+ it "should find running pipelines" do
182
+ expect(subject.running_pipelines).not_to be_empty
183
+ end
184
+
185
+ it "should not find non_running pipelines" do
186
+ expect(subject.non_running_pipelines).to be_empty
187
+ end
188
+
189
+ it "should find running_user_defined_pipelines" do
190
+ expect(pipeline).to receive(:system?).and_return(false)
191
+ expect(subject.running_user_defined_pipelines).not_to be_empty
192
+ end
193
+
194
+ it "should not find running_user_defined_pipelines" do
195
+ expect(pipeline).to receive(:system?).and_return(true)
196
+ expect(subject.running_user_defined_pipelines).to be_empty
197
+ end
198
+ end
199
+
200
+ context "with a terminated pipelines" do
201
+ before :each do
202
+ subject.create_pipeline(pipeline_id, pipeline) { true }
203
+ expect(pipeline).to receive(:finished_execution?).and_return(true)
204
+ end
205
+
206
+ it "should not find running pipelines" do
207
+ expect(subject.running_pipelines).to be_empty
208
+ end
209
+
210
+ it "should find non_running pipelines" do
211
+ expect(subject.non_running_pipelines).not_to be_empty
212
+ end
213
+
214
+ it "should not find running_user_defined_pipelines" do
215
+ expect(subject.running_user_defined_pipelines).to be_empty
216
+ end
217
+ end
218
+
219
+ end
220
+ end
@@ -22,6 +22,8 @@ describe LogStash::Runner do
22
22
  before :each do
23
23
  clear_data_dir
24
24
 
25
+ WebMock.disable_net_connect!(allow_localhost: true)
26
+
25
27
  allow(LogStash::Runner).to receive(:logger).and_return(logger)
26
28
  allow(logger).to receive(:debug?).and_return(true)
27
29
  allow(logger).to receive(:subscribe).with(any_args)
@@ -18,17 +18,17 @@ describe LogStash::StateResolver do
18
18
 
19
19
  after do
20
20
  # ensure that the the created pipeline are closed
21
- running_pipelines.each { |_, pipeline| pipeline.close }
21
+ pipelines.running_pipelines.each { |_, pipeline| pipeline.close }
22
22
  end
23
23
 
24
24
  context "when no pipeline is running" do
25
- let(:running_pipelines) { {} }
25
+ let(:pipelines) { LogStash::PipelinesRegistry.new }
26
26
 
27
27
  context "no pipeline configs is received" do
28
28
  let(:pipeline_configs) { [] }
29
29
 
30
30
  it "returns no action" do
31
- expect(subject.resolve(running_pipelines, pipeline_configs).size).to eq(0)
31
+ expect(subject.resolve(pipelines, pipeline_configs).size).to eq(0)
32
32
  end
33
33
  end
34
34
 
@@ -36,7 +36,7 @@ describe LogStash::StateResolver do
36
36
  let(:pipeline_configs) { [mock_pipeline_config(:hello_world)] }
37
37
 
38
38
  it "returns some actions" do
39
- expect(subject.resolve(running_pipelines, pipeline_configs)).to have_actions(
39
+ expect(subject.resolve(pipelines, pipeline_configs)).to have_actions(
40
40
  [:create, :hello_world],
41
41
  )
42
42
  end
@@ -47,13 +47,17 @@ describe LogStash::StateResolver do
47
47
  context "when a pipeline is running" do
48
48
  let(:main_pipeline) { mock_pipeline(:main) }
49
49
  let(:main_pipeline_config) { main_pipeline.pipeline_config }
50
- let(:running_pipelines) { { :main => main_pipeline } }
50
+ let(:pipelines) do
51
+ r = LogStash::PipelinesRegistry.new
52
+ r.create_pipeline(:main, main_pipeline) { true }
53
+ r
54
+ end
51
55
 
52
56
  context "when the pipeline config contains a new one and the existing" do
53
57
  let(:pipeline_configs) { [mock_pipeline_config(:hello_world), main_pipeline_config ] }
54
58
 
55
59
  it "creates the new one and keep the other one" do
56
- expect(subject.resolve(running_pipelines, pipeline_configs)).to have_actions(
60
+ expect(subject.resolve(pipelines, pipeline_configs)).to have_actions(
57
61
  [:create, :hello_world],
58
62
  )
59
63
  end
@@ -62,7 +66,7 @@ describe LogStash::StateResolver do
62
66
  let(:pipeline_configs) { [mock_pipeline_config(:hello_world)] }
63
67
 
64
68
  it "creates the new one and stop the old one one" do
65
- expect(subject.resolve(running_pipelines, pipeline_configs)).to have_actions(
69
+ expect(subject.resolve(pipelines, pipeline_configs)).to have_actions(
66
70
  [:create, :hello_world],
67
71
  [:stop, :main]
68
72
  )
@@ -73,7 +77,7 @@ describe LogStash::StateResolver do
73
77
  let(:pipeline_configs) { [] }
74
78
 
75
79
  it "stops the old one one" do
76
- expect(subject.resolve(running_pipelines, pipeline_configs)).to have_actions(
80
+ expect(subject.resolve(pipelines, pipeline_configs)).to have_actions(
77
81
  [:stop, :main]
78
82
  )
79
83
  end
@@ -83,7 +87,7 @@ describe LogStash::StateResolver do
83
87
  let(:pipeline_configs) { [mock_pipeline_config(:main, "input { generator {}}")] }
84
88
 
85
89
  it "reloads the old one one" do
86
- expect(subject.resolve(running_pipelines, pipeline_configs)).to have_actions(
90
+ expect(subject.resolve(pipelines, pipeline_configs)).to have_actions(
87
91
  [:reload, :main]
88
92
  )
89
93
  end
@@ -92,21 +96,21 @@ describe LogStash::StateResolver do
92
96
  end
93
97
 
94
98
  context "when we have a lot of pipeline running" do
95
- let(:running_pipelines) do
96
- {
97
- :main1 => mock_pipeline(:main1),
98
- :main2 => mock_pipeline(:main2),
99
- :main3 => mock_pipeline(:main3),
100
- :main4 => mock_pipeline(:main4),
101
- :main5 => mock_pipeline(:main5),
102
- :main6 => mock_pipeline(:main6),
103
- }
99
+ let(:pipelines) do
100
+ r = LogStash::PipelinesRegistry.new
101
+ r.create_pipeline(:main1, mock_pipeline(:main1)) { true }
102
+ r.create_pipeline(:main2, mock_pipeline(:main2)) { true }
103
+ r.create_pipeline(:main3, mock_pipeline(:main3)) { true }
104
+ r.create_pipeline(:main4, mock_pipeline(:main4)) { true }
105
+ r.create_pipeline(:main5, mock_pipeline(:main5)) { true }
106
+ r.create_pipeline(:main6, mock_pipeline(:main6)) { true }
107
+ r
104
108
  end
105
109
 
106
110
  context "without system pipeline" do
107
111
  let(:pipeline_configs) do
108
112
  [
109
- running_pipelines[:main1].pipeline_config,
113
+ pipelines.get_pipeline(:main1).pipeline_config,
110
114
  mock_pipeline_config(:main9),
111
115
  mock_pipeline_config(:main5, "input { generator {}}"),
112
116
  mock_pipeline_config(:main3, "input { generator {}}"),
@@ -115,7 +119,7 @@ describe LogStash::StateResolver do
115
119
  end
116
120
 
117
121
  it "generates actions required to converge" do
118
- expect(subject.resolve(running_pipelines, pipeline_configs)).to have_actions(
122
+ expect(subject.resolve(pipelines, pipeline_configs)).to have_actions(
119
123
  [:create, :main7],
120
124
  [:create, :main9],
121
125
  [:reload, :main3],
@@ -130,7 +134,7 @@ describe LogStash::StateResolver do
130
134
  context "with system pipeline" do
131
135
  let(:pipeline_configs) do
132
136
  [
133
- running_pipelines[:main1].pipeline_config,
137
+ pipelines.get_pipeline(:main1).pipeline_config,
134
138
  mock_pipeline_config(:main9),
135
139
  mock_pipeline_config(:main5, "input { generator {}}"),
136
140
  mock_pipeline_config(:main3, "input { generator {}}"),
@@ -140,7 +144,7 @@ describe LogStash::StateResolver do
140
144
  end
141
145
 
142
146
  it "creates the system pipeline before user defined pipelines" do
143
- expect(subject.resolve(running_pipelines, pipeline_configs)).to have_actions(
147
+ expect(subject.resolve(pipelines, pipeline_configs)).to have_actions(
144
148
  [:create, :monitoring],
145
149
  [:create, :main7],
146
150
  [:create, :main9],