logstash-core 2.1.3-java → 2.2.0-java
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of logstash-core might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/lib/logstash-core.rb +1 -3
- data/lib/logstash-core/logstash-core.rb +3 -0
- data/lib/logstash-core/version.rb +8 -0
- data/lib/logstash/agent.rb +48 -20
- data/lib/logstash/codecs/base.rb +2 -2
- data/lib/logstash/config/config_ast.rb +8 -3
- data/lib/logstash/environment.rb +0 -16
- data/lib/logstash/filters/base.rb +9 -5
- data/lib/logstash/inputs/base.rb +1 -1
- data/lib/logstash/output_delegator.rb +150 -0
- data/lib/logstash/outputs/base.rb +37 -40
- data/lib/logstash/pipeline.rb +259 -178
- data/lib/logstash/pipeline_reporter.rb +114 -0
- data/lib/logstash/plugin.rb +1 -1
- data/lib/logstash/{shutdown_controller.rb → shutdown_watcher.rb} +10 -37
- data/lib/logstash/util.rb +17 -0
- data/lib/logstash/util/decorators.rb +14 -7
- data/lib/logstash/util/worker_threads_default_printer.rb +4 -4
- data/lib/logstash/util/wrapped_synchronous_queue.rb +41 -0
- data/lib/logstash/version.rb +10 -2
- data/locales/en.yml +8 -3
- data/logstash-core.gemspec +5 -3
- data/spec/{core/conditionals_spec.rb → conditionals_spec.rb} +0 -0
- data/spec/{core/config_spec.rb → logstash/config/config_ast_spec.rb} +0 -0
- data/spec/{core/config_cpu_core_strategy_spec.rb → logstash/config/cpu_core_strategy_spec.rb} +0 -0
- data/spec/{core/config_defaults_spec.rb → logstash/config/defaults_spec.rb} +0 -0
- data/spec/{core/config_mixin_spec.rb → logstash/config/mixin_spec.rb} +0 -0
- data/spec/{core → logstash}/environment_spec.rb +0 -0
- data/spec/{filters → logstash/filters}/base_spec.rb +0 -0
- data/spec/{inputs → logstash/inputs}/base_spec.rb +0 -0
- data/spec/{lib/logstash → logstash}/java_integration_spec.rb +0 -0
- data/spec/{util → logstash}/json_spec.rb +0 -0
- data/spec/logstash/output_delegator_spec.rb +126 -0
- data/spec/logstash/outputs/base_spec.rb +40 -0
- data/spec/logstash/pipeline_reporter_spec.rb +85 -0
- data/spec/{core → logstash}/pipeline_spec.rb +128 -16
- data/spec/{core → logstash}/plugin_spec.rb +47 -1
- data/spec/logstash/runner_spec.rb +68 -0
- data/spec/{core/shutdown_controller_spec.rb → logstash/shutdown_watcher_spec.rb} +17 -11
- data/spec/{util → logstash/util}/buftok_spec.rb +0 -0
- data/spec/{util → logstash/util}/charset_spec.rb +0 -0
- data/spec/{util → logstash/util}/defaults_printer_spec.rb +4 -4
- data/spec/{util → logstash/util}/java_version_spec.rb +0 -0
- data/spec/{util → logstash/util}/plugin_version_spec.rb +0 -0
- data/spec/{util → logstash/util}/unicode_trimmer_spec.rb +0 -0
- data/spec/{util → logstash/util}/worker_threads_default_printer_spec.rb +8 -8
- data/spec/logstash/util/wrapped_synchronous_queue_spec.rb +28 -0
- data/spec/{util_spec.rb → logstash/util_spec.rb} +0 -0
- metadata +74 -81
- data/lib/logstash/event.rb +0 -275
- data/lib/logstash/patches/bundler.rb +0 -36
- data/lib/logstash/sized_queue.rb +0 -8
- data/lib/logstash/string_interpolation.rb +0 -140
- data/lib/logstash/timestamp.rb +0 -97
- data/lib/logstash/util/accessors.rb +0 -123
- data/spec/core/event_spec.rb +0 -518
- data/spec/core/runner_spec.rb +0 -40
- data/spec/core/timestamp_spec.rb +0 -84
- data/spec/coverage_helper.rb +0 -24
- data/spec/lib/logstash/bundler_spec.rb +0 -121
- data/spec/license_spec.rb +0 -67
- data/spec/outputs/base_spec.rb +0 -26
- data/spec/plugin_manager/install_spec.rb +0 -28
- data/spec/plugin_manager/update_spec.rb +0 -39
- data/spec/plugin_manager/util_spec.rb +0 -71
- data/spec/spec_helper.rb +0 -11
- data/spec/util/accessors_spec.rb +0 -170
- data/spec/util/compress_spec.rb +0 -121
- data/spec/util/gemfile_spec.rb +0 -212
- data/spec/util/retryable_spec.rb +0 -139
data/spec/spec_helper.rb
DELETED
@@ -1,11 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
require_relative 'coverage_helper'
|
3
|
-
# In order to archive an expected coverage analysis we need to eager load
|
4
|
-
# all logstash code base, otherwise it will not get a good analysis.
|
5
|
-
CoverageHelper.eager_load if ENV['COVERAGE']
|
6
|
-
|
7
|
-
require "logstash/devutils/rspec/spec_helper"
|
8
|
-
|
9
|
-
def installed_plugins
|
10
|
-
Gem::Specification.find_all.select { |spec| spec.metadata["logstash_plugin"] }.map { |plugin| plugin.name }
|
11
|
-
end
|
data/spec/util/accessors_spec.rb
DELETED
@@ -1,170 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
require "spec_helper"
|
3
|
-
require "logstash/util/accessors"
|
4
|
-
|
5
|
-
describe LogStash::Util::Accessors, :if => true do
|
6
|
-
|
7
|
-
context "using simple field" do
|
8
|
-
|
9
|
-
it "should get value of word key" do
|
10
|
-
str = "hello"
|
11
|
-
data = { "hello" => "world" }
|
12
|
-
accessors = LogStash::Util::Accessors.new(data)
|
13
|
-
expect(accessors.get(str)).to eq(data[str])
|
14
|
-
end
|
15
|
-
|
16
|
-
it "should get value of key with spaces" do
|
17
|
-
str = "hel lo"
|
18
|
-
data = { "hel lo" => "world" }
|
19
|
-
accessors = LogStash::Util::Accessors.new(data)
|
20
|
-
expect(accessors.get(str)).to eq(data[str])
|
21
|
-
end
|
22
|
-
|
23
|
-
it "should get value of numeric key string" do
|
24
|
-
str = "1"
|
25
|
-
data = { "1" => "world" }
|
26
|
-
accessors = LogStash::Util::Accessors.new(data)
|
27
|
-
expect(accessors.get(str)).to eq(data[str])
|
28
|
-
end
|
29
|
-
|
30
|
-
it "should handle delete" do
|
31
|
-
str = "simple"
|
32
|
-
data = { "simple" => "things" }
|
33
|
-
accessors = LogStash::Util::Accessors.new(data)
|
34
|
-
expect(accessors.del(str)).to eq("things")
|
35
|
-
expect(data).to be_empty
|
36
|
-
end
|
37
|
-
|
38
|
-
it "should handle delete on non-existent field" do
|
39
|
-
str = "[foo][bar]"
|
40
|
-
data = { "hello" => "world" }
|
41
|
-
accessors = LogStash::Util::Accessors.new(data)
|
42
|
-
expect(accessors.del(str)).to be_nil
|
43
|
-
expect(data).not_to be_empty
|
44
|
-
# assert no side effects
|
45
|
-
expect(accessors.get("foo")).to be_nil
|
46
|
-
expect(accessors.get("hello")).to eq("world")
|
47
|
-
end
|
48
|
-
|
49
|
-
it "should set string value" do
|
50
|
-
str = "simple"
|
51
|
-
data = {}
|
52
|
-
accessors = LogStash::Util::Accessors.new(data)
|
53
|
-
expect(accessors.set(str, "things")).to eq("things")
|
54
|
-
expect(data).to eq({ "simple" => "things" })
|
55
|
-
end
|
56
|
-
|
57
|
-
it "should set array value" do
|
58
|
-
str = "simple"
|
59
|
-
data = {}
|
60
|
-
accessors = LogStash::Util::Accessors.new(data)
|
61
|
-
expect(accessors.set(str, ["foo", "bar"])).to eq(["foo", "bar"])
|
62
|
-
expect(data).to eq({ "simple" => ["foo", "bar"]})
|
63
|
-
end
|
64
|
-
end
|
65
|
-
|
66
|
-
context "using field path" do
|
67
|
-
|
68
|
-
it "should get shallow string value of word key" do
|
69
|
-
str = "[hello]"
|
70
|
-
data = { "hello" => "world" }
|
71
|
-
accessors = LogStash::Util::Accessors.new(data)
|
72
|
-
expect(accessors.get(str)).to eq("world")
|
73
|
-
end
|
74
|
-
|
75
|
-
it "should get shallow string value of key with spaces" do
|
76
|
-
str = "[hel lo]"
|
77
|
-
data = { "hel lo" => "world" }
|
78
|
-
accessors = LogStash::Util::Accessors.new(data)
|
79
|
-
expect(accessors.get(str)).to eq("world")
|
80
|
-
end
|
81
|
-
|
82
|
-
it "should get shallow string value of numeric key string" do
|
83
|
-
str = "[1]"
|
84
|
-
data = { "1" => "world" }
|
85
|
-
accessors = LogStash::Util::Accessors.new(data)
|
86
|
-
expect(accessors.get(str)).to eq("world")
|
87
|
-
end
|
88
|
-
|
89
|
-
it "should get deep string value" do
|
90
|
-
str = "[hello][world]"
|
91
|
-
data = { "hello" => { "world" => "foo", "bar" => "baz" } }
|
92
|
-
accessors = LogStash::Util::Accessors.new(data)
|
93
|
-
expect(accessors.get(str)).to eq(data["hello"]["world"])
|
94
|
-
end
|
95
|
-
|
96
|
-
it "should return nil when getting a non-existant field (with no side-effects on original data)" do
|
97
|
-
str = "[hello][world]"
|
98
|
-
data = {}
|
99
|
-
accessors = LogStash::Util::Accessors.new(data)
|
100
|
-
expect(accessors.get(str)).to be_nil
|
101
|
-
expect(data).to be_empty
|
102
|
-
expect(accessors.set(str, "foo")).to eq("foo")
|
103
|
-
expect(data).to eq({ "hello" => {"world" => "foo"} })
|
104
|
-
end
|
105
|
-
|
106
|
-
it "should handle delete" do
|
107
|
-
str = "[hello][world]"
|
108
|
-
data = { "hello" => { "world" => "foo", "bar" => "baz" } }
|
109
|
-
accessors = LogStash::Util::Accessors.new(data)
|
110
|
-
expect(accessors.del(str)).to eq("foo")
|
111
|
-
|
112
|
-
# Make sure the "world" key is removed.
|
113
|
-
expect(data["hello"]).to eq({ "bar" => "baz" })
|
114
|
-
end
|
115
|
-
|
116
|
-
it "should set shallow string value" do
|
117
|
-
str = "[hello]"
|
118
|
-
data = {}
|
119
|
-
accessors = LogStash::Util::Accessors.new(data)
|
120
|
-
expect(accessors.set(str, "foo")).to eq("foo")
|
121
|
-
expect(data).to eq({ "hello" => "foo" })
|
122
|
-
end
|
123
|
-
|
124
|
-
it "should set deep string value" do
|
125
|
-
str = "[hello][world]"
|
126
|
-
data = {}
|
127
|
-
accessors = LogStash::Util::Accessors.new(data)
|
128
|
-
expect(accessors.set(str, "foo")).to eq("foo")
|
129
|
-
expect(data).to eq({ "hello" => { "world" => "foo" } })
|
130
|
-
end
|
131
|
-
|
132
|
-
it "should set deep array value" do
|
133
|
-
str = "[hello][world]"
|
134
|
-
data = {}
|
135
|
-
accessors = LogStash::Util::Accessors.new(data)
|
136
|
-
expect(accessors.set(str, ["foo", "bar"])).to eq(["foo", "bar"])
|
137
|
-
expect(data).to eq({ "hello" => { "world" => ["foo", "bar"] } })
|
138
|
-
end
|
139
|
-
|
140
|
-
it "should set element within array value" do
|
141
|
-
str = "[hello][0]"
|
142
|
-
data = {"hello" => ["foo", "bar"]}
|
143
|
-
accessors = LogStash::Util::Accessors.new(data)
|
144
|
-
expect(accessors.set(str, "world") ).to eq("world")
|
145
|
-
expect(data).to eq({"hello" => ["world", "bar"]})
|
146
|
-
end
|
147
|
-
|
148
|
-
it "should retrieve array item" do
|
149
|
-
data = { "hello" => { "world" => ["a", "b"], "bar" => "baz" } }
|
150
|
-
accessors = LogStash::Util::Accessors.new(data)
|
151
|
-
expect(accessors.get("[hello][world][0]")).to eq(data["hello"]["world"][0])
|
152
|
-
expect(accessors.get("[hello][world][1]")).to eq(data["hello"]["world"][1])
|
153
|
-
end
|
154
|
-
|
155
|
-
it "should retrieve array item containing hash" do
|
156
|
-
data = { "hello" => { "world" => [ { "a" => 123 }, { "b" => 345 } ], "bar" => "baz" } }
|
157
|
-
accessors = LogStash::Util::Accessors.new(data)
|
158
|
-
expect(accessors.get("[hello][world][0][a]")).to eq(data["hello"]["world"][0]["a"])
|
159
|
-
expect(accessors.get("[hello][world][1][b]")).to eq(data["hello"]["world"][1]["b"])
|
160
|
-
end
|
161
|
-
|
162
|
-
it "should handle delete of array element" do
|
163
|
-
str = "[geocoords][0]"
|
164
|
-
data = { "geocoords" => [4, 2] }
|
165
|
-
accessors = LogStash::Util::Accessors.new(data)
|
166
|
-
expect(accessors.del(str)).to eq(4)
|
167
|
-
expect(data).to eq({ "geocoords" => [2] })
|
168
|
-
end
|
169
|
-
end
|
170
|
-
end
|
data/spec/util/compress_spec.rb
DELETED
@@ -1,121 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
require "spec_helper"
|
3
|
-
require 'ostruct'
|
4
|
-
require "bootstrap/util/compress"
|
5
|
-
|
6
|
-
describe LogStash::Util::Zip do
|
7
|
-
|
8
|
-
subject { Class.new { extend LogStash::Util::Zip } }
|
9
|
-
|
10
|
-
context "#extraction" do
|
11
|
-
|
12
|
-
let(:source) { File.join(File.expand_path("."), "source_file.zip") }
|
13
|
-
let(:target) { File.expand_path("target_dir") }
|
14
|
-
|
15
|
-
it "raise an exception if the target dir exist" do
|
16
|
-
allow(File).to receive(:exist?).with(target).and_return(true)
|
17
|
-
expect { subject.extract(source, target) }.to raise_error
|
18
|
-
end
|
19
|
-
|
20
|
-
let(:zip_file) do
|
21
|
-
[ "foo", "bar", "zoo" ].inject([]) do |acc, name|
|
22
|
-
acc << OpenStruct.new(:name => name)
|
23
|
-
acc
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
|
-
it "extract the list of entries from a zip file" do
|
28
|
-
allow(Zip::File).to receive(:open).with(source).and_yield(zip_file)
|
29
|
-
expect(FileUtils).to receive(:mkdir_p).exactly(3).times
|
30
|
-
expect(zip_file).to receive(:extract).exactly(3).times
|
31
|
-
subject.extract(source, target)
|
32
|
-
end
|
33
|
-
end
|
34
|
-
|
35
|
-
context "#compression" do
|
36
|
-
|
37
|
-
let(:target) { File.join(File.expand_path("."), "target_file.zip") }
|
38
|
-
let(:source) { File.expand_path("source_dir") }
|
39
|
-
|
40
|
-
it "raise an exception if the target file exist" do
|
41
|
-
allow(File).to receive(:exist?).with(target).and_return(true)
|
42
|
-
expect { subject.compress(source, target) }.to raise_error
|
43
|
-
end
|
44
|
-
|
45
|
-
let(:dir_files) do
|
46
|
-
[ "foo", "bar", "zoo" ]
|
47
|
-
end
|
48
|
-
|
49
|
-
let(:zip_file) { Class.new }
|
50
|
-
|
51
|
-
it "add a dir to a zip file" do
|
52
|
-
allow(Zip::File).to receive(:open).with(target, ::Zip::File::CREATE).and_yield(zip_file)
|
53
|
-
allow(Dir).to receive(:glob).and_return(dir_files)
|
54
|
-
expect(zip_file).to receive(:add).exactly(3).times
|
55
|
-
subject.compress(source, target)
|
56
|
-
end
|
57
|
-
end
|
58
|
-
end
|
59
|
-
|
60
|
-
describe LogStash::Util::Tar do
|
61
|
-
|
62
|
-
subject { Class.new { extend LogStash::Util::Tar } }
|
63
|
-
|
64
|
-
context "#extraction" do
|
65
|
-
|
66
|
-
let(:source) { File.join(File.expand_path("."), "source_file.tar.gz") }
|
67
|
-
let(:target) { File.expand_path("target_dir") }
|
68
|
-
|
69
|
-
it "raise an exception if the target dir exist" do
|
70
|
-
allow(File).to receive(:exist?).with(target).and_return(true)
|
71
|
-
expect { subject.extract(source, target) }.to raise_error
|
72
|
-
end
|
73
|
-
|
74
|
-
let(:gzip_file) { Class.new }
|
75
|
-
|
76
|
-
let(:tar_file) do
|
77
|
-
[ "foo", "bar", "zoo" ].inject([]) do |acc, name|
|
78
|
-
acc << OpenStruct.new(:full_name => name)
|
79
|
-
acc
|
80
|
-
end
|
81
|
-
end
|
82
|
-
|
83
|
-
it "extract the list of entries from a tar.gz file" do
|
84
|
-
allow(Zlib::GzipReader).to receive(:open).with(source).and_yield(gzip_file)
|
85
|
-
allow(Gem::Package::TarReader).to receive(:new).with(gzip_file).and_yield(tar_file)
|
86
|
-
|
87
|
-
expect(FileUtils).to receive(:mkdir).with(target)
|
88
|
-
expect(File).to receive(:open).exactly(3).times
|
89
|
-
subject.extract(source, target)
|
90
|
-
end
|
91
|
-
end
|
92
|
-
|
93
|
-
context "#compression" do
|
94
|
-
|
95
|
-
let(:target) { File.join(File.expand_path("."), "target_file.tar.gz") }
|
96
|
-
let(:source) { File.expand_path("source_dir") }
|
97
|
-
|
98
|
-
it "raise an exception if the target file exist" do
|
99
|
-
allow(File).to receive(:exist?).with(target).and_return(true)
|
100
|
-
expect { subject.compress(source, target) }.to raise_error
|
101
|
-
end
|
102
|
-
|
103
|
-
let(:dir_files) do
|
104
|
-
[ "foo", "bar", "zoo" ]
|
105
|
-
end
|
106
|
-
|
107
|
-
let(:tar_file) { Class.new }
|
108
|
-
let(:tar) { Class.new }
|
109
|
-
|
110
|
-
it "add a dir to a tgz file" do
|
111
|
-
allow(Stud::Temporary).to receive(:file).and_yield(tar_file)
|
112
|
-
allow(Gem::Package::TarWriter).to receive(:new).with(tar_file).and_yield(tar)
|
113
|
-
allow(Dir).to receive(:glob).and_return(dir_files)
|
114
|
-
expect(File).to receive(:stat).exactly(3).times.and_return(OpenStruct.new(:mode => "rw"))
|
115
|
-
expect(tar).to receive(:add_file).exactly(3).times
|
116
|
-
expect(tar_file).to receive(:rewind)
|
117
|
-
expect(subject).to receive(:gzip).with(target, tar_file)
|
118
|
-
subject.compress(source, target)
|
119
|
-
end
|
120
|
-
end
|
121
|
-
end
|
data/spec/util/gemfile_spec.rb
DELETED
@@ -1,212 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
require "spec_helper"
|
3
|
-
require "pluginmanager/gemfile"
|
4
|
-
|
5
|
-
describe "logstash Gemfile Manager" do
|
6
|
-
|
7
|
-
context LogStash::Gemfile do
|
8
|
-
|
9
|
-
context "load" do
|
10
|
-
|
11
|
-
it "should load and return self" do
|
12
|
-
file = <<-END
|
13
|
-
source "https://rubygems.org"
|
14
|
-
gemspec :a => "a"
|
15
|
-
gem "test", "> 1.0", "< 2.0", :b => "b"
|
16
|
-
END
|
17
|
-
|
18
|
-
gemfile = LogStash::Gemfile.new(StringIO.new(file)).load
|
19
|
-
expect(gemfile).to be_an(LogStash::Gemfile)
|
20
|
-
end
|
21
|
-
|
22
|
-
it "should add sources" do
|
23
|
-
file = <<-END
|
24
|
-
source "a"
|
25
|
-
source "b"
|
26
|
-
END
|
27
|
-
|
28
|
-
gemfile = LogStash::Gemfile.new(StringIO.new(file)).load
|
29
|
-
expect(gemfile.gemset.sources.size).to eq(2)
|
30
|
-
expect(gemfile.gemset.sources).to eq(["a", "b"])
|
31
|
-
end
|
32
|
-
|
33
|
-
it "should add gemspec" do
|
34
|
-
file = <<-END
|
35
|
-
gemspec "foo"
|
36
|
-
END
|
37
|
-
|
38
|
-
gemfile = LogStash::Gemfile.new(StringIO.new(file)).load
|
39
|
-
expect(gemfile.gemset.gemspec).to eq("foo")
|
40
|
-
end
|
41
|
-
|
42
|
-
it "should raise on multiple gemspec" do
|
43
|
-
file = <<-END
|
44
|
-
gemspec "foo"
|
45
|
-
gemspec "boom"
|
46
|
-
END
|
47
|
-
|
48
|
-
expect{LogStash::Gemfile.new(StringIO.new(file)).load}.to raise_error(LogStash::GemfileError)
|
49
|
-
end
|
50
|
-
|
51
|
-
it "should add gems" do
|
52
|
-
file = <<-END
|
53
|
-
gem "foo"
|
54
|
-
gem "bar"
|
55
|
-
END
|
56
|
-
|
57
|
-
gemfile = LogStash::Gemfile.new(StringIO.new(file)).load
|
58
|
-
expect(gemfile.gemset.gems.size).to eq(2)
|
59
|
-
expect(gemfile.gemset.gems[0].name).to eq("foo")
|
60
|
-
expect(gemfile.gemset.gems[1].name).to eq("bar")
|
61
|
-
end
|
62
|
-
|
63
|
-
it "should raise on duplicate gem name" do
|
64
|
-
file = <<-END
|
65
|
-
gem "foo"
|
66
|
-
gem "foo"
|
67
|
-
END
|
68
|
-
|
69
|
-
expect{LogStash::Gemfile.new(StringIO.new(file)).load}.to raise_error(LogStash::GemfileError)
|
70
|
-
end
|
71
|
-
|
72
|
-
it "should add gems with only name" do
|
73
|
-
file = <<-END
|
74
|
-
gem "foo"
|
75
|
-
END
|
76
|
-
|
77
|
-
gemfile = LogStash::Gemfile.new(StringIO.new(file)).load
|
78
|
-
|
79
|
-
expect(gemfile.gemset.gems[0].name).to eq("foo")
|
80
|
-
expect(gemfile.gemset.gems[0].requirements.empty?).to eq(true)
|
81
|
-
expect(gemfile.gemset.gems[0].options.empty?).to eq(true)
|
82
|
-
end
|
83
|
-
|
84
|
-
it "should add gems with name and requirements" do
|
85
|
-
file = <<-END
|
86
|
-
gem "foo", "a"
|
87
|
-
gem "bar", "a", "b"
|
88
|
-
END
|
89
|
-
|
90
|
-
gemfile = LogStash::Gemfile.new(StringIO.new(file)).load
|
91
|
-
|
92
|
-
expect(gemfile.gemset.gems[0].name).to eq("foo")
|
93
|
-
expect(gemfile.gemset.gems[0].requirements).to eq(["a"])
|
94
|
-
expect(gemfile.gemset.gems[0].options.empty?).to eq(true)
|
95
|
-
|
96
|
-
expect(gemfile.gemset.gems[1].name).to eq("bar")
|
97
|
-
expect(gemfile.gemset.gems[1].requirements).to eq(["a", "b"])
|
98
|
-
expect(gemfile.gemset.gems[1].options.empty?).to eq(true)
|
99
|
-
end
|
100
|
-
|
101
|
-
it "should add gems with name and options" do
|
102
|
-
file = <<-END
|
103
|
-
gem "foo", :a => "a"
|
104
|
-
gem "bar", :a => "a", :b => "b"
|
105
|
-
END
|
106
|
-
|
107
|
-
gemfile = LogStash::Gemfile.new(StringIO.new(file)).load
|
108
|
-
|
109
|
-
expect(gemfile.gemset.gems[0].name).to eq("foo")
|
110
|
-
expect(gemfile.gemset.gems[0].requirements.empty?).to eq(true)
|
111
|
-
expect(gemfile.gemset.gems[0].options).to eq({:a => "a"})
|
112
|
-
|
113
|
-
expect(gemfile.gemset.gems[1].name).to eq("bar")
|
114
|
-
expect(gemfile.gemset.gems[1].requirements.empty?).to eq(true)
|
115
|
-
expect(gemfile.gemset.gems[1].options).to eq({:a => "a", :b => "b"})
|
116
|
-
end
|
117
|
-
|
118
|
-
it "should add gems with name, requirements and options" do
|
119
|
-
file = <<-END
|
120
|
-
gem "foo", "> 1.0", :b => "b"
|
121
|
-
gem "bar", "> 2.0", "< 3.0", :c => "c", :d => "d"
|
122
|
-
END
|
123
|
-
|
124
|
-
gemfile = LogStash::Gemfile.new(StringIO.new(file)).load
|
125
|
-
expect(gemfile.gemset.gems.size).to eq(2)
|
126
|
-
|
127
|
-
expect(gemfile.gemset.gems[0].name).to eq("foo")
|
128
|
-
expect(gemfile.gemset.gems[0].requirements).to eq(["> 1.0"])
|
129
|
-
expect(gemfile.gemset.gems[0].options).to eq({:b => "b"})
|
130
|
-
|
131
|
-
expect(gemfile.gemset.gems[1].name).to eq("bar")
|
132
|
-
expect(gemfile.gemset.gems[1].requirements).to eq(["> 2.0", "< 3.0"])
|
133
|
-
expect(gemfile.gemset.gems[1].options).to eq({:c => "c", :d => "d"})
|
134
|
-
end
|
135
|
-
end
|
136
|
-
|
137
|
-
describe "Locally installed gems" do
|
138
|
-
subject { LogStash::Gemfile.new(StringIO.new(file)).load.locally_installed_gems }
|
139
|
-
|
140
|
-
context "has gems defined with a path" do
|
141
|
-
let(:file) {
|
142
|
-
%Q[
|
143
|
-
source "https://rubygems.org"
|
144
|
-
gemspec :a => "a", "b" => 1
|
145
|
-
gem "foo", "> 1.0", :path => "/tmp/foo"
|
146
|
-
gem "bar", :path => "/tmp/bar"
|
147
|
-
gem "no-fun"
|
148
|
-
]
|
149
|
-
}
|
150
|
-
|
151
|
-
it "returns the list of gems" do
|
152
|
-
expect(subject.collect(&:name)).to eq(["foo", "bar"])
|
153
|
-
end
|
154
|
-
end
|
155
|
-
|
156
|
-
context "no gems defined with a path" do
|
157
|
-
let(:file) {
|
158
|
-
%Q[
|
159
|
-
source "https://rubygems.org"
|
160
|
-
gemspec :a => "a", "b" => 1
|
161
|
-
gem "no-fun"
|
162
|
-
]
|
163
|
-
}
|
164
|
-
|
165
|
-
it "return an empty list" do
|
166
|
-
expect(subject.size).to eq(0)
|
167
|
-
end
|
168
|
-
end
|
169
|
-
|
170
|
-
context "keep a backup of the original file" do
|
171
|
-
|
172
|
-
end
|
173
|
-
end
|
174
|
-
|
175
|
-
context "save" do
|
176
|
-
it "should save" do
|
177
|
-
file = <<-END
|
178
|
-
source "https://rubygems.org"
|
179
|
-
gemspec :a => "a", "b" => 1
|
180
|
-
gem "foo", "> 1.0", "< 2.0", :b => "b"
|
181
|
-
gem "bar"
|
182
|
-
END
|
183
|
-
|
184
|
-
io = StringIO.new(file)
|
185
|
-
gemfile = LogStash::Gemfile.new(io).load
|
186
|
-
gemfile.save
|
187
|
-
expect(file).to eq(
|
188
|
-
LogStash::Gemfile::HEADER + \
|
189
|
-
"source \"https://rubygems.org\"\n" + \
|
190
|
-
"gemspec :a => \"a\", \"b\" => 1\n" + \
|
191
|
-
"gem \"foo\", \"> 1.0\", \"< 2.0\", :b => \"b\"\n" + \
|
192
|
-
"gem \"bar\"\n"
|
193
|
-
)
|
194
|
-
end
|
195
|
-
end
|
196
|
-
end
|
197
|
-
|
198
|
-
context LogStash::DSL do
|
199
|
-
context "parse" do
|
200
|
-
it "should parse Gemfile content string" do
|
201
|
-
gemfile = <<-END
|
202
|
-
source "https://rubygems.org"
|
203
|
-
gemspec
|
204
|
-
gem "foo"
|
205
|
-
END
|
206
|
-
|
207
|
-
gemset = LogStash::DSL.parse(gemfile)
|
208
|
-
expect(gemset).to be_an(LogStash::Gemset)
|
209
|
-
end
|
210
|
-
end
|
211
|
-
end
|
212
|
-
end
|