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,17 +0,0 @@
|
|
1
|
-
shared_examples_for "configurable daemon settings" do |type, form_name, form_value|
|
2
|
-
it "Shown form with filled in td.*.* on match" do
|
3
|
-
visit send("daemon_setting_#{type}_path")
|
4
|
-
page.should have_css("input[name=\"setting[#{form_name}]\"]")
|
5
|
-
end
|
6
|
-
|
7
|
-
it "Updated config after submit" do
|
8
|
-
daemon.agent.config.should_not include(form_value)
|
9
|
-
visit send("daemon_setting_#{type}_path")
|
10
|
-
within("form") do
|
11
|
-
fill_in form_name.capitalize, with: form_value
|
12
|
-
end
|
13
|
-
click_button I18n.t("fluentd.common.finish")
|
14
|
-
daemon.agent.config.should include(form_value)
|
15
|
-
end
|
16
|
-
|
17
|
-
end
|
@@ -1,158 +0,0 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
|
3
|
-
describe "source_and_output", js: true, stub: :daemon do
|
4
|
-
let(:exists_user) { build(:user) }
|
5
|
-
|
6
|
-
before do
|
7
|
-
login_with exists_user
|
8
|
-
end
|
9
|
-
|
10
|
-
before do
|
11
|
-
daemon.agent.config_write config_contents
|
12
|
-
visit source_and_output_daemon_setting_path
|
13
|
-
end
|
14
|
-
|
15
|
-
context "config is blank" do
|
16
|
-
let(:config_contents) { "" }
|
17
|
-
it do
|
18
|
-
page.should have_content(I18n.t("fluentd.settings.source_and_output.setting_empty"))
|
19
|
-
page.should have_css(".input .empty")
|
20
|
-
page.should have_css(".output .empty")
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
context "config is given" do
|
25
|
-
let(:config_contents) { <<-CONF.strip_heredoc }
|
26
|
-
<source>
|
27
|
-
# http://docs.fluentd.org/articles/in_forward
|
28
|
-
type forward
|
29
|
-
port 24224
|
30
|
-
</source>
|
31
|
-
|
32
|
-
<match debug.*>
|
33
|
-
# http://docs.fluentd.org/articles/out_stdout
|
34
|
-
type stdout
|
35
|
-
</match>
|
36
|
-
|
37
|
-
<match s3.*>
|
38
|
-
type s3
|
39
|
-
aws_key_id fofoaiofa
|
40
|
-
aws_sec_key aaaaaaaaaaaaaae
|
41
|
-
s3_bucket test
|
42
|
-
s3_endpoint s3-us-west-1.amazonaws.com
|
43
|
-
format out_file
|
44
|
-
include_time_key false
|
45
|
-
add_newline false
|
46
|
-
output_tag true
|
47
|
-
output_time true
|
48
|
-
store_as gzip
|
49
|
-
use_ssl true
|
50
|
-
buffer_type memory
|
51
|
-
</match>
|
52
|
-
CONF
|
53
|
-
|
54
|
-
it do
|
55
|
-
page.should_not have_content(I18n.t("fluentd.settings.source_and_output.setting_empty"))
|
56
|
-
|
57
|
-
page.should have_css('.input .card .card-header')
|
58
|
-
page.should have_css('.output .card .card-header')
|
59
|
-
end
|
60
|
-
|
61
|
-
it ".card-body is hidden by default and click .card-header for display" do
|
62
|
-
page.should_not have_css('.input .card .card-body')
|
63
|
-
page.should_not have_css('.output .card .card-body')
|
64
|
-
all(".input .card .card-header").first.click
|
65
|
-
page.should have_css('.input .card .card-body')
|
66
|
-
all(".output .card .card-header").first.click
|
67
|
-
page.should have_css('.output .card .card-body')
|
68
|
-
end
|
69
|
-
|
70
|
-
it "display plugin name" do
|
71
|
-
within ".input" do
|
72
|
-
page.should have_content("forward")
|
73
|
-
end
|
74
|
-
|
75
|
-
within ".output" do
|
76
|
-
page.should have_content("stdout")
|
77
|
-
page.should have_content("s3")
|
78
|
-
end
|
79
|
-
end
|
80
|
-
end
|
81
|
-
|
82
|
-
describe "edit, update, delete" do
|
83
|
-
let(:config_contents) { <<-CONF.strip_heredoc }
|
84
|
-
<source>
|
85
|
-
type forward
|
86
|
-
port 24224
|
87
|
-
</source>
|
88
|
-
CONF
|
89
|
-
let(:new_config) { <<-CONF.strip_heredoc }
|
90
|
-
<source>
|
91
|
-
type http
|
92
|
-
port 8899
|
93
|
-
</source>
|
94
|
-
CONF
|
95
|
-
|
96
|
-
before do
|
97
|
-
all(".input .card .card-header").first.click
|
98
|
-
end
|
99
|
-
|
100
|
-
it "click edit button transform textarea, then click cancel button to be reset" do
|
101
|
-
skip "Doesn't work on Poltergeist"
|
102
|
-
page.should_not have_css('.input textarea')
|
103
|
-
find(".btn", text: I18n.t('terms.edit')).click
|
104
|
-
page.evaluate_script(<<-JS).should == config_contents
|
105
|
-
document.querySelector("textarea").codemirror.getValue()
|
106
|
-
JS
|
107
|
-
page.evaluate_script <<-JS
|
108
|
-
var cm = document.querySelector('textarea').codemirror;
|
109
|
-
cm.setValue(JSON.parse(#{new_config.to_json}));
|
110
|
-
JS
|
111
|
-
find(".btn", text: I18n.t('terms.cancel')).click
|
112
|
-
content = wait_until do
|
113
|
-
page.evaluate_script("document.querySelector('.input pre').textContent")
|
114
|
-
end
|
115
|
-
content.should == config_contents
|
116
|
-
daemon.agent.config.strip.should == config_contents.strip
|
117
|
-
end
|
118
|
-
|
119
|
-
it "click edit button transform textarea, then click update button to be stored" do
|
120
|
-
skip "Doesn't work on Poltergeist"
|
121
|
-
page.should_not have_css('.input textarea')
|
122
|
-
find(".btn", text: I18n.t('terms.edit')).click
|
123
|
-
page.evaluate_script(<<-JS).should == config_contents
|
124
|
-
document.querySelector("textarea").codemirror.getValue()
|
125
|
-
JS
|
126
|
-
page.evaluate_script <<-JS
|
127
|
-
var cm = document.querySelector('textarea').codemirror;
|
128
|
-
cm.setValue(JSON.parse(#{new_config.to_json}));
|
129
|
-
JS
|
130
|
-
find(".btn", text: I18n.t('terms.save')).click
|
131
|
-
content = wait_until do
|
132
|
-
page.evaluate_script("document.querySelector('.input pre').textContent")
|
133
|
-
end
|
134
|
-
content.should == new_config
|
135
|
-
daemon.agent.config.strip.should == new_config.strip
|
136
|
-
end
|
137
|
-
|
138
|
-
it "click delete button transform textarea" do
|
139
|
-
skip "accept_confirm does not work properly"
|
140
|
-
page.should have_css('.input .card-body')
|
141
|
-
accept_confirm do
|
142
|
-
find(".btn", text: I18n.t('terms.destroy')).click
|
143
|
-
end
|
144
|
-
page.should_not have_css('.input .card-body')
|
145
|
-
daemon.agent.config.strip.should == ""
|
146
|
-
end
|
147
|
-
|
148
|
-
it "click delete button then cancel it" do
|
149
|
-
skip "accept_confirm does not work properly"
|
150
|
-
page.should have_css('.input .card-body')
|
151
|
-
dismiss_confirm do
|
152
|
-
find(".btn", text: I18n.t('terms.destroy')).click
|
153
|
-
end
|
154
|
-
page.should have_css('.input .card-body')
|
155
|
-
daemon.agent.config.strip.should == config_contents.strip
|
156
|
-
end
|
157
|
-
end
|
158
|
-
end
|
data/spec/features/users_spec.rb
DELETED
@@ -1,53 +0,0 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
|
3
|
-
describe "users" do
|
4
|
-
describe "visit edit page before login" do
|
5
|
-
let(:url) { user_path }
|
6
|
-
it_should_behave_like "login required"
|
7
|
-
end
|
8
|
-
|
9
|
-
describe "edit" do
|
10
|
-
let!(:user) { build(:user) }
|
11
|
-
|
12
|
-
before do
|
13
|
-
login_with user
|
14
|
-
end
|
15
|
-
|
16
|
-
after do
|
17
|
-
# reset password to the default
|
18
|
-
FileUtils.rm_f(User::ENCRYPTED_PASSWORD_FILE)
|
19
|
-
end
|
20
|
-
|
21
|
-
describe 'to change password' do
|
22
|
-
let(:current_password) { user.password }
|
23
|
-
let(:password) { 'new_password' }
|
24
|
-
|
25
|
-
before do
|
26
|
-
visit user_path
|
27
|
-
fill_in 'user[current_password]', with: current_password
|
28
|
-
|
29
|
-
fill_in 'user[password]', with: password
|
30
|
-
fill_in 'user[password_confirmation]', with: password_confirmation
|
31
|
-
click_button I18n.t("terms.update_password")
|
32
|
-
end
|
33
|
-
|
34
|
-
context 'when valid new password/confirmation is input' do
|
35
|
-
let(:password_confirmation) { password }
|
36
|
-
|
37
|
-
it 'should update users password with new password' do
|
38
|
-
expect(page).to have_css('.alert-success')
|
39
|
-
expect(user.stored_digest).to eq user.digest(password)
|
40
|
-
end
|
41
|
-
end
|
42
|
-
|
43
|
-
context 'when invalid new password/confirmation is input' do
|
44
|
-
let(:password_confirmation) { 'invalid_password' }
|
45
|
-
|
46
|
-
it 'should not update users password with new password' do
|
47
|
-
expect(page).to have_css('.alert-danger')
|
48
|
-
expect(user.stored_digest).to eq user.digest(current_password)
|
49
|
-
end
|
50
|
-
end
|
51
|
-
end
|
52
|
-
end
|
53
|
-
end
|
data/spec/grok_converter_spec.rb
DELETED
@@ -1,50 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe GrokConverter do
|
4
|
-
describe "#convert_to_regexp" do
|
5
|
-
let(:grok) { GrokConverter.new }
|
6
|
-
|
7
|
-
subject { grok.convert_to_regexp(pattern) }
|
8
|
-
|
9
|
-
context "load" do
|
10
|
-
before { grok.load_patterns(Rails.root + "vendor/patterns/") }
|
11
|
-
|
12
|
-
context "basic key" do
|
13
|
-
let(:pattern) { "%{USER:username} is a user" }
|
14
|
-
|
15
|
-
it do
|
16
|
-
subject.names.should == ["username"]
|
17
|
-
end
|
18
|
-
|
19
|
-
it do
|
20
|
-
subject.match("foobar is a user").should be_truthy
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
context "without name" do
|
25
|
-
let(:pattern) { "%{USER} is a user" }
|
26
|
-
|
27
|
-
it do
|
28
|
-
subject.names.should == []
|
29
|
-
end
|
30
|
-
|
31
|
-
it do
|
32
|
-
subject.match("foobar2 is a user").should be_truthy
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
|
-
context "not exists key" do
|
37
|
-
let(:pattern) { "%{USER:username} %{USER} %{NOT_EXISTS_KEY:key} foo bar" }
|
38
|
-
|
39
|
-
it do
|
40
|
-
subject.names.should == ["username", "key"]
|
41
|
-
end
|
42
|
-
|
43
|
-
it do
|
44
|
-
subject.match("someuser user2 foo bar").should be_truthy
|
45
|
-
end
|
46
|
-
end
|
47
|
-
end
|
48
|
-
end
|
49
|
-
end
|
50
|
-
|
@@ -1,93 +0,0 @@
|
|
1
|
-
# coding: utf-8
|
2
|
-
|
3
|
-
require "enumerator"
|
4
|
-
require 'spec_helper'
|
5
|
-
|
6
|
-
describe FileReverseReader do
|
7
|
-
let(:instance) { FileReverseReader.new(io) }
|
8
|
-
let(:io) { File.open(logfile) }
|
9
|
-
|
10
|
-
describe "#each_line" do
|
11
|
-
let(:instance) { FileReverseReader.new(io, step) }
|
12
|
-
subject { instance.enum_for(:each_line) }
|
13
|
-
let(:logfile) { File.expand_path("./spec/support/fixtures/error0.log", Rails.root) }
|
14
|
-
|
15
|
-
context "read at once" do
|
16
|
-
|
17
|
-
context "small file (read at once)" do
|
18
|
-
let(:step) { File.size(logfile) }
|
19
|
-
|
20
|
-
it { subject.count.should == File.open(logfile).each_line.count }
|
21
|
-
it "reverse order" do
|
22
|
-
subject.to_a.should == File.open(logfile).each_line.to_a.map(&:strip).reverse
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
context "large file" do
|
27
|
-
let(:step) { 2 }
|
28
|
-
|
29
|
-
it { subject.count.should == File.open(logfile).each_line.count }
|
30
|
-
it "reverse order" do
|
31
|
-
subject.to_a.should == File.open(logfile).each_line.to_a.map(&:strip).reverse
|
32
|
-
end
|
33
|
-
end
|
34
|
-
end
|
35
|
-
end
|
36
|
-
|
37
|
-
describe "#binary_file?" do
|
38
|
-
let(:logfile) { File.expand_path("./tmp/log.log", Rails.root) }
|
39
|
-
before { File.open(logfile, "wb"){|f| f.write content} }
|
40
|
-
subject { instance.binary_file? }
|
41
|
-
|
42
|
-
context "contain ascii only" do
|
43
|
-
let(:content) { "ABCDE" }
|
44
|
-
it { should == false }
|
45
|
-
end
|
46
|
-
|
47
|
-
context "contain non-ascii" do
|
48
|
-
let(:content) { "\x89NG" }
|
49
|
-
it { should == true }
|
50
|
-
end
|
51
|
-
end
|
52
|
-
|
53
|
-
describe "#tail" do
|
54
|
-
let(:logfile) { File.expand_path("./tmp/log.log", Rails.root) }
|
55
|
-
before { File.open(logfile, "wb"){|f| f.write(content) } }
|
56
|
-
|
57
|
-
describe "count" do
|
58
|
-
let(:log_lines) { 100 }
|
59
|
-
let(:content) { "foo\n" * log_lines }
|
60
|
-
subject { instance.tail(count) }
|
61
|
-
|
62
|
-
context "2" do
|
63
|
-
let(:count) { 2 }
|
64
|
-
it { subject.to_a.size.should == count }
|
65
|
-
end
|
66
|
-
|
67
|
-
context "50" do
|
68
|
-
let(:count) { 50 }
|
69
|
-
it { subject.to_a.size.should == count }
|
70
|
-
end
|
71
|
-
|
72
|
-
context "over log lines" do
|
73
|
-
let(:count) { log_lines + 100 }
|
74
|
-
it { subject.to_a.size.should == log_lines }
|
75
|
-
end
|
76
|
-
end
|
77
|
-
|
78
|
-
describe "non-ascii encoding" do
|
79
|
-
subject { instance.tail }
|
80
|
-
|
81
|
-
context "compatible with utf-8" do
|
82
|
-
let(:content) { "utf8あいう\n" }
|
83
|
-
it { subject.to_a.should == [content.strip] }
|
84
|
-
end
|
85
|
-
|
86
|
-
context "incompatible with utf-8" do
|
87
|
-
let(:content) { "eucあいう\n".encode('euc-jp') }
|
88
|
-
it { subject.to_a.should == [] }
|
89
|
-
end
|
90
|
-
end
|
91
|
-
end
|
92
|
-
end
|
93
|
-
|
data/spec/lib/fluentd-ui_spec.rb
DELETED
@@ -1,35 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe FluentdUI do
|
4
|
-
describe ".update_available?" do
|
5
|
-
let(:current_version) { ::FluentdUI::VERSION }
|
6
|
-
before { FluentdUI.latest_version = latest_version }
|
7
|
-
subject { FluentdUI.update_available? }
|
8
|
-
|
9
|
-
context "nothing" do
|
10
|
-
let(:latest_version) { current_version }
|
11
|
-
it { should be_falsey }
|
12
|
-
end
|
13
|
-
|
14
|
-
context "available" do
|
15
|
-
let(:latest_version) { current_version.succ }
|
16
|
-
it { should be_truthy }
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
|
-
describe ".fluentd_version" do
|
21
|
-
before { Fluentd.stub(:instance).and_return(target) }
|
22
|
-
subject { FluentdUI.fluentd_version }
|
23
|
-
|
24
|
-
context "not setup yet" do
|
25
|
-
let(:target) { nil }
|
26
|
-
it { should be_nil }
|
27
|
-
end
|
28
|
-
|
29
|
-
context "did setup" do
|
30
|
-
let(:target) { build(:fluentd) }
|
31
|
-
let(:version) { "1.1.1" }
|
32
|
-
it { should == target.agent.version }
|
33
|
-
end
|
34
|
-
end
|
35
|
-
end
|
@@ -1,111 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe RegexpPreview::MultiLine do
|
4
|
-
describe "#matches" do
|
5
|
-
subject { parser.matches }
|
6
|
-
let(:parser) { RegexpPreview::MultiLine.new(target_path, "multiline", plugin_config) }
|
7
|
-
|
8
|
-
describe "simple usage" do
|
9
|
-
let(:target_path) { File.expand_path("./spec/support/fixtures/error0.log", Rails.root) }
|
10
|
-
|
11
|
-
let :plugin_config do
|
12
|
-
plugin_config = {
|
13
|
-
"format_firstline" => "/foo/",
|
14
|
-
"time_format" => "time_format",
|
15
|
-
}
|
16
|
-
plugin_config["format1"] = "/(?<foo>foo)\n/"
|
17
|
-
plugin_config["format2"] = "/(?<bar>bar)/"
|
18
|
-
3.upto(Fluentd::Setting::InTail::MULTI_LINE_MAX_FORMAT_COUNT) do |i|
|
19
|
-
plugin_config["format#{i}"] = "//"
|
20
|
-
end
|
21
|
-
plugin_config
|
22
|
-
end
|
23
|
-
|
24
|
-
it "should include matches info" do
|
25
|
-
matches_info = {
|
26
|
-
whole: "foo\nbar\nbaz\n1\n2\n3\n4\n5\n6\n10\n11\n12",
|
27
|
-
matches: [
|
28
|
-
{
|
29
|
-
key: "foo", matched: "foo", pos: [0, 3]
|
30
|
-
},
|
31
|
-
{
|
32
|
-
key: "bar", matched: "bar", pos: [4, 7]
|
33
|
-
}
|
34
|
-
]
|
35
|
-
}
|
36
|
-
expect(subject[:matches]).to include matches_info
|
37
|
-
end
|
38
|
-
end
|
39
|
-
|
40
|
-
describe "detect only continuos patterns" do
|
41
|
-
let(:target_path) { File.expand_path("./spec/support/fixtures/error0.log", Rails.root) }
|
42
|
-
let(:plugin_config) do
|
43
|
-
plugin_config = {
|
44
|
-
"format_firstline" => "/foo/",
|
45
|
-
"time_format" => "time_format",
|
46
|
-
}
|
47
|
-
plugin_config["format1"] = "/(?<foo>foo)\n/"
|
48
|
-
plugin_config["format2"] = "/(?<bar>baz)/"
|
49
|
-
3.upto(Fluentd::Setting::InTail::MULTI_LINE_MAX_FORMAT_COUNT) do |i|
|
50
|
-
plugin_config["format#{i}"] = "//"
|
51
|
-
end
|
52
|
-
plugin_config
|
53
|
-
end
|
54
|
-
|
55
|
-
it "shouldn't match" do
|
56
|
-
expect(subject[:matches]).to eq []
|
57
|
-
end
|
58
|
-
end
|
59
|
-
|
60
|
-
describe "example on document" do
|
61
|
-
# http://docs.fluentd.org/articles/in_tail
|
62
|
-
let(:target_path) { File.expand_path("./spec/support/fixtures/multiline_example.log", Rails.root) }
|
63
|
-
|
64
|
-
let :plugin_config do
|
65
|
-
plugin_config = {
|
66
|
-
"format_firstline" => "/\\d{4}-\\d{1,2}-\\d{1,2}/",
|
67
|
-
"format1" => "/^(?<time>\\d{4}-\\d{1,2}-\\d{1,2} \\d{1,2}:\\d{1,2}:\\d{1,2}) \\[(?<thread>.*)\\] (?<level>[^\\s]+)(?<message>.*)/",
|
68
|
-
"time_format" => "%Y-%m-%d %H:%M:%S",
|
69
|
-
"keep_time_key" => true
|
70
|
-
}
|
71
|
-
2.upto(Fluentd::Setting::InTail::MULTI_LINE_MAX_FORMAT_COUNT) do |i|
|
72
|
-
plugin_config["format#{i}"] = "//"
|
73
|
-
end
|
74
|
-
plugin_config
|
75
|
-
end
|
76
|
-
|
77
|
-
it "should include matches info" do
|
78
|
-
matches_info = [
|
79
|
-
{
|
80
|
-
whole: "2013-3-03 14:27:33 [main] INFO Main - Start\n",
|
81
|
-
matches: [
|
82
|
-
{key: "time", matched: "2013-3-03 14:27:33", pos: [0, 18]},
|
83
|
-
{key: "thread", matched: "main", pos: [20, 24]},
|
84
|
-
{key: "level", matched: "INFO", pos: [26, 30]},
|
85
|
-
{key: "message", matched: " Main - Start\n", pos: [30, 45]}
|
86
|
-
]
|
87
|
-
},
|
88
|
-
{
|
89
|
-
whole: "2013-3-03 14:27:33 [main] ERROR Main - Exception\njavax.management.RuntimeErrorException: null\n at Main.main(Main.java:16) ~[bin/:na]\n",
|
90
|
-
matches: [
|
91
|
-
{key: "time", matched: "2013-3-03 14:27:33", pos: [0, 18]},
|
92
|
-
{key: "thread", matched: "main", pos: [20, 24]},
|
93
|
-
{key: "level", matched: "ERROR", pos: [26, 31]},
|
94
|
-
{key: "message", matched: " Main - Exception\njavax.management.RuntimeErrorException: null\n at Main.main(Main.java:16) ~[bin/:na]\n", pos: [31, 136]},
|
95
|
-
]
|
96
|
-
},
|
97
|
-
{
|
98
|
-
whole: "2013-3-03 14:27:33 [main] INFO Main - End",
|
99
|
-
matches: [
|
100
|
-
{key: "time", matched: "2013-3-03 14:27:33", pos: [0, 18]},
|
101
|
-
{key: "thread", matched: "main", pos: [20, 24]},
|
102
|
-
{key: "level", matched: "INFO", pos: [26, 30]},
|
103
|
-
{key: "message", matched: " Main - End", pos: [30, 42]},
|
104
|
-
]
|
105
|
-
}
|
106
|
-
]
|
107
|
-
expect(subject[:matches]).to eq matches_info
|
108
|
-
end
|
109
|
-
end
|
110
|
-
end
|
111
|
-
end
|