fluentd-ui 0.3.9 → 0.3.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (69) hide show
  1. data/ChangeLog +5 -0
  2. data/Gemfile +2 -0
  3. data/Gemfile.lock +52 -40
  4. data/README.md +21 -1
  5. data/app/assets/javascripts/enable_bootstrap_tooltip.js +3 -0
  6. data/app/assets/javascripts/vue/fluent_log.js +1 -1
  7. data/app/assets/stylesheets/common.css.scss +9 -0
  8. data/app/controllers/fluentd/settings/in_forward_controller.rb +9 -0
  9. data/app/controllers/fluentd/settings/in_http_controller.rb +9 -0
  10. data/app/controllers/fluentd/settings/in_monitor_agent_controller.rb +9 -0
  11. data/app/controllers/fluentd/settings/out_stdout_controller.rb +9 -0
  12. data/app/controllers/fluentd/settings_controller.rb +2 -0
  13. data/app/helpers/application_helper.rb +10 -0
  14. data/app/models/fluent_gem.rb +1 -1
  15. data/app/models/fluentd/agent/local_common.rb +3 -2
  16. data/app/models/fluentd/setting/in_forward.rb +44 -0
  17. data/app/models/fluentd/setting/in_http.rb +45 -0
  18. data/app/models/fluentd/setting/in_monitor_agent.rb +38 -0
  19. data/app/models/fluentd/setting/out_stdout.rb +37 -0
  20. data/app/views/fluentd/settings/source_and_output.html.haml +10 -28
  21. data/app/views/layouts/application.html.erb +7 -0
  22. data/bower.json +1 -1
  23. data/config/locales/translation_en.yml +31 -1
  24. data/config/locales/translation_ja.yml +35 -1
  25. data/config/routes.rb +16 -0
  26. data/docs/screenshots/02.png +0 -0
  27. data/docs/screenshots/dashboard.gif +0 -0
  28. data/docs/screenshots/fluentd-ui.gif +0 -0
  29. data/docs/screenshots/in_tail.gif +0 -0
  30. data/docs/screenshots/plugin.gif +0 -0
  31. data/docs/screenshots/setting.gif +0 -0
  32. data/lib/file_reverse_reader.rb +2 -1
  33. data/lib/fluentd-ui/version.rb +1 -1
  34. data/public/td-logo.png +0 -0
  35. data/spec/features/dashboard_spec.rb +42 -0
  36. data/spec/features/fluentd/setting/in_forward_spec.rb +7 -0
  37. data/spec/features/fluentd/setting/in_http_spec.rb +7 -0
  38. data/spec/features/fluentd/setting/in_monitor_agent_spec.rb +7 -0
  39. data/spec/features/fluentd/setting/out_stdout_spec.rb +7 -0
  40. data/spec/features/fluentd_status_spec.rb +36 -0
  41. data/spec/features/{fluentd/setting/out_elasticsearch_spec.rb → out_elasticsearch_spec.rb} +3 -13
  42. data/spec/features/{fluentd/setting/out_forward_spec.rb → out_forward_spec.rb} +2 -12
  43. data/spec/features/{fluentd/setting/out_td_spec.rb → out_td_spec.rb} +2 -12
  44. data/spec/features/sessions_spec.rb +6 -18
  45. data/spec/features/setting_spec.rb +33 -0
  46. data/spec/features/shared_examples/configurable_daemon_settings.rb +17 -0
  47. data/spec/features/{fluentd/setting/source_and_output_spec.rb → source_and_output_spec.rb} +2 -13
  48. data/spec/lib/file_reverse_reader_spec.rb +33 -13
  49. data/spec/models/fluent_gem_spec.rb +0 -6
  50. data/spec/models/fluentd/agent/local_common_spec.rb +29 -0
  51. data/spec/spec_helper.rb +3 -0
  52. data/spec/support/login_macro.rb +2 -2
  53. data/spec/support/stub_daemon.rb +12 -0
  54. data/vendor/assets/javascripts/bower/vue/.bower.json +5 -5
  55. data/vendor/assets/javascripts/bower/vue/dist/vue.js +200 -180
  56. data/vendor/assets/javascripts/bower/vue/dist/vue.min.js +3 -3
  57. data/vendor/assets/javascripts/bower/vue/src/api/lifecycle.js +3 -75
  58. data/vendor/assets/javascripts/bower/vue/src/compiler/transclude.js +9 -26
  59. data/vendor/assets/javascripts/bower/vue/src/directive.js +8 -7
  60. data/vendor/assets/javascripts/bower/vue/src/directives/component.js +3 -21
  61. data/vendor/assets/javascripts/bower/vue/src/directives/html.js +2 -1
  62. data/vendor/assets/javascripts/bower/vue/src/directives/repeat.js +16 -10
  63. data/vendor/assets/javascripts/bower/vue/src/instance/compile.js +116 -8
  64. data/vendor/assets/javascripts/bower/vue/src/observer/object.js +5 -14
  65. data/vendor/assets/javascripts/bower/vue/src/parsers/template.js +7 -5
  66. data/vendor/assets/javascripts/bower/vue/src/util/dom.js +21 -0
  67. data/vendor/assets/javascripts/bower/vue/src/util/merge-option.js +9 -12
  68. metadata +131 -52
  69. checksums.yaml +0 -7
@@ -9,6 +9,8 @@ en:
9
9
  fluentd_restart_failed: Failed to restart fluentd
10
10
  fluentd_start_stop_delay_notice: "'%{action} daemon' is accepted. That operation could take a minute for complete."
11
11
  password_successfully_updated: "Your password has been changed successfully."
12
+ fluentd_status_running: Running
13
+ fluentd_status_stopped: Stopped
12
14
 
13
15
  terms: &terms
14
16
  name: Name
@@ -97,8 +99,12 @@ en:
97
99
  page_title: "%{label}"
98
100
  setup_in_tail: File
99
101
  setup_in_syslog: Syslog Protocol
102
+ setup_in_monitor_agent: Monitoring Agent
103
+ setup_in_http: http
104
+ setup_in_forward: Forwarding (receiving from another fluentd)
100
105
  setup_out_td: Treasure Data
101
106
  setup_out_mongo: MongoDB
107
+ setup_out_stdout: stdout (log)
102
108
  setup_out_forward: Forwarding
103
109
  setup_out_s3: Amazon S3
104
110
  setup_out_elasticsearch: Elasticsearch
@@ -109,7 +115,7 @@ en:
109
115
  destroy_fluentd_setting: "Delete %{brand} setting"
110
116
  destroy_fluentd_setting_warning: |
111
117
  Delete %{brand} setting.
112
-
118
+
113
119
  <p>Running %{brand} will be stopped, but log and config file are still exists.</p>
114
120
  show:
115
121
  page_title: Dashboard
@@ -161,11 +167,35 @@ en:
161
167
  For each config parameter, please refer to the <a href="http://docs.fluentd.org/articles/out_mongo" target="_blank">MongoDB output plugin</a> documentation page.
162
168
  show:
163
169
  page_title: Add Output to MongoDB
170
+ out_stdout:
171
+ option_guide: |
172
+ Print events to STDOUT (or fluentd log file if launched with daemon mode). Please refer to the <a href="http://docs.fluentd.org/articles/out_stdout" target="_blank">stdout output plugin</a> documentation page.
173
+ show:
174
+ page_title: stdout (log)
164
175
  in_syslog:
165
176
  option_guide: |
166
177
  For each config parameter, please refer to the <a href="http://docs.fluentd.org/articles/in_syslog" target="_blank">MongoDB output plugin</a> documentation page.
167
178
  show:
168
179
  page_title: Add Input from Syslog Protocol
180
+ in_monitor_agent:
181
+ option_guide: |
182
+ Monitoring agent returns current fluentd/td-agent setting as JSON via HTTP. <br />
183
+ Please see refer to the <a target="_blank" href="http://docs.fluentd.org/articles/monitoring">Monitoring Agent</a> documentation page.
184
+ show:
185
+ page_title: Monitoring Agent (monitor_agent)
186
+ in_http:
187
+ option_guide: |
188
+ Retrieve records from http POST.<br />
189
+ The URL path becomes the tag of the Fluentd event log and the POSTed body element becomes the record itself.<br />
190
+ Please see refer to the <a target="_blank" href="http://docs.fluentd.org/articles/in_http">http Input Plugin</a> documentation page.
191
+ show:
192
+ page_title: Add http Input Plugin
193
+ in_forward:
194
+ option_guide: |
195
+ Listen to a TCP socket to receive the event stream and an UDP socket to receive heartbeat messages.
196
+ Please see refer to the <a target="_blank" href="http://docs.fluentd.org/articles/in_forward">forward Input Plugin</a> documentation page.
197
+ show:
198
+ page_title: Add forward Input Plugin
169
199
  in_tail_option_guide: |
170
200
  For each config parameter, please refer to the <a href="http://docs.fluentd.org/articles/in_tail" target="_blank">Tail input plugin</a> documentation page.
171
201
  in_tail:
@@ -9,6 +9,8 @@ ja:
9
9
  fluentd_restart_failed: "%{brand}の再起動に失敗しました。"
10
10
  fluentd_start_stop_delay_notice: "デーモンの%{action}を受け付けました。処理が完了するまで時間がかかる場合があります。"
11
11
  password_successfully_updated: "パスワードを変更しました。"
12
+ fluentd_status_running: 稼働中
13
+ fluentd_status_stopped: 停止中
12
14
 
13
15
  terms: &terms
14
16
  name: アカウント名
@@ -96,7 +98,11 @@ ja:
96
98
  page_title: "%{label}"
97
99
  setup_in_tail: ファイル
98
100
  setup_in_syslog: syslogプロトコル
101
+ setup_in_monitor_agent: 監視エージェント
102
+ setup_in_http: http
103
+ setup_in_forward: 転送(他Fluentdからの受信)
99
104
  setup_out_td: Treasure Data
105
+ setup_out_stdout: 標準出力(ログ)
100
106
  setup_out_mongo: MongoDB
101
107
  setup_out_forward: 転送
102
108
  setup_out_s3: AWS S3
@@ -108,7 +114,7 @@ ja:
108
114
  destroy_fluentd_setting: "%{brand}の設定情報を削除"
109
115
  destroy_fluentd_setting_warning: |
110
116
  %{brand}の設定を削除します。
111
-
117
+
112
118
  <p>起動中の%{brand}は停止し、ログや設定ファイルはそのまま残存します。</p>
113
119
  show:
114
120
  page_title: "ダッシュボード"
@@ -162,11 +168,39 @@ ja:
162
168
  <a target="_blank" href="http://docs.fluentd.org/ja/articles/out_mongo">out_mongoプラグインの解説</a>もご参照ください。
163
169
  show:
164
170
  page_title: MongoDB書き出し設定
171
+ out_stdout:
172
+ option_guide: |
173
+ 標準出力(デーモンとして起動しているときはログファイル)へイベントを書き出します。<br />
174
+ <a target="_blank" href="http://docs.fluentd.org/ja/articles/out_stdout">out_stdoutプラグインの解説</a>もご参照ください。
175
+ show:
176
+ page_title: 標準出力(ログ)
165
177
  in_syslog:
166
178
  option_guide: |
167
179
  <a target="_blank" href="http://docs.fluentd.org/ja/articles/in_syslog">in_syslogプラグイン解説ページ</a>もご参照ください。
168
180
  show:
169
181
  page_title: Syslog読み込み設定
182
+ in_monitor_agent:
183
+ option_guide: |
184
+ HTTP経由で現在稼働中のfluentdが使用しているconfigやプラグインをJSONやLTSV形式で取得できます。<br />
185
+ <a target="_blank" href="http://docs.fluentd.org/ja/articles/monitoring">監視エージェント</a>のページもご参照ください。
186
+ show:
187
+ page_title: 監視エージェント設定(monitor_agent)
188
+ in_http:
189
+ option_guide: |
190
+ http POSTからレコードを取得可能にします。<br />
191
+ URLパスはFluentdイベントログのタグとなり、ポストされたbody要素はレコードそのものになります。<br />
192
+ <a target="_blank" href="http://docs.fluentd.org/ja/articles/in_http">httpインプットプラグイン解説ページ</a>もご参照ください。
193
+ show:
194
+ page_title: http入力設定
195
+ in_forward:
196
+ option_guide: |
197
+ TCPソケットをリッスンし、イベントストリームを受信します。<br />
198
+ UDPソケットもリッスンし、ハートビートメッセージを受信します。<br />
199
+ 他のFluentdインスタンス、fluent-catコマンドまたはクライアントライブラリーからイベントログを受信するために使用されます。<br />
200
+ <a target="_blank" href="http://docs.fluentd.org/ja/articles/in_forward">forwardインプットプラグイン解説ページ</a>もご参照ください。
201
+ show:
202
+ page_title: forward入力設定
203
+
170
204
  in_tail_option_guide: |
171
205
  <a target="_blank" href="http://docs.fluentd.org/ja/articles/in_tail">in_tailプラグインの解説ページ</a>や
172
206
  <a target="_blank" href="http://fluentular.herokuapp.com/">Fluentular</a>もご参照ください。
data/config/routes.rb CHANGED
@@ -28,6 +28,22 @@ Rails.application.routes.draw do
28
28
  post "finish"
29
29
  end
30
30
 
31
+ resource :in_monitor_agent, only: [:show], module: :settings, controller: :in_monitor_agent do
32
+ post "finish"
33
+ end
34
+
35
+ resource :in_http, only: [:show], module: :settings, controller: :in_http do
36
+ post "finish"
37
+ end
38
+
39
+ resource :in_forward, only: [:show], module: :settings, controller: :in_forward do
40
+ post "finish"
41
+ end
42
+
43
+ resource :out_stdout, only: [:show], module: :settings, controller: :out_stdout do
44
+ post "finish"
45
+ end
46
+
31
47
  resource :out_mongo, only: [:show], module: :settings, controller: :out_mongo do
32
48
  post "finish"
33
49
  end
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
@@ -36,7 +36,7 @@ class FileReverseReader
36
36
 
37
37
  def binary_file?
38
38
  sample = io.read(1024) || ""
39
- !sample.force_encoding('us-ascii').valid_encoding?
39
+ !sample.force_encoding('utf-8').valid_encoding?
40
40
  ensure
41
41
  io.rewind
42
42
  end
@@ -44,6 +44,7 @@ class FileReverseReader
44
44
  private
45
45
 
46
46
  def split_each_line(buf, &block)
47
+ return unless buf.force_encoding('utf-8').valid_encoding?
47
48
  buf.split($/).reverse.each do |line|
48
49
  block.call(line)
49
50
  end
@@ -1,3 +1,3 @@
1
1
  module FluentdUI
2
- VERSION = "0.3.9"
2
+ VERSION = "0.3.10"
3
3
  end
Binary file
@@ -0,0 +1,42 @@
1
+ require 'spec_helper'
2
+
3
+ describe 'dashboard' do
4
+ let!(:exists_user) { build(:user) }
5
+
6
+ before { login_with exists_user }
7
+
8
+ context 'no configuration' do
9
+ before { visit '/' }
10
+
11
+ it do
12
+ page.should have_css('h1', text: 'fluentd')
13
+ page.should have_link(I18n.t('terms.setup', target: 'fluentd'))
14
+ page.should have_link(I18n.t('terms.setup', target: 'td-agent'))
15
+ end
16
+ end
17
+
18
+ context 'fluentd is stop', stub: :daemon do
19
+ before { visit '/' }
20
+
21
+ it do
22
+ page.should have_css('h1', text: I18n.t('fluentd.show.page_title'))
23
+ page.should have_css('h4', text: I18n.t('fluentd.common.stopped'))
24
+ page.should have_css('h4', text: I18n.t('fluentd.common.fluentd_info'))
25
+ end
26
+ end
27
+
28
+ context 'fluentd is running', stub: :daemon do
29
+ before do
30
+ # XXX i have no idea to not use stub...
31
+ Fluentd::Agent::TdAgent.any_instance.stub(:running?).and_return(true)
32
+
33
+ visit '/'
34
+ end
35
+
36
+ it do
37
+ page.should have_css('h1', text: I18n.t('fluentd.show.page_title'))
38
+ page.should have_css('h4', text: I18n.t('fluentd.common.running'))
39
+ page.should have_css('h4', text: I18n.t('fluentd.common.fluentd_info'))
40
+ end
41
+ end
42
+ end
@@ -0,0 +1,7 @@
1
+ require "spec_helper"
2
+
3
+ describe "in_forward", stub: :daemon do
4
+ before { login_with exists_user }
5
+ it_should_behave_like "configurable daemon settings", "in_forward", "port", "12345"
6
+
7
+ end
@@ -0,0 +1,7 @@
1
+ require "spec_helper"
2
+
3
+ describe "in_http", stub: :daemon do
4
+ before { login_with exists_user }
5
+ it_should_behave_like "configurable daemon settings", "in_http", "port", "12345"
6
+
7
+ end
@@ -0,0 +1,7 @@
1
+ require "spec_helper"
2
+
3
+ describe "in_monitor_agent", stub: :daemon do
4
+ before { login_with exists_user }
5
+ it_should_behave_like "configurable daemon settings", "in_monitor_agent", "port", "12345"
6
+
7
+ end
@@ -0,0 +1,7 @@
1
+ require "spec_helper"
2
+
3
+ describe "out_stdout", stub: :daemon do
4
+ before { login_with exists_user }
5
+ it_should_behave_like "configurable daemon settings", "out_stdout", "match", "stdout.**"
6
+
7
+ end
@@ -0,0 +1,36 @@
1
+ require 'spec_helper'
2
+
3
+ describe 'dashboard' do
4
+ let!(:exists_user) { build(:user) }
5
+
6
+ before { login_with exists_user }
7
+
8
+ context 'no configuration' do
9
+ before { visit '/' }
10
+
11
+ it do
12
+ page.should_not have_css(".fluentd-status")
13
+ end
14
+ end
15
+
16
+ context 'fluentd is stop', stub: :daemon do
17
+ before { visit '/' }
18
+
19
+ it do
20
+ page.should have_css(".fluentd-status .stopped")
21
+ end
22
+ end
23
+
24
+ context 'fluentd is running', stub: :daemon do
25
+ before do
26
+ # XXX i have no idea to not use stub...
27
+ Fluentd::Agent::TdAgent.any_instance.stub(:running?).and_return(true)
28
+
29
+ visit '/'
30
+ end
31
+
32
+ it do
33
+ page.should have_css(".fluentd-status .running")
34
+ end
35
+ end
36
+ end
@@ -1,22 +1,12 @@
1
1
  require "spec_helper"
2
2
 
3
- describe "out_elasticsearch" do
3
+ describe "out_elasticsearch", stub: :daemon do
4
4
  let(:exists_user) { build(:user) }
5
- let(:daemon) { build(:fluentd, variant: "td-agent") }
6
- let(:match) { "test.out_elasticsearch.#{Time.now.to_i}.*" }
5
+ let(:match) { "test.out_forward.#{Time.now.to_i}.*" }
7
6
  let(:location) { daemon_setting_out_elasticsearch_path }
8
7
 
9
8
  before do
10
- Fluentd.stub(:instance).and_return(daemon)
11
- Fluentd::Agent::TdAgent.any_instance.stub(:detached_command).and_return(true)
12
- daemon.agent.config_write ""
13
-
14
- visit '/sessions/new'
15
- within("form") do
16
- fill_in 'session_name', :with => exists_user.name
17
- fill_in 'session_password', :with => exists_user.password
18
- end
19
- click_button I18n.t("terms.sign_in")
9
+ login_with exists_user
20
10
  end
21
11
 
22
12
  it "Shown form" do
@@ -1,21 +1,11 @@
1
1
  require "spec_helper"
2
2
 
3
- describe "out_forward" do
3
+ describe "out_forward", stub: :daemon do
4
4
  let(:exists_user) { build(:user) }
5
- let(:daemon) { build(:fluentd, variant: "td-agent") }
6
5
  let(:match) { "test.out_forward.#{Time.now.to_i}.*" }
7
6
 
8
7
  before do
9
- Fluentd.stub(:instance).and_return(daemon)
10
- Fluentd::Agent::TdAgent.any_instance.stub(:detached_command).and_return(true)
11
- daemon.agent.config_write ""
12
-
13
- visit '/sessions/new'
14
- within("form") do
15
- fill_in 'session_name', :with => exists_user.name
16
- fill_in 'session_password', :with => exists_user.password
17
- end
18
- click_button I18n.t("terms.sign_in")
8
+ login_with exists_user
19
9
  end
20
10
 
21
11
  it "Shown form" do
@@ -1,21 +1,11 @@
1
1
  require "spec_helper"
2
2
 
3
- describe "out_td" do
3
+ describe "out_td", stub: :daemon do
4
4
  let(:exists_user) { build(:user) }
5
- let(:daemon) { build(:fluentd, variant: "td-agent") }
6
5
  let(:api_key) { "dummydummy" }
7
6
 
8
7
  before do
9
- Fluentd.stub(:instance).and_return(daemon)
10
- Fluentd::Agent::TdAgent.any_instance.stub(:detached_command).and_return(true)
11
- daemon.agent.config_write ""
12
-
13
- visit '/sessions/new'
14
- within("form") do
15
- fill_in 'session_name', :with => exists_user.name
16
- fill_in 'session_password', :with => exists_user.password
17
- end
18
- click_button I18n.t("terms.sign_in")
8
+ login_with exists_user
19
9
  end
20
10
 
21
11
  it "Shown form with filled in td.*.* on match" do
@@ -1,3 +1,5 @@
1
+ require 'spec_helper'
2
+
1
3
  describe "sessions" do
2
4
  let(:exists_user) { build(:user) }
3
5
  let(:submit_label) { I18n.t("terms.sign_in") }
@@ -5,12 +7,7 @@ describe "sessions" do
5
7
 
6
8
  describe "sign in with default password" do
7
9
  before do
8
- visit '/sessions/new'
9
- within("form") do
10
- fill_in 'session_name', :with => user.name
11
- fill_in 'session_password', :with => user.password
12
- end
13
- click_button submit_label
10
+ login_with user
14
11
  end
15
12
 
16
13
  context "correct credentials" do
@@ -40,12 +37,8 @@ describe "sessions" do
40
37
 
41
38
  before do
42
39
  exists_user.update_attributes(current_password: Settings.default_password, password: new_password, password_confirmation: new_password)
43
- visit '/sessions/new'
44
- within("form") do
45
- fill_in 'session_name', :with => user.name
46
- fill_in 'session_password', :with => user.password
47
- end
48
- click_button submit_label
40
+
41
+ login_with user
49
42
  end
50
43
 
51
44
  after do
@@ -71,12 +64,7 @@ describe "sessions" do
71
64
  describe "sign out process" do
72
65
  let(:submit_label) { I18n.t("terms.sign_in") }
73
66
  before do
74
- visit '/sessions/new'
75
- within("form") do
76
- fill_in 'session_name', :with => exists_user.name
77
- fill_in 'session_password', :with => exists_user.password
78
- end
79
- click_button submit_label
67
+ login_with exists_user
80
68
  end
81
69
 
82
70
  before do
@@ -0,0 +1,33 @@
1
+ require 'spec_helper'
2
+
3
+ describe 'setting', stub: :daemon do
4
+ let!(:exists_user) { build(:user) }
5
+
6
+ before do
7
+ login_with exists_user
8
+
9
+ daemon.agent.config_write 'GREAT CONFIG HERE'
10
+
11
+ visit '/daemon/setting'
12
+ end
13
+
14
+ it 'shows setting' do
15
+ page.should have_css('h1', text: I18n.t('fluentd.settings.show.page_title'))
16
+ page.should have_link(I18n.t('terms.edit'))
17
+ page.should have_css('pre', text: 'GREAT CONFIG HERE')
18
+ end
19
+
20
+ it 'edits setting' do
21
+ click_link I18n.t('terms.edit')
22
+
23
+ page.should have_css('h1', text: I18n.t('fluentd.settings.edit.page_title'))
24
+ page.should have_css('p.text-danger', text: I18n.t('terms.notice_restart_for_config_edit', brand: 'fluentd'))
25
+
26
+ fill_in 'config', with: 'YET ANOTHER CONFIG'
27
+
28
+ click_button I18n.t('terms.update')
29
+
30
+ current_path.should == '/daemon/setting'
31
+ page.should have_css('pre', text: 'YET ANOTHER CONFIG')
32
+ end
33
+ end
@@ -0,0 +1,17 @@
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=\"fluentd_setting_#{type}[#{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("#new_fluentd_setting_#{type}") 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,21 +1,10 @@
1
1
  require "spec_helper"
2
2
 
3
- describe "source_and_output", js: true do
3
+ describe "source_and_output", js: true, stub: :daemon do
4
4
  let(:exists_user) { build(:user) }
5
- let(:daemon) { build(:fluentd, variant: "td-agent") }
6
5
 
7
6
  before do
8
- Fluentd.stub(:instance).and_return(daemon)
9
- Fluentd::Agent::TdAgent.any_instance.stub(:detached_command).and_return(true)
10
- end
11
-
12
- before do
13
- visit '/sessions/new'
14
- within("form") do
15
- fill_in 'session_name', :with => exists_user.name
16
- fill_in 'session_password', :with => exists_user.password
17
- end
18
- click_button I18n.t("terms.sign_in")
7
+ login_with exists_user
19
8
  end
20
9
 
21
10
  before do
@@ -1,3 +1,5 @@
1
+ # coding: utf-8
2
+
1
3
  require "enumerator"
2
4
  require 'spec_helper'
3
5
 
@@ -50,23 +52,41 @@ describe FileReverseReader do
50
52
 
51
53
  describe "#tail" do
52
54
  let(:logfile) { File.expand_path("./tmp/log.log", Rails.root) }
53
- let(:log_lines) { 100 }
54
- before { File.open(logfile, "w"){|f| f.write("foo\n" * log_lines) } }
55
- subject { instance.tail(count) }
55
+ before { File.open(logfile, "wb"){|f| f.write(content) } }
56
56
 
57
- context "2" do
58
- let(:count) { 2 }
59
- it { subject.to_a.size.should == count }
60
- end
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
61
71
 
62
- context "50" do
63
- let(:count) { 50 }
64
- it { subject.to_a.size.should == count }
72
+ context "over log lines" do
73
+ let(:count) { log_lines + 100 }
74
+ it { subject.to_a.size.should == log_lines }
75
+ end
65
76
  end
66
77
 
67
- context "over log lines" do
68
- let(:count) { log_lines + 100 }
69
- it { subject.to_a.size.should == log_lines }
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
70
90
  end
71
91
  end
72
92
  end
@@ -64,12 +64,6 @@ describe FluentGem do
64
64
  GEM
65
65
  it { subject.to_a.should == gem_list.lines.to_a }
66
66
  end
67
-
68
- context "failed" do
69
- let(:gem_list) { "" }
70
- before { $?.stub(:exitstatus).and_return(128) }
71
- it { expect{ subject }.to raise_error(FluentGem::GemError) }
72
- end
73
67
  end
74
68
 
75
69
  describe "#run" do
@@ -0,0 +1,29 @@
1
+ require 'spec_helper'
2
+ require 'fileutils'
3
+
4
+ describe 'Fluentd::Agent::LocalCommon' do
5
+ subject { target_class.new.tap{|t| t.pid_file = pid_file_path} }
6
+
7
+ let!(:target_class) { Struct.new(:pid_file){ include Fluentd::Agent::LocalCommon } }
8
+ let!(:pid_file_path) { Rails.root.join('tmp', 'fluentd-test', 'local_common_test.pid').to_s }
9
+
10
+ describe '#pid' do
11
+ context 'no pid file exists' do
12
+ its(:pid) { should be_nil }
13
+ end
14
+
15
+ context 'empty pid file given' do
16
+ before { FileUtils.touch pid_file_path }
17
+ after { FileUtils.rm pid_file_path }
18
+
19
+ its(:pid) { should be_nil }
20
+ end
21
+
22
+ context 'valid pid file given' do
23
+ before { File.write pid_file_path, '9999' }
24
+ after { FileUtils.rm pid_file_path }
25
+
26
+ its(:pid) { should eq(9999) }
27
+ end
28
+ end
29
+ end
data/spec/spec_helper.rb CHANGED
@@ -12,10 +12,12 @@ end
12
12
  ENV["RAILS_ENV"] ||= 'test'
13
13
  require File.expand_path("../../config/environment", __FILE__)
14
14
  require 'rspec/rails'
15
+ require 'rspec/its'
15
16
  require 'webmock/rspec'
16
17
  WebMock.disable_net_connect!(allow_localhost: true)
17
18
  require 'capybara/poltergeist'
18
19
  Capybara.javascript_driver = :poltergeist
20
+ require 'capybara-screenshot/rspec'
19
21
 
20
22
  # Requires supporting ruby files with custom matchers and macros, etc,
21
23
  # in spec/support/ and its subdirectories.
@@ -35,6 +37,7 @@ RSpec.configure do |config|
35
37
  config.include FactoryGirl::Syntax::Methods
36
38
  config.include LoginMacro
37
39
  config.include JavascriptMacro
40
+ config.include StubDaemon
38
41
 
39
42
  # If true, the base class of anonymous controllers will be inferred
40
43
  # automatically. This will be the default behavior in future versions of
@@ -2,8 +2,8 @@ module LoginMacro
2
2
  def login_with(user)
3
3
  visit '/sessions/new'
4
4
  within("form") do
5
- fill_in 'session_name', :with => exists_user.name
6
- fill_in 'session_password', :with => exists_user.password
5
+ fill_in 'session_name', :with => user.name
6
+ fill_in 'session_password', :with => user.password
7
7
  end
8
8
  click_button I18n.t("terms.sign_in")
9
9
  end