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.
@@ -32,5 +32,45 @@ module LogStash module Util
32
32
  end
33
33
  end
34
34
  end
35
+
36
+ describe "#initialize" do
37
+ context 'when host is required' do
38
+ MALFORMED_URIS = ['http:/user:pass@localhost:9600', 'http:/localhost', 'http:/localhost:9600', 'h;localhost', 'http:://localhost']
39
+
40
+ context 'malformed uris via string' do
41
+ MALFORMED_URIS.each do |arg|
42
+ it "#{arg}: should raise an error" do
43
+ expect{LogStash::Util::SafeURI.new(arg)}.to raise_error(ArgumentError)
44
+ end
45
+ end
46
+ end
47
+
48
+ context 'malformed uris via java.net.URI' do
49
+ MALFORMED_URIS.each do |arg|
50
+ it "#{arg}: should raise an error" do
51
+ java_uri = java.net.URI.new(arg)
52
+ expect{LogStash::Util::SafeURI.new(java_uri)}.to raise_error(ArgumentError)
53
+ end
54
+ end
55
+ end
56
+
57
+ context 'malformed uris via Ruby URI' do
58
+ MALFORMED_URIS.each do |arg|
59
+ it "#{arg}: should raise an error" do
60
+ ruby_uri = URI.parse(arg)
61
+ expect{LogStash::Util::SafeURI.new(ruby_uri)}.to raise_error(ArgumentError)
62
+ end
63
+ end
64
+ end
65
+
66
+ context 'uris with a valid host' do
67
+ ['http://user:pass@notlocalhost:9600', 'http://notlocalhost', 'https://notlocalhost:9600', '//notlocalhost', 'notlocalhost', 'notlocalhost:9200'].each do |arg|
68
+ it "#{arg}: should resolve host correctly" do
69
+ expect(LogStash::Util::SafeURI.new(arg).host).to eq('notlocalhost')
70
+ end
71
+ end
72
+ end
73
+ end
74
+ end
35
75
  end
36
76
  end end
@@ -51,44 +51,50 @@ end
51
51
 
52
52
  RSpec::Matchers.define :have_pipeline? do |pipeline_config|
53
53
  match do |agent|
54
- pipeline = agent.get_pipeline(pipeline_config.pipeline_id)
55
- expect(pipeline).to_not be_nil
54
+ pipeline = nil
55
+ try(30) do
56
+ pipeline = agent.get_pipeline(pipeline_config.pipeline_id)
57
+ expect(pipeline).to_not be_nil
58
+ end
56
59
  expect(pipeline.config_str).to eq(pipeline_config.config_string)
60
+ expect(agent.running_pipelines.keys.map(&:to_s)).to include(pipeline_config.pipeline_id.to_s)
57
61
  end
58
62
 
59
63
  match_when_negated do |agent|
60
- pipeline = agent.get_pipeline(pipeline_config.pipeline_id)
61
- pipeline.nil? || pipeline.config_str != pipeline_config.config_string
64
+ pipeline = nil
65
+ try(30) do
66
+ pipeline = agent.get_pipeline(pipeline_config.pipeline_id)
67
+ expect(pipeline).to_not be_nil
68
+ end
69
+ # either the pipeline_id is not in the running pipelines OR it is but have different configurations
70
+ expect(!agent.running_pipelines.keys.map(&:to_s).include?(pipeline_config.pipeline_id.to_s) || pipeline.config_str != pipeline_config.config_string).to be_truthy
62
71
  end
63
72
  end
64
73
 
65
74
  RSpec::Matchers.define :have_running_pipeline? do |pipeline_config|
66
75
  match do |agent|
67
- Stud.try(10.times, [StandardError, RSpec::Expectations::ExpectationNotMetError]) do
76
+ pipeline = nil
77
+ try(30) do
68
78
  pipeline = agent.get_pipeline(pipeline_config.pipeline_id)
69
79
  expect(pipeline).to_not be_nil
70
- expect(pipeline.config_str).to eq(pipeline_config.config_string)
71
- expect(pipeline.running?).to be_truthy
72
80
  end
81
+ expect(pipeline.config_str).to eq(pipeline_config.config_string)
82
+ expect(pipeline.running?).to be_truthy
83
+ expect(agent.running_pipelines.keys.map(&:to_s)).to include(pipeline_config.pipeline_id.to_s)
73
84
  end
74
85
 
75
86
  failure_message do |agent|
76
87
  pipeline = agent.get_pipeline(pipeline_config.pipeline_id)
77
88
 
78
89
  if pipeline.nil?
79
- "Expected pipeline to exist and running, be we cannot find `#{pipeline_config.pipeline_id}` in the running pipelines `#{agent.pipelines.keys.join(",")}`"
80
- else
81
- if pipeline.running? == false
82
- "Found `#{pipeline_config.pipeline_id}` in the list of pipelines but its not running"
83
- elsif pipeline.config_str != pipeline_config.config_string
84
- "Found `#{pipeline_config.pipeline_id}` in the list of pipelines and running, but the config_string doesn't match,
85
- Expected:
86
- #{pipeline_config.config_string}
87
-
88
- got:
89
- #{pipeline.config_str}"
90
- end
90
+ "Expected pipeline to exist and running, be we cannot find '#{pipeline_config.pipeline_id.to_s}' in the running pipelines '#{agent.running_pipelines.keys.join(",")}'"
91
+ else
92
+ if !pipeline.running?
93
+ "Found '#{pipeline_config.pipeline_id.to_s}' in the list of pipelines but its not running"
94
+ elsif pipeline.config_str != pipeline_config.config_string
95
+ "Found '#{pipeline_config.pipeline_id.to_s}' in the list of pipelines and running, but the config_string doesn't match,\nExpected:\n#{pipeline_config.config_string}\n\ngot:\n#{pipeline.config_str}"
91
96
  end
97
+ end
92
98
  end
93
99
 
94
100
  match_when_negated do
@@ -26,12 +26,12 @@ shared_context "api setup" do
26
26
  @agent.execute
27
27
  pipeline_config = mock_pipeline_config(:main, "input { generator { id => '123' } } output { null {} }")
28
28
  pipeline_creator = LogStash::PipelineAction::Create.new(pipeline_config, @agent.metric)
29
- @pipelines = java.util.concurrent.ConcurrentHashMap.new
30
- expect(pipeline_creator.execute(@agent, @pipelines)).to be_truthy
29
+ @pipelines_registry = LogStash::PipelinesRegistry.new
30
+ expect(pipeline_creator.execute(@agent, @pipelines_registry)).to be_truthy
31
31
  end
32
32
 
33
33
  after :all do
34
- @pipelines.each do |_, pipeline|
34
+ @pipelines_registry.running_pipelines.each do |_, pipeline|
35
35
  pipeline.shutdown
36
36
  pipeline.thread.join
37
37
  end
@@ -1,6 +1,6 @@
1
1
  ---
2
- logstash: 6.6.0
3
- logstash-core: 6.6.0
2
+ logstash: 6.6.1
3
+ logstash-core: 6.6.1
4
4
  logstash-core-plugin-api: 2.1.16
5
5
 
6
6
  # jruby must reference a *released* version of jruby which can be downloaded from the official download url
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: logstash-core
3
3
  version: !ruby/object:Gem::Version
4
- version: 6.6.0
4
+ version: 6.6.1
5
5
  platform: java
6
6
  authors:
7
7
  - Elastic
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-01-24 00:00:00.000000000 Z
11
+ date: 2019-02-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  requirement: !ruby/object:Gem::Requirement
@@ -429,6 +429,7 @@ files:
429
429
  - lib/logstash/pipeline_action/stop.rb
430
430
  - lib/logstash/pipeline_reporter.rb
431
431
  - lib/logstash/pipeline_settings.rb
432
+ - lib/logstash/pipelines_registry.rb
432
433
  - lib/logstash/plugin.rb
433
434
  - lib/logstash/plugins.rb
434
435
  - lib/logstash/plugins/builtin.rb
@@ -542,6 +543,7 @@ files:
542
543
  - spec/logstash/pipeline_pq_file_spec.rb
543
544
  - spec/logstash/pipeline_reporter_spec.rb
544
545
  - spec/logstash/pipeline_spec.rb
546
+ - spec/logstash/pipelines_registry_spec.rb
545
547
  - spec/logstash/plugin_spec.rb
546
548
  - spec/logstash/plugins/builtin/pipeline_input_output_spec.rb
547
549
  - spec/logstash/plugins/hooks_registry_spec.rb
@@ -681,6 +683,7 @@ test_files:
681
683
  - spec/logstash/pipeline_pq_file_spec.rb
682
684
  - spec/logstash/pipeline_reporter_spec.rb
683
685
  - spec/logstash/pipeline_spec.rb
686
+ - spec/logstash/pipelines_registry_spec.rb
684
687
  - spec/logstash/plugin_spec.rb
685
688
  - spec/logstash/plugins/builtin/pipeline_input_output_spec.rb
686
689
  - spec/logstash/plugins/hooks_registry_spec.rb