fluentd-ui 1.0.0.beta.1 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of fluentd-ui might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/ChangeLog.md +24 -0
- data/Gemfile +5 -3
- data/Gemfile.lock +88 -75
- data/README.md +11 -0
- data/Rakefile +1 -1
- data/app/javascript/packs/aws_credential.js +1 -1
- data/app/javascript/packs/in_tail_parse.js +1 -1
- data/app/javascript/packs/owned_plugin_form.js +1 -1
- data/app/javascript/packs/settings.js +20 -9
- data/app/javascript/packs/transport_config.js +1 -1
- data/app/javascript/packs/transport_section.js +1 -1
- data/app/javascript/packs/treeview.js +2 -2
- data/app/models/plugin.rb +2 -2
- data/app/views/fluentd/settings/source_and_output.html.haml +12 -10
- data/app/views/layouts/application.html.erb +3 -0
- data/app/views/plugins/recommended.html.haml +3 -0
- data/app/views/plugins/updated.html.haml +5 -6
- data/config.ru +3 -1
- data/config/application.rb +1 -1
- data/config/application.yml +104 -31
- data/config/locales/translation_en.yml +1 -0
- data/config/locales/translation_ja.yml +1 -0
- data/gemfiles/ruby2.2.gemfile +2 -1
- data/lib/fluentd-ui/version.rb +1 -1
- data/test/application_system_test_case.rb +8 -0
- data/test/controllers/application_controller_test.rb +42 -0
- data/test/controllers/fluentd/agents_controller_test.rb +39 -0
- data/test/controllers/misc_controller_test.rb +70 -0
- data/test/controllers/polling_controller_test.rb +29 -0
- data/test/decorators/plugin_decorator_test.rb +26 -0
- data/{spec → test}/factories/fluentd.rb +0 -0
- data/{spec → test}/factories/plugins.rb +0 -0
- data/{spec → test}/factories/user.rb +0 -0
- data/{spec/support → test}/fixtures/error0.log +0 -0
- data/{spec/support → test}/fixtures/error2.log +0 -0
- data/{spec/support → test}/fixtures/error3.log +0 -0
- data/{spec/support → test}/fixtures/error4.log +0 -0
- data/{spec/support → test}/fixtures/multiline_example.log +0 -0
- data/test/integration/dashboard_test.rb +57 -0
- data/test/integration/fluentd/setting/histories_test.rb +139 -0
- data/test/integration/fluentd/setting/notes_test.rb +27 -0
- data/test/integration/fluentd/setting/running_backup_test.rb +65 -0
- data/test/integration/fluentd_ui_update_checking_test.rb +27 -0
- data/test/integration/sesstions_test.rb +56 -0
- data/test/integration/setting_test.rb +126 -0
- data/test/integration/users_test.rb +43 -0
- data/test/lib/filte_reverse_reader_test.rb +63 -0
- data/test/lib/fluentd_ui_test.rb +36 -0
- data/test/lib/regexp_preview/multi_line_test.rb +86 -0
- data/test/lib/regexp_preview/single_line_test.rb +87 -0
- data/test/models/fluent_gem_test.rb +76 -0
- data/test/models/fluentd/agent_test.rb +331 -0
- data/{spec/models/fluentd/setting/in_forward_spec.rb → test/models/fluentd/setting/in_forward_test.rb} +32 -44
- data/test/models/fluentd/setting/in_http_test.rb +30 -0
- data/test/models/fluentd/setting/in_monitor_agent_test.rb +30 -0
- data/test/models/fluentd/setting/in_syslog_test.rb +88 -0
- data/test/models/fluentd/setting/in_tail_test.rb +52 -0
- data/test/models/fluentd/setting/out_elasticsearch_test.rb +32 -0
- data/test/models/fluentd/setting/out_mongo_test.rb +61 -0
- data/test/models/fluentd/setting/out_s3_test.rb +112 -0
- data/test/models/fluentd/setting/out_stdout_test.rb +32 -0
- data/test/models/fluentd/setting/out_tdlog_test.rb +60 -0
- data/test/models/fluentd_log_test.rb +140 -0
- data/test/models/fluentd_test.rb +185 -0
- data/test/models/plugin_test.rb +144 -0
- data/test/models/user_test.rb +48 -0
- data/test/support/config_histories.rb +72 -0
- data/test/support/configurable_daemon_settings.rb +26 -0
- data/test/support/login_macro.rb +12 -0
- data/test/support/login_required.rb +8 -0
- data/test/support/stub_daemon.rb +14 -0
- data/test/system/fluentd/setting/in_forward_test.rb +13 -0
- data/test/system/fluentd/setting/in_http_test.rb +13 -0
- data/test/system/fluentd/setting/in_monitor_agent.rb +13 -0
- data/test/system/fluentd/setting/out_elasticsearch_test.rb +32 -0
- data/test/system/fluentd/setting/out_forward_test.rb +41 -0
- data/test/system/fluentd/setting/out_stdout_test.rb +15 -0
- data/test/system/fluentd/setting/out_tdlog_test.rb +15 -0
- data/test/system/source_and_output_test.rb +184 -0
- data/test/test_helper.rb +34 -0
- metadata +147 -161
- data/spec/controllers/application_controller_spec.rb +0 -84
- data/spec/controllers/fluentd/agents_controller_spec.rb +0 -61
- data/spec/controllers/misc_controller_spec.rb +0 -68
- data/spec/controllers/polling_controller_spec.rb +0 -39
- data/spec/controllers/sessions_controller_spec.rb +0 -5
- data/spec/decorators/plugin_decorator_spec.rb +0 -37
- data/spec/features/dashboard_spec.rb +0 -42
- data/spec/features/fluentd/setting/histories_spec.rb +0 -110
- data/spec/features/fluentd/setting/in_forward_spec.rb +0 -6
- data/spec/features/fluentd/setting/in_http_spec.rb +0 -6
- data/spec/features/fluentd/setting/in_monitor_agent_spec.rb +0 -6
- data/spec/features/fluentd/setting/notes_spec.rb +0 -27
- data/spec/features/fluentd/setting/out_forward_spec.rb +0 -38
- data/spec/features/fluentd/setting/out_stdout_spec.rb +0 -6
- data/spec/features/fluentd/setting/running_backup_spec.rb +0 -106
- data/spec/features/fluentd_status_spec.rb +0 -36
- data/spec/features/fluentd_ui_update_available_spec.rb +0 -33
- data/spec/features/out_elasticsearch_spec.rb +0 -28
- data/spec/features/out_forward_spec.rb +0 -36
- data/spec/features/out_tdlog_spec.rb +0 -26
- data/spec/features/sessions_spec.rb +0 -79
- data/spec/features/setting_spec.rb +0 -95
- data/spec/features/shared_examples/configurable_daemon_settings.rb +0 -17
- data/spec/features/shared_examples/login_required.rb +0 -4
- data/spec/features/source_and_output_spec.rb +0 -158
- data/spec/features/users_spec.rb +0 -53
- data/spec/grok_converter_spec.rb +0 -50
- data/spec/lib/file_reverse_reader_spec.rb +0 -93
- data/spec/lib/fluentd-ui_spec.rb +0 -35
- data/spec/lib/regexp_preview/multi_line_spec.rb +0 -111
- data/spec/lib/regexp_preview/single_line_spec.rb +0 -185
- data/spec/models/fluent_gem_spec.rb +0 -104
- data/spec/models/fluentd/agent/common_spec.rb +0 -82
- data/spec/models/fluentd/agent_spec.rb +0 -134
- data/spec/models/fluentd/setting/in_http_spec.rb +0 -31
- data/spec/models/fluentd/setting/in_monitor_agent_spec.rb +0 -31
- data/spec/models/fluentd/setting/in_syslog_spec.rb +0 -98
- data/spec/models/fluentd/setting/in_tail_spec.rb +0 -53
- data/spec/models/fluentd/setting/out_elasticsearch_spec.rb +0 -31
- data/spec/models/fluentd/setting/out_mongo_spec.rb +0 -62
- data/spec/models/fluentd/setting/out_s3_spec.rb +0 -128
- data/spec/models/fluentd/setting/out_stdout_spec.rb +0 -31
- data/spec/models/fluentd/setting/out_tdlog_spec.rb +0 -46
- data/spec/models/fluentd_log_spec.rb +0 -171
- data/spec/models/fluentd_spec.rb +0 -164
- data/spec/models/plugin_spec.rb +0 -191
- data/spec/models/user_spec.rb +0 -59
- data/spec/spec_helper.rb +0 -85
- data/spec/support/config_histories.rb +0 -57
- data/spec/support/fluentd_agent_common_behavior.rb +0 -181
- data/spec/support/fluentd_agent_restart_strategy.rb +0 -94
- data/spec/support/javascript_macro.rb +0 -21
- data/spec/support/login_macro.rb +0 -10
- data/spec/support/stub_daemon.rb +0 -12
@@ -1,46 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe Fluentd::Setting::OutTdlog do
|
4
|
-
let(:klass) { described_class }
|
5
|
-
let(:instance) { klass.new(valid_attributes) }
|
6
|
-
let(:valid_attributes) {
|
7
|
-
{
|
8
|
-
pattern: "td.*.*",
|
9
|
-
apikey: "APIKEY",
|
10
|
-
auto_create_table: "true",
|
11
|
-
}
|
12
|
-
}
|
13
|
-
|
14
|
-
describe "#valid?" do
|
15
|
-
it "should be invalid if apikey is missing" do
|
16
|
-
params = valid_attributes.dup
|
17
|
-
params.delete(:apikey)
|
18
|
-
instance = klass.new(params)
|
19
|
-
instance.should_not be_valid
|
20
|
-
instance.errors.full_messages.should == ["'apikey' parameter is required"]
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
describe "#plugin_name" do
|
25
|
-
subject { instance.plugin_name }
|
26
|
-
it { should == "tdlog" }
|
27
|
-
end
|
28
|
-
|
29
|
-
describe "#plugin_type" do
|
30
|
-
subject { instance.plugin_type }
|
31
|
-
it { should == "output" }
|
32
|
-
end
|
33
|
-
|
34
|
-
describe "#to_config" do
|
35
|
-
subject { instance.to_config.to_s }
|
36
|
-
let(:expected) {
|
37
|
-
<<-CONFIG
|
38
|
-
<match td.*.*>
|
39
|
-
@type tdlog
|
40
|
-
apikey APIKEY
|
41
|
-
</match>
|
42
|
-
CONFIG
|
43
|
-
}
|
44
|
-
it { should == expected }
|
45
|
-
end
|
46
|
-
end
|
@@ -1,171 +0,0 @@
|
|
1
|
-
# coding: utf-8
|
2
|
-
require "spec_helper"
|
3
|
-
|
4
|
-
describe FluentdLog do
|
5
|
-
describe "#read" do
|
6
|
-
let(:log) { FluentdLog.new(logfile) }
|
7
|
-
let(:logfile) { Rails.root.join("tmp", "dummylog").to_s }
|
8
|
-
|
9
|
-
before { File.open(logfile, "wb"){|f| f.write content } }
|
10
|
-
subject { log.read }
|
11
|
-
|
12
|
-
context "compatible with utf-8" do
|
13
|
-
let(:content) { "utf8あいう\n" }
|
14
|
-
it { subject.should == content }
|
15
|
-
end
|
16
|
-
|
17
|
-
context "incompatible with utf-8" do
|
18
|
-
let(:content) { "eucあいう\n".encode('euc-jp').force_encoding('ascii-8bit') }
|
19
|
-
it { subject.should == content }
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
|
-
describe "#tail" do
|
24
|
-
let(:log) { FluentdLog.new(logfile) }
|
25
|
-
let(:logfile) { Rails.root.join("tmp", "dummylog").to_s }
|
26
|
-
|
27
|
-
before { File.open(logfile, "wb"){|f| f.write content } }
|
28
|
-
|
29
|
-
context "5 lines log" do
|
30
|
-
let(:content) { 5.times.map{|n| "#{n}\n"}.join }
|
31
|
-
|
32
|
-
context "tail(5)" do
|
33
|
-
let(:limit) { 5 }
|
34
|
-
subject { log.tail(limit) }
|
35
|
-
|
36
|
-
it { should == %w(4 3 2 1 0) }
|
37
|
-
end
|
38
|
-
|
39
|
-
context "tail(3)" do
|
40
|
-
let(:limit) { 3 }
|
41
|
-
subject { log.tail(limit) }
|
42
|
-
|
43
|
-
it { should == %w(4 3 2) }
|
44
|
-
end
|
45
|
-
|
46
|
-
context "tail(99)" do
|
47
|
-
let(:limit) { 99 }
|
48
|
-
subject { log.tail(limit) }
|
49
|
-
|
50
|
-
it { should == %w(4 3 2 1 0) }
|
51
|
-
end
|
52
|
-
end
|
53
|
-
end
|
54
|
-
|
55
|
-
describe "#logged_errors" do
|
56
|
-
let(:log) { FluentdLog.new(logfile) }
|
57
|
-
|
58
|
-
describe "#last_error_message" do
|
59
|
-
subject { log.last_error_message }
|
60
|
-
|
61
|
-
context "have 0 error log" do
|
62
|
-
let(:logfile) { File.expand_path("./spec/support/fixtures/error0.log", Rails.root) }
|
63
|
-
|
64
|
-
it { should be_empty }
|
65
|
-
end
|
66
|
-
|
67
|
-
context "have 2 error log" do
|
68
|
-
let(:logfile) { File.expand_path("./spec/support/fixtures/error2.log", Rails.root) }
|
69
|
-
|
70
|
-
it { should == log.recent_errors(1).first[:subject] }
|
71
|
-
end
|
72
|
-
end
|
73
|
-
|
74
|
-
describe "#errors_since" do
|
75
|
-
let(:logged_time) { Time.parse('2014-05-27') }
|
76
|
-
let(:now) { Time.parse('2014-05-29') }
|
77
|
-
|
78
|
-
before { Timecop.freeze(now) }
|
79
|
-
after { Timecop.return }
|
80
|
-
|
81
|
-
subject { log.errors_since(days.days.ago) }
|
82
|
-
|
83
|
-
context "has no errors" do
|
84
|
-
let(:logfile) { File.expand_path("./spec/support/fixtures/error0.log", Rails.root) }
|
85
|
-
let(:days) { 100 }
|
86
|
-
|
87
|
-
it "empty array" do
|
88
|
-
should be_empty
|
89
|
-
end
|
90
|
-
end
|
91
|
-
|
92
|
-
context "has errors" do
|
93
|
-
let(:logfile) { File.expand_path("./spec/support/fixtures/error2.log", Rails.root) }
|
94
|
-
|
95
|
-
context "unreachable since" do
|
96
|
-
let(:days) { 0 }
|
97
|
-
it { should be_empty }
|
98
|
-
end
|
99
|
-
|
100
|
-
context "reachable since" do
|
101
|
-
let(:days) { 100 }
|
102
|
-
|
103
|
-
it "contain stack trace" do
|
104
|
-
subject[0][:subject].should include("Address already in use - bind(2)")
|
105
|
-
end
|
106
|
-
|
107
|
-
it "newer(bottom) is first" do
|
108
|
-
one = Time.parse(subject[0][:subject])
|
109
|
-
two = Time.parse(subject[1][:subject])
|
110
|
-
one.should >= two
|
111
|
-
end
|
112
|
-
end
|
113
|
-
end
|
114
|
-
end
|
115
|
-
|
116
|
-
describe "#recent_errors" do
|
117
|
-
context "have 0 error log" do
|
118
|
-
let(:logfile) { File.expand_path("./spec/support/fixtures/error0.log", Rails.root) }
|
119
|
-
subject { log.recent_errors(2) }
|
120
|
-
|
121
|
-
it "empty array" do
|
122
|
-
should be_empty
|
123
|
-
end
|
124
|
-
end
|
125
|
-
|
126
|
-
context "have 2 error log" do
|
127
|
-
let(:logfile) { File.expand_path("./spec/support/fixtures/error2.log", Rails.root) }
|
128
|
-
subject { log.recent_errors(2) }
|
129
|
-
|
130
|
-
describe "limit" do
|
131
|
-
subject { log.recent_errors(limit).length }
|
132
|
-
|
133
|
-
context "=1" do
|
134
|
-
let(:limit) { 1 }
|
135
|
-
it { should == limit }
|
136
|
-
end
|
137
|
-
|
138
|
-
context "=2" do
|
139
|
-
let(:limit) { 2 }
|
140
|
-
it { should == limit }
|
141
|
-
end
|
142
|
-
end
|
143
|
-
|
144
|
-
it "contain stack trace" do
|
145
|
-
subject[0][:subject].should include("Address already in use - bind(2)")
|
146
|
-
end
|
147
|
-
|
148
|
-
it "newer(bottom) is first" do
|
149
|
-
one = Time.parse(subject[0][:subject])
|
150
|
-
two = Time.parse(subject[1][:subject])
|
151
|
-
one.should >= two
|
152
|
-
end
|
153
|
-
end
|
154
|
-
|
155
|
-
context "have 3 errors log includeing sequential 2 error log" do
|
156
|
-
let(:logfile) { File.expand_path("./spec/support/fixtures/error3.log", Rails.root) }
|
157
|
-
subject { log.recent_errors(3) }
|
158
|
-
|
159
|
-
it "count 3 errors" do
|
160
|
-
subject[0][:subject].should include("3 Address already in use - bind(2)")
|
161
|
-
subject[0][:notes].size.should be 1
|
162
|
-
subject[1][:subject].should include("2 Address already in use - bind(2)")
|
163
|
-
subject[1][:notes].size.should be 2
|
164
|
-
subject[2][:subject].should include("1 Address already in use - bind(2)")
|
165
|
-
subject[2][:notes].size.should be 0
|
166
|
-
end
|
167
|
-
end
|
168
|
-
end
|
169
|
-
end
|
170
|
-
|
171
|
-
end
|
data/spec/models/fluentd_spec.rb
DELETED
@@ -1,164 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe Fluentd do
|
4
|
-
shared_examples_for "path permission" do |column|
|
5
|
-
let(:path) { fluentd.send(column) }
|
6
|
-
|
7
|
-
subject do
|
8
|
-
fluentd.check_permission(column)
|
9
|
-
fluentd.errors
|
10
|
-
end
|
11
|
-
|
12
|
-
context "file exists" do
|
13
|
-
before { FileUtils.touch(path) }
|
14
|
-
after { FileUtils.chmod(0755, path) }
|
15
|
-
|
16
|
-
context "writable" do
|
17
|
-
before { FileUtils.chmod(0600, path) }
|
18
|
-
it { should be_blank }
|
19
|
-
end
|
20
|
-
|
21
|
-
context "not writable" do
|
22
|
-
before { FileUtils.chmod(0400, path) }
|
23
|
-
it { should_not be_blank }
|
24
|
-
it { subject[column].should include(I18n.t('activerecord.errors.messages.lack_write_permission')) }
|
25
|
-
end
|
26
|
-
|
27
|
-
context "not readable" do
|
28
|
-
before { FileUtils.chmod(0200, path) }
|
29
|
-
it { should_not be_blank }
|
30
|
-
it { subject[column].should include(I18n.t('activerecord.errors.messages.lack_read_permission')) }
|
31
|
-
end
|
32
|
-
|
33
|
-
context "is directory" do
|
34
|
-
before { fluentd.send("#{column}=", Rails.root + "tmp") }
|
35
|
-
it { should_not be_blank }
|
36
|
-
it { subject[column].should include(I18n.t('activerecord.errors.messages.is_a_directory')) }
|
37
|
-
end
|
38
|
-
end
|
39
|
-
|
40
|
-
context "file not exists" do
|
41
|
-
let(:dir) { File.dirname(path) }
|
42
|
-
before { FileUtils.rm path }
|
43
|
-
after { FileUtils.chmod_R(0755, dir) }
|
44
|
-
|
45
|
-
context "writable" do
|
46
|
-
before { FileUtils.chmod(0700, dir) }
|
47
|
-
it { should be_blank }
|
48
|
-
end
|
49
|
-
|
50
|
-
context "not writable" do
|
51
|
-
before { FileUtils.chmod(0500, dir) }
|
52
|
-
it { should_not be_blank }
|
53
|
-
it { subject[column].should include(I18n.t('activerecord.errors.messages.lack_write_permission')) }
|
54
|
-
end
|
55
|
-
end
|
56
|
-
end
|
57
|
-
|
58
|
-
let(:fluentd) { build(:fluentd) }
|
59
|
-
after { File.unlink(Fluentd.json_path) if File.exist?(Fluentd.json_path) }
|
60
|
-
|
61
|
-
describe "#valid?" do
|
62
|
-
before do
|
63
|
-
%w(pid_file log_file config_file).each do |column|
|
64
|
-
FileUtils.mkdir_p File.dirname(fluentd.send(column))
|
65
|
-
FileUtils.touch fluentd.send(column)
|
66
|
-
end
|
67
|
-
end
|
68
|
-
|
69
|
-
subject { fluentd }
|
70
|
-
|
71
|
-
describe "variant" do
|
72
|
-
before { fluentd.variant = variant }
|
73
|
-
|
74
|
-
context "fluentd" do
|
75
|
-
let(:variant) { "fluentd_gem" }
|
76
|
-
it { should be_valid }
|
77
|
-
end
|
78
|
-
|
79
|
-
context "foobar (not declared in Fluentd.variants)" do
|
80
|
-
let(:variant) { "foobar" }
|
81
|
-
it { should_not be_valid }
|
82
|
-
end
|
83
|
-
end
|
84
|
-
|
85
|
-
describe "pid_file" do
|
86
|
-
it_should_behave_like "path permission", :pid_file
|
87
|
-
end
|
88
|
-
|
89
|
-
describe "log_file" do
|
90
|
-
it_should_behave_like "path permission", :log_file
|
91
|
-
end
|
92
|
-
|
93
|
-
describe "config_file" do
|
94
|
-
it_should_behave_like "path permission", :config_file
|
95
|
-
end
|
96
|
-
end
|
97
|
-
|
98
|
-
describe "variant" do
|
99
|
-
before { fluentd.variant = variant }
|
100
|
-
|
101
|
-
context "= fluentd_gem" do
|
102
|
-
let(:variant) { "fluentd_gem" }
|
103
|
-
it { fluentd.should be_fluentd_gem }
|
104
|
-
it { fluentd.should_not be_td_agent }
|
105
|
-
|
106
|
-
describe "#load_settings_from_agent_default" do
|
107
|
-
before { fluentd.load_settings_from_agent_default }
|
108
|
-
|
109
|
-
it { fluentd.pid_file == fluentd.agent.class.default_options[:pid_file] }
|
110
|
-
it { fluentd.log_file == fluentd.agent.class.default_options[:log_file] }
|
111
|
-
it { fluentd.config_file == fluentd.agent.class.default_options[:config_file] }
|
112
|
-
end
|
113
|
-
end
|
114
|
-
|
115
|
-
context "= td-agent" do
|
116
|
-
let(:variant) { "td-agent" }
|
117
|
-
it { fluentd.should_not be_fluentd_gem }
|
118
|
-
it { fluentd.should be_td_agent }
|
119
|
-
|
120
|
-
describe "#load_settings_from_agent_default" do
|
121
|
-
before { fluentd.load_settings_from_agent_default }
|
122
|
-
|
123
|
-
it { fluentd.pid_file == fluentd.agent.class.default_options[:pid_file] }
|
124
|
-
it { fluentd.log_file == fluentd.agent.class.default_options[:log_file] }
|
125
|
-
it { fluentd.config_file == fluentd.agent.class.default_options[:config_file] }
|
126
|
-
end
|
127
|
-
end
|
128
|
-
end
|
129
|
-
|
130
|
-
describe "#agent" do
|
131
|
-
before { fluentd.variant = variant }
|
132
|
-
subject { fluentd.agent }
|
133
|
-
|
134
|
-
context "fluentd_gem" do
|
135
|
-
let(:variant) { "fluentd_gem" }
|
136
|
-
it { should be_instance_of(Fluentd::Agent::FluentdGem) }
|
137
|
-
end
|
138
|
-
|
139
|
-
context "td-agent" do
|
140
|
-
let(:variant) { "td-agent" }
|
141
|
-
it { should be_instance_of(Fluentd::Agent::TdAgent) }
|
142
|
-
end
|
143
|
-
end
|
144
|
-
|
145
|
-
describe "#ensure_default_config_file" do
|
146
|
-
subject do
|
147
|
-
fluentd.config_file = config_file
|
148
|
-
fluentd.save
|
149
|
-
fluentd.config_file
|
150
|
-
end
|
151
|
-
|
152
|
-
let(:config_file) { Rails.root + "tmp/test.conf" }
|
153
|
-
|
154
|
-
context "doesn't exists" do
|
155
|
-
before { File.unlink(config_file) if File.exist?(config_file) }
|
156
|
-
it { File.exist?(subject).should be_truthy }
|
157
|
-
end
|
158
|
-
|
159
|
-
context "already exists" do
|
160
|
-
before { FileUtils.touch(config_file) }
|
161
|
-
it { File.exist?(subject).should be_truthy }
|
162
|
-
end
|
163
|
-
end
|
164
|
-
end
|
data/spec/models/plugin_spec.rb
DELETED
@@ -1,191 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe Plugin do
|
4
|
-
let(:plugin) { build(:plugin) }
|
5
|
-
|
6
|
-
describe ".installed" do
|
7
|
-
before { FluentGem.stub(:"`").and_return(gem_list) }
|
8
|
-
|
9
|
-
context "fluent-plugin-foo 0.1.2" do
|
10
|
-
let(:target) { Plugin.new(gem_name: "fluent-plugin-foo", version: "0.1.2") }
|
11
|
-
let(:gem_list) { <<-GEM.strip_heredoc }
|
12
|
-
dummy (3.3.3)
|
13
|
-
fluent-plugin-foo (0.1.2)
|
14
|
-
more_dummy (0.0.1)
|
15
|
-
GEM
|
16
|
-
|
17
|
-
it "detect foo plugin" do
|
18
|
-
Plugin.installed.first.inspect.should == target.inspect
|
19
|
-
end
|
20
|
-
|
21
|
-
it "detected foo plugin is marked as installed" do
|
22
|
-
target.should be_installed
|
23
|
-
end
|
24
|
-
|
25
|
-
it "detected foo plugin version to be installed_version" do
|
26
|
-
target.installed_version.should == target.version
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
31
|
-
describe "#valid?" do
|
32
|
-
describe "gem_name" do
|
33
|
-
subject { plugin }
|
34
|
-
before { plugin.gem_name = gem_name }
|
35
|
-
|
36
|
-
context "nil is invalid" do
|
37
|
-
let(:gem_name) { nil }
|
38
|
-
it { should_not be_valid }
|
39
|
-
end
|
40
|
-
|
41
|
-
context "something filled is valid" do
|
42
|
-
let(:gem_name) { "foobar" }
|
43
|
-
it { should be_valid }
|
44
|
-
end
|
45
|
-
end
|
46
|
-
|
47
|
-
describe "version" do
|
48
|
-
subject { plugin }
|
49
|
-
before { plugin.version = version }
|
50
|
-
|
51
|
-
context "nil is invalid" do
|
52
|
-
let(:version) { nil }
|
53
|
-
it { should_not be_valid }
|
54
|
-
end
|
55
|
-
|
56
|
-
context "something filled is valid" do
|
57
|
-
let(:version) { "0.0.1" }
|
58
|
-
it { should be_valid }
|
59
|
-
end
|
60
|
-
end
|
61
|
-
end
|
62
|
-
|
63
|
-
describe "#install!" do
|
64
|
-
describe "invoke fluent_gem" do
|
65
|
-
after do
|
66
|
-
plugin.stub(:valid?).and_return(valid)
|
67
|
-
plugin.stub(:installed?).and_return(installed)
|
68
|
-
plugin.install!
|
69
|
-
end
|
70
|
-
|
71
|
-
context "valid" do
|
72
|
-
let(:valid) { true }
|
73
|
-
|
74
|
-
context "installed" do
|
75
|
-
let(:installed) { true }
|
76
|
-
it { FluentGem.should_not_receive(:install) }
|
77
|
-
end
|
78
|
-
|
79
|
-
context "not installed" do
|
80
|
-
let(:installed) { false }
|
81
|
-
it { FluentGem.should_receive(:install) }
|
82
|
-
end
|
83
|
-
end
|
84
|
-
|
85
|
-
context "invalid" do
|
86
|
-
let(:valid) { false }
|
87
|
-
|
88
|
-
context "installed" do
|
89
|
-
let(:installed) { true }
|
90
|
-
it { FluentGem.should_not_receive(:install) }
|
91
|
-
end
|
92
|
-
|
93
|
-
context "not installed" do
|
94
|
-
let(:installed) { false }
|
95
|
-
it { FluentGem.should_not_receive(:installed) }
|
96
|
-
end
|
97
|
-
end
|
98
|
-
end
|
99
|
-
|
100
|
-
context "system command error" do
|
101
|
-
before { FluentGem.should_receive(:system).at_least(1).and_return(false) }
|
102
|
-
subject { expect { plugin.install! } }
|
103
|
-
|
104
|
-
it "raise GemError" do
|
105
|
-
subject.to raise_error(FluentGem::GemError)
|
106
|
-
end
|
107
|
-
|
108
|
-
it "error message contains gem name" do
|
109
|
-
subject.to raise_error(/#{plugin.gem_name}/)
|
110
|
-
end
|
111
|
-
end
|
112
|
-
end
|
113
|
-
|
114
|
-
describe "#uninstall!" do
|
115
|
-
let(:installed_plugin) { build(:plugin, gem_name: "fluent-plugin-foobar") }
|
116
|
-
|
117
|
-
before do
|
118
|
-
installed_plugin.stub(:installed?).and_return(installed)
|
119
|
-
end
|
120
|
-
|
121
|
-
context "installed" do
|
122
|
-
let(:installed) { true }
|
123
|
-
before { installed_plugin.should_receive(:gem_uninstall) }
|
124
|
-
it { installed_plugin.uninstall! }
|
125
|
-
end
|
126
|
-
|
127
|
-
context "not installed" do
|
128
|
-
let(:installed) { false }
|
129
|
-
before { installed_plugin.should_not_receive(:gem_uninstall) }
|
130
|
-
it { installed_plugin.uninstall! }
|
131
|
-
end
|
132
|
-
end
|
133
|
-
|
134
|
-
describe "#upgrade!" do
|
135
|
-
let(:installed_plugin) { build(:plugin, gem_name: "fluent-plugin-foobar", version: current_version) }
|
136
|
-
let(:current_version) { "1.0.0" }
|
137
|
-
let(:target_version) { "1.2.0" }
|
138
|
-
|
139
|
-
before do
|
140
|
-
# NOTE: not `plugin.stub` because upgrade! creates new Plugin instance internally
|
141
|
-
installed_plugin.stub(:installed?).and_return(true)
|
142
|
-
FluentGem.stub(:run).and_return(true)
|
143
|
-
|
144
|
-
installed_plugin.should_receive(:uninstall!)
|
145
|
-
FluentGem.should_receive(:install)
|
146
|
-
end
|
147
|
-
|
148
|
-
it { installed_plugin.upgrade!(target_version) }
|
149
|
-
end
|
150
|
-
|
151
|
-
describe "#to_param" do
|
152
|
-
it { plugin.to_param.should == plugin.gem_name }
|
153
|
-
end
|
154
|
-
|
155
|
-
describe "Gem versions" do
|
156
|
-
let(:plugin) { build(:plugin, version: current_version) }
|
157
|
-
let(:current_version) { "1.0.0" }
|
158
|
-
let(:versions) { %w(1.0.1 0.99.1 1.0.0 0.99.0 0.1.0 0.0.3 0.0.2 0.0.1) }
|
159
|
-
let(:authors) { %w(foo bar) }
|
160
|
-
let(:json) do
|
161
|
-
versions.map do |ver|
|
162
|
-
{
|
163
|
-
number: ver,
|
164
|
-
summary: "summary of #{ver}",
|
165
|
-
authors: authors,
|
166
|
-
}
|
167
|
-
end.to_json
|
168
|
-
end
|
169
|
-
|
170
|
-
before do
|
171
|
-
stub_request(:get, plugin.gem_json_url).to_return(body: json)
|
172
|
-
end
|
173
|
-
|
174
|
-
it "latest version is 1.0.1" do
|
175
|
-
plugin.latest_version.should == "1.0.1"
|
176
|
-
end
|
177
|
-
it "1.0.0 is not latest" do
|
178
|
-
plugin.should_not be_latest_version
|
179
|
-
plugin.latest_version.should_not == plugin.version
|
180
|
-
end
|
181
|
-
it "released version is sorted" do
|
182
|
-
plugin.released_versions.should == versions.sort_by{|ver| Gem::Version.new(ver) }.reverse
|
183
|
-
end
|
184
|
-
it "authors" do
|
185
|
-
plugin.authors.should == authors
|
186
|
-
end
|
187
|
-
it "summary" do
|
188
|
-
plugin.summary.should == "summary of #{plugin.version}"
|
189
|
-
end
|
190
|
-
end
|
191
|
-
end
|