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.

Files changed (136) hide show
  1. checksums.yaml +4 -4
  2. data/ChangeLog.md +24 -0
  3. data/Gemfile +5 -3
  4. data/Gemfile.lock +88 -75
  5. data/README.md +11 -0
  6. data/Rakefile +1 -1
  7. data/app/javascript/packs/aws_credential.js +1 -1
  8. data/app/javascript/packs/in_tail_parse.js +1 -1
  9. data/app/javascript/packs/owned_plugin_form.js +1 -1
  10. data/app/javascript/packs/settings.js +20 -9
  11. data/app/javascript/packs/transport_config.js +1 -1
  12. data/app/javascript/packs/transport_section.js +1 -1
  13. data/app/javascript/packs/treeview.js +2 -2
  14. data/app/models/plugin.rb +2 -2
  15. data/app/views/fluentd/settings/source_and_output.html.haml +12 -10
  16. data/app/views/layouts/application.html.erb +3 -0
  17. data/app/views/plugins/recommended.html.haml +3 -0
  18. data/app/views/plugins/updated.html.haml +5 -6
  19. data/config.ru +3 -1
  20. data/config/application.rb +1 -1
  21. data/config/application.yml +104 -31
  22. data/config/locales/translation_en.yml +1 -0
  23. data/config/locales/translation_ja.yml +1 -0
  24. data/gemfiles/ruby2.2.gemfile +2 -1
  25. data/lib/fluentd-ui/version.rb +1 -1
  26. data/test/application_system_test_case.rb +8 -0
  27. data/test/controllers/application_controller_test.rb +42 -0
  28. data/test/controllers/fluentd/agents_controller_test.rb +39 -0
  29. data/test/controllers/misc_controller_test.rb +70 -0
  30. data/test/controllers/polling_controller_test.rb +29 -0
  31. data/test/decorators/plugin_decorator_test.rb +26 -0
  32. data/{spec → test}/factories/fluentd.rb +0 -0
  33. data/{spec → test}/factories/plugins.rb +0 -0
  34. data/{spec → test}/factories/user.rb +0 -0
  35. data/{spec/support → test}/fixtures/error0.log +0 -0
  36. data/{spec/support → test}/fixtures/error2.log +0 -0
  37. data/{spec/support → test}/fixtures/error3.log +0 -0
  38. data/{spec/support → test}/fixtures/error4.log +0 -0
  39. data/{spec/support → test}/fixtures/multiline_example.log +0 -0
  40. data/test/integration/dashboard_test.rb +57 -0
  41. data/test/integration/fluentd/setting/histories_test.rb +139 -0
  42. data/test/integration/fluentd/setting/notes_test.rb +27 -0
  43. data/test/integration/fluentd/setting/running_backup_test.rb +65 -0
  44. data/test/integration/fluentd_ui_update_checking_test.rb +27 -0
  45. data/test/integration/sesstions_test.rb +56 -0
  46. data/test/integration/setting_test.rb +126 -0
  47. data/test/integration/users_test.rb +43 -0
  48. data/test/lib/filte_reverse_reader_test.rb +63 -0
  49. data/test/lib/fluentd_ui_test.rb +36 -0
  50. data/test/lib/regexp_preview/multi_line_test.rb +86 -0
  51. data/test/lib/regexp_preview/single_line_test.rb +87 -0
  52. data/test/models/fluent_gem_test.rb +76 -0
  53. data/test/models/fluentd/agent_test.rb +331 -0
  54. data/{spec/models/fluentd/setting/in_forward_spec.rb → test/models/fluentd/setting/in_forward_test.rb} +32 -44
  55. data/test/models/fluentd/setting/in_http_test.rb +30 -0
  56. data/test/models/fluentd/setting/in_monitor_agent_test.rb +30 -0
  57. data/test/models/fluentd/setting/in_syslog_test.rb +88 -0
  58. data/test/models/fluentd/setting/in_tail_test.rb +52 -0
  59. data/test/models/fluentd/setting/out_elasticsearch_test.rb +32 -0
  60. data/test/models/fluentd/setting/out_mongo_test.rb +61 -0
  61. data/test/models/fluentd/setting/out_s3_test.rb +112 -0
  62. data/test/models/fluentd/setting/out_stdout_test.rb +32 -0
  63. data/test/models/fluentd/setting/out_tdlog_test.rb +60 -0
  64. data/test/models/fluentd_log_test.rb +140 -0
  65. data/test/models/fluentd_test.rb +185 -0
  66. data/test/models/plugin_test.rb +144 -0
  67. data/test/models/user_test.rb +48 -0
  68. data/test/support/config_histories.rb +72 -0
  69. data/test/support/configurable_daemon_settings.rb +26 -0
  70. data/test/support/login_macro.rb +12 -0
  71. data/test/support/login_required.rb +8 -0
  72. data/test/support/stub_daemon.rb +14 -0
  73. data/test/system/fluentd/setting/in_forward_test.rb +13 -0
  74. data/test/system/fluentd/setting/in_http_test.rb +13 -0
  75. data/test/system/fluentd/setting/in_monitor_agent.rb +13 -0
  76. data/test/system/fluentd/setting/out_elasticsearch_test.rb +32 -0
  77. data/test/system/fluentd/setting/out_forward_test.rb +41 -0
  78. data/test/system/fluentd/setting/out_stdout_test.rb +15 -0
  79. data/test/system/fluentd/setting/out_tdlog_test.rb +15 -0
  80. data/test/system/source_and_output_test.rb +184 -0
  81. data/test/test_helper.rb +34 -0
  82. metadata +147 -161
  83. data/spec/controllers/application_controller_spec.rb +0 -84
  84. data/spec/controllers/fluentd/agents_controller_spec.rb +0 -61
  85. data/spec/controllers/misc_controller_spec.rb +0 -68
  86. data/spec/controllers/polling_controller_spec.rb +0 -39
  87. data/spec/controllers/sessions_controller_spec.rb +0 -5
  88. data/spec/decorators/plugin_decorator_spec.rb +0 -37
  89. data/spec/features/dashboard_spec.rb +0 -42
  90. data/spec/features/fluentd/setting/histories_spec.rb +0 -110
  91. data/spec/features/fluentd/setting/in_forward_spec.rb +0 -6
  92. data/spec/features/fluentd/setting/in_http_spec.rb +0 -6
  93. data/spec/features/fluentd/setting/in_monitor_agent_spec.rb +0 -6
  94. data/spec/features/fluentd/setting/notes_spec.rb +0 -27
  95. data/spec/features/fluentd/setting/out_forward_spec.rb +0 -38
  96. data/spec/features/fluentd/setting/out_stdout_spec.rb +0 -6
  97. data/spec/features/fluentd/setting/running_backup_spec.rb +0 -106
  98. data/spec/features/fluentd_status_spec.rb +0 -36
  99. data/spec/features/fluentd_ui_update_available_spec.rb +0 -33
  100. data/spec/features/out_elasticsearch_spec.rb +0 -28
  101. data/spec/features/out_forward_spec.rb +0 -36
  102. data/spec/features/out_tdlog_spec.rb +0 -26
  103. data/spec/features/sessions_spec.rb +0 -79
  104. data/spec/features/setting_spec.rb +0 -95
  105. data/spec/features/shared_examples/configurable_daemon_settings.rb +0 -17
  106. data/spec/features/shared_examples/login_required.rb +0 -4
  107. data/spec/features/source_and_output_spec.rb +0 -158
  108. data/spec/features/users_spec.rb +0 -53
  109. data/spec/grok_converter_spec.rb +0 -50
  110. data/spec/lib/file_reverse_reader_spec.rb +0 -93
  111. data/spec/lib/fluentd-ui_spec.rb +0 -35
  112. data/spec/lib/regexp_preview/multi_line_spec.rb +0 -111
  113. data/spec/lib/regexp_preview/single_line_spec.rb +0 -185
  114. data/spec/models/fluent_gem_spec.rb +0 -104
  115. data/spec/models/fluentd/agent/common_spec.rb +0 -82
  116. data/spec/models/fluentd/agent_spec.rb +0 -134
  117. data/spec/models/fluentd/setting/in_http_spec.rb +0 -31
  118. data/spec/models/fluentd/setting/in_monitor_agent_spec.rb +0 -31
  119. data/spec/models/fluentd/setting/in_syslog_spec.rb +0 -98
  120. data/spec/models/fluentd/setting/in_tail_spec.rb +0 -53
  121. data/spec/models/fluentd/setting/out_elasticsearch_spec.rb +0 -31
  122. data/spec/models/fluentd/setting/out_mongo_spec.rb +0 -62
  123. data/spec/models/fluentd/setting/out_s3_spec.rb +0 -128
  124. data/spec/models/fluentd/setting/out_stdout_spec.rb +0 -31
  125. data/spec/models/fluentd/setting/out_tdlog_spec.rb +0 -46
  126. data/spec/models/fluentd_log_spec.rb +0 -171
  127. data/spec/models/fluentd_spec.rb +0 -164
  128. data/spec/models/plugin_spec.rb +0 -191
  129. data/spec/models/user_spec.rb +0 -59
  130. data/spec/spec_helper.rb +0 -85
  131. data/spec/support/config_histories.rb +0 -57
  132. data/spec/support/fluentd_agent_common_behavior.rb +0 -181
  133. data/spec/support/fluentd_agent_restart_strategy.rb +0 -94
  134. data/spec/support/javascript_macro.rb +0 -21
  135. data/spec/support/login_macro.rb +0 -10
  136. data/spec/support/stub_daemon.rb +0 -12
@@ -1,61 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe Fluentd::AgentsController do
4
- let(:log) { double('log').as_null_object }
5
-
6
- before do
7
- allow(controller).to receive(:current_user).and_return true
8
- allow(controller).to receive(:find_fluentd).and_return(nil)
9
- controller.instance_variable_set(:@fluentd, double(agent: @agent = double(:agent)))
10
- end
11
-
12
- describe "when the action succeeds" do
13
- it "stops" do
14
- expect(@agent).to receive(:stop).and_return true
15
- put :stop
16
- end
17
-
18
- it "starts" do
19
- expect(@agent).to receive(:start).and_return true
20
- put :start
21
- end
22
-
23
- it "restarts" do
24
- expect(@agent).to receive(:restart).and_return true
25
- put :restart
26
- end
27
-
28
- it "reaload" do
29
- expect(@agent).to receive(:reload).and_return true
30
- put :reload
31
- end
32
- end
33
-
34
- describe "when the action does not succeed" do
35
- it "stops" do
36
- expect(@agent).to receive(:stop).and_return false
37
- put :stop
38
- end
39
-
40
- it "starts" do
41
- expect(@agent).to receive(:start).and_return false
42
- expect(@agent).to receive(:log).and_return(log)
43
- expect(log).to receive(:tail).with(1)
44
- put :start
45
- end
46
-
47
- it "restarts" do
48
- expect(@agent).to receive(:restart).and_return false
49
- expect(@agent).to receive(:log).and_return(log)
50
- expect(log).to receive(:tail).with(1)
51
- put :restart
52
- end
53
-
54
- it "reload" do
55
- expect(@agent).to receive(:reload).and_return false
56
- expect(@agent).to receive(:log).and_return(log)
57
- expect(log).to receive(:tail).with(1)
58
- put :reload
59
- end
60
- end
61
- end
@@ -1,68 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe MiscController do
4
- let(:instance) { Fluentd.new(id: nil, variant: "fluentd_gem", log_file: "dummy.log", pid_file: "dummy.pid", config_file: "dummy.conf") }
5
-
6
- class DummyAagent
7
- def log
8
- Struct.new(:read).new(read: "dummy_log_content")
9
- end
10
-
11
- def version
12
- "dummy version"
13
- end
14
- end
15
-
16
- let!(:dummy_agent) { DummyAagent.new }
17
- let!(:fluentd_log_content) { dummy_agent.log.read }
18
- let!(:fluentd_version) { dummy_agent.version }
19
- let(:fluentd_ui_log_content) { <<-LOG.strip_heredoc }
20
- log1
21
- log2
22
- log3
23
- LOG
24
-
25
- let!(:dummy_log_path) { "tmp/dummy.log" }
26
- let!(:expand_dir) { Rails.root.join("tmp/system_info") }
27
-
28
- before do
29
- allow(controller).to receive(:current_user).and_return true
30
-
31
- #dummy log for fluentd-ui.log
32
- File.open(dummy_log_path, 'w') { |file| file.write(fluentd_ui_log_content) }
33
- controller.stub(:log_path) { dummy_log_path }
34
-
35
- instance.stub(:agent).and_return(dummy_agent)
36
- Fluentd.stub(:instance).and_return(instance)
37
- end
38
-
39
- describe 'download_info' do
40
- before do
41
- get 'download_info'
42
-
43
- #expand files in zip
44
- Zip::File.open(Rails.root.join("tmp/system_info.zip")) do |zip_file|
45
- FileUtils.mkdir_p(expand_dir)
46
-
47
- zip_file.each do |f|
48
- f_path = File.join(expand_dir, f.name)
49
- zip_file.extract(f, f_path) unless File.exist?(f_path)
50
- end
51
- end
52
- end
53
-
54
- #remove all temp files for this spec
55
- after do
56
- FileUtils.rm Rails.root.join("tmp/system_info.zip")
57
- FileUtils.rm_r expand_dir
58
- FileUtils.rm dummy_log_path
59
- end
60
-
61
- it 'write files' do
62
- expect(File.read(File.join(expand_dir, "fluentd.log"))).to eq "#{fluentd_log_content}\n"
63
- expect(File.read(File.join(expand_dir, "fluentd-ui.log"))).to eq "#{fluentd_ui_log_content}"
64
- expect(File.read(File.join(expand_dir, "env.txt"))).to match "RAILS_ENV=test"
65
- expect(File.read(File.join(expand_dir, "versions.txt"))).to match "fluentd: #{fluentd_version}"
66
- end
67
- end
68
- end
@@ -1,39 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe PollingController do
4
- describe 'polling for alerts' do
5
- before do
6
- allow(controller).to receive(:current_user).and_return true
7
- end
8
-
9
- after do
10
- response.should be_successful
11
- end
12
-
13
- it 'may find nothing' do
14
- expect(controller).to receive(:uninstalling_gems).and_return []
15
- expect(controller).to receive(:installing_gems).and_return []
16
- get :alerts
17
- end
18
-
19
- it 'may find gems being uninstalled' do
20
- expect(controller).to receive(:uninstalling_gems).and_return [
21
- double(gem_name: "foobar", version: "1.0.0")
22
- ]
23
-
24
- allow(controller).to receive(:installing_gems).and_return []
25
-
26
- get :alerts
27
- end
28
-
29
- it 'may find gems being installed' do
30
- expect(controller).to receive(:installing_gems).and_return [
31
- double(gem_name: "bazbang", version: "0.0.1")
32
- ]
33
-
34
- allow(controller).to receive(:uninstalling_gems).and_return []
35
-
36
- get :alerts
37
- end
38
- end
39
- end
@@ -1,5 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe SessionsController do
4
-
5
- end
@@ -1,37 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe PluginDecorator do
4
- let(:decorated_plugin) { build(:plugin).decorate }
5
-
6
- describe "#status" do
7
- subject { decorated_plugin.status }
8
-
9
- context "plugin is processing" do
10
- before { decorated_plugin.stub(:processing?).and_return(true) }
11
-
12
- it "returns the term for processing" do
13
- expect(subject).to eq I18n.t("terms.processing")
14
- end
15
- end
16
-
17
- context "plugin isn't while processing" do
18
- before { decorated_plugin.stub(:processing?).and_return(false) }
19
-
20
- context "plugin is already installed" do
21
- before { decorated_plugin.stub(:installed?).and_return(true) }
22
-
23
- it "returns the term for installed" do
24
- expect(subject).to eq I18n.t("terms.installed")
25
- end
26
- end
27
-
28
- context "plugin isn't installed yet" do
29
- before { decorated_plugin.stub(:installed?).and_return(false) }
30
-
31
- it "returns the term for not installed" do
32
- expect(subject).to eq I18n.t("terms.not_installed")
33
- end
34
- end
35
- end
36
- end
37
- end
@@ -1,42 +0,0 @@
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
@@ -1,110 +0,0 @@
1
- require "spec_helper"
2
-
3
- describe "histories", stub: :daemon do
4
- let!(:exists_user) { build(:user) }
5
- include_context 'daemon has some config histories'
6
-
7
- before do
8
- login_with exists_user
9
- end
10
-
11
- describe 'index' do
12
- before do
13
- visit '/daemon/setting/histories'
14
- end
15
-
16
- it 'show histories#index' do
17
- page.should have_css('h1', text: I18n.t('fluentd.settings.histories.index.page_title'))
18
- expect(all('.row tr').count).to eq 9 + 1 # links to hisotries#show + 1 table header
19
- end
20
-
21
- it 'will go to histories#show' do
22
- all('.row tr td a').first.click
23
-
24
- page.should have_css('h1', text: I18n.t('fluentd.settings.histories.show.page_title'))
25
- end
26
- end
27
-
28
- describe 'show' do
29
- let!(:last_backup_file) { Fluentd::SettingArchive::BackupFile.new(daemon.agent.backup_files_in_new_order.first) }
30
- let!(:new_file) { Fluentd::SettingArchive::BackupFile.new(daemon.agent.backup_files_in_new_order[1]) }
31
-
32
- before do
33
- visit "/daemon/setting/histories/#{last_backup_file.file_id}"
34
- end
35
-
36
- it 'show histories#show' do
37
- page.should have_css('h1', text: I18n.t('fluentd.settings.histories.show.page_title'))
38
-
39
- page.should has_text?(last_backup_file.content)
40
- end
41
-
42
- describe 'diff' do
43
- context 'has diff' do
44
- it 'shows diff between current and target' do
45
- page.should has_text?("- type http")
46
- page.should has_text?("+ type forward")
47
- page.should has_text?("- port 8899")
48
- page.should has_text?("+ port 24224")
49
- end
50
- end
51
-
52
- context 'has no diff' do
53
- before do
54
- visit "/daemon/setting/histories/#{new_file.file_id}"
55
- end
56
-
57
- it 'shows no diff message' do
58
- page.should have_text(I18n.t('messages.no_diff'))
59
- end
60
- end
61
- end
62
-
63
- it 'update config and redirect to setting#show' do
64
- click_link I18n.t("terms.reuse")
65
-
66
- page.should have_css('h1', text: I18n.t('fluentd.settings.show.page_title'))
67
- page.should have_text(I18n.t('messages.config_successfully_copied', brand: 'fluentd') )
68
- page.should has_text?(last_backup_file.content)
69
- end
70
-
71
- describe "configtest" do
72
- let(:daemon) { build(:fluentd, variant: "fluentd_gem") } # To use fluentd_gem for real dry-run checking
73
- before do
74
- daemon.agent.config_write config
75
- daemon.agent.config_write "# dummy"
76
- backup = Fluentd::SettingArchive::BackupFile.new(daemon.agent.backup_files_in_new_order.first)
77
- visit "/daemon/setting/histories/#{backup.file_id}"
78
- click_link I18n.t("terms.configtest")
79
- end
80
-
81
- context "invalid configfile" do
82
- let(:config) { <<-CONFIG }
83
- <source>
84
- type aaaaaaaaaaaa
85
- </source>
86
- CONFIG
87
-
88
- it do
89
- page.should_not have_css('.alert-success')
90
- page.should have_css('.alert-danger')
91
- page.should have_text(%Q|Unknown input plugin 'aaaaaaaaaaaa'|)
92
- end
93
- end
94
-
95
- context "valid configfile" do
96
- let(:config) { <<-CONFIG }
97
- <source>
98
- type syslog
99
- tag syslog
100
- </source>
101
- CONFIG
102
-
103
- it do
104
- page.should have_css('.alert-success')
105
- page.should_not have_css('.alert-danger')
106
- end
107
- end
108
- end
109
- end
110
- end
@@ -1,6 +0,0 @@
1
- require "spec_helper"
2
-
3
- describe "in_forward", stub: :daemon, js: true do
4
- before { login_with exists_user }
5
- it_should_behave_like "configurable daemon settings", "in_forward", "port", "12345"
6
- end
@@ -1,6 +0,0 @@
1
- require "spec_helper"
2
-
3
- describe "in_http", js: true, stub: :daemon do
4
- before { login_with exists_user }
5
- it_should_behave_like "configurable daemon settings", "in_http", "port", "12345"
6
- end
@@ -1,6 +0,0 @@
1
- require "spec_helper"
2
-
3
- describe "in_monitor_agent", js: true, stub: :daemon do
4
- before { login_with exists_user }
5
- it_should_behave_like "configurable daemon settings", "in_monitor_agent", "port", "12345"
6
- end
@@ -1,27 +0,0 @@
1
- require "spec_helper"
2
-
3
- describe "notes", stub: :daemon do
4
- let!(:exists_user) { build(:user) }
5
- include_context 'daemon has some config histories'
6
-
7
- before { login_with exists_user }
8
-
9
- describe 'update' do
10
- let(:note_field) { ".note-content" }
11
- let(:updating_content) { "This config file is for ..." }
12
-
13
- before do
14
- visit '/daemon/setting/histories'
15
- within first("form") do
16
- first(note_field).set updating_content
17
- click_button(I18n.t('terms.save'))
18
- end
19
- end
20
-
21
- it "update a content of a note" do
22
- within first("form") do
23
- first(note_field).value.should eq updating_content
24
- end
25
- end
26
- end
27
- end
@@ -1,38 +0,0 @@
1
- require "spec_helper"
2
-
3
- describe "out_forward", js: true, stub: :daemon do
4
- before { login_with exists_user }
5
-
6
- let(:type) { "out_forward" }
7
- let(:page_url) { send("daemon_setting_#{type}_path") }
8
- let(:form_values) { {
9
- Pattern: "*",
10
- Name: "name",
11
- Host: "localhost",
12
- Port: "9999",
13
- } }
14
-
15
- it "Updated config after submit" do
16
- daemon.agent.config.should_not include("type file") # out_forward's Secondary hidden field
17
- form_values.each_pair do |k,v|
18
- daemon.agent.config.should_not include(v)
19
- end
20
- visit page_url
21
- within("form") do
22
- form_values.each_pair do |k,v|
23
- fill_in k, with: v
24
- end
25
- end
26
- click_button I18n.t("fluentd.common.finish")
27
- form_values.each_pair do |k,v|
28
- daemon.agent.config.should include(v)
29
- end
30
- end
31
-
32
- it "Click to append Server fields", js: true do
33
- visit page_url
34
- all(".js-multiple").length.should == 1
35
- first(".js-multiple .js-append").click
36
- all(".js-multiple").length.should == 2
37
- end
38
- end