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
@@ -0,0 +1,27 @@
|
|
1
|
+
require "test_helper"
|
2
|
+
|
3
|
+
class NotesTest < ActionDispatch::IntegrationTest
|
4
|
+
include ConfigHistories::DaemonHaveSomeConfigHistories
|
5
|
+
|
6
|
+
setup do
|
7
|
+
login_with(FactoryBot.build(:user))
|
8
|
+
end
|
9
|
+
|
10
|
+
sub_test_case "update" do
|
11
|
+
setup do
|
12
|
+
visit("/daemon/setting/histories")
|
13
|
+
end
|
14
|
+
|
15
|
+
test "update a content of the first note" do
|
16
|
+
content = "This config file is for ..."
|
17
|
+
within(first("form")) do
|
18
|
+
first(".note-content").set(content)
|
19
|
+
click_button(I18n.t('terms.save'))
|
20
|
+
end
|
21
|
+
|
22
|
+
within(first("form")) do
|
23
|
+
assert_equal(content, first(".note-content").value)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,65 @@
|
|
1
|
+
require "test_helper"
|
2
|
+
|
3
|
+
class RunningBackupTest < ActionDispatch::IntegrationTest
|
4
|
+
include ConfigHistories::DaemonHaveSomeConfigHistories
|
5
|
+
|
6
|
+
setup do
|
7
|
+
login_with(FactoryBot.build(:user))
|
8
|
+
end
|
9
|
+
|
10
|
+
sub_test_case "have no running backup files" do
|
11
|
+
test "have no contents, no reuse button" do
|
12
|
+
visit("/daemon/setting/running_backup")
|
13
|
+
assert do
|
14
|
+
page.has_text?(I18n.t('fluentd.common.never_started_yet', brand: 'fluentd'))
|
15
|
+
end
|
16
|
+
assert do
|
17
|
+
!page.has_css?("pre")
|
18
|
+
end
|
19
|
+
assert do
|
20
|
+
!page.has_text?(I18n.t("terms.reuse"))
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
sub_test_case "have running backup files" do
|
26
|
+
include ConfigHistories::DaemonHadBeenStartedOnce
|
27
|
+
|
28
|
+
setup do
|
29
|
+
visit("/daemon/setting/running_backup")
|
30
|
+
end
|
31
|
+
|
32
|
+
test "have content and reuse button" do
|
33
|
+
assert do
|
34
|
+
!page.has_text?(I18n.t('fluentd.common.never_started_yet', brand: 'fluentd'))
|
35
|
+
end
|
36
|
+
assert do
|
37
|
+
page.has_text?(backup_content)
|
38
|
+
end
|
39
|
+
assert do
|
40
|
+
page.has_text?(I18n.t("terms.reuse"))
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
test "have diff" do
|
45
|
+
diff = page.first(".diff pre").native.inner_text
|
46
|
+
assert_equal(<<-DIFF.gsub("\n\n", ""), diff)
|
47
|
+
|
48
|
+
- <source>
|
49
|
+
+ Running backup file content
|
50
|
+
- @type http
|
51
|
+
- port 8899
|
52
|
+
- </source>
|
53
|
+
\n
|
54
|
+
DIFF
|
55
|
+
end
|
56
|
+
|
57
|
+
test "have no diff" do
|
58
|
+
daemon.agent.config_write(backup_content)
|
59
|
+
visit("/daemon/setting/running_backup")
|
60
|
+
assert do
|
61
|
+
page.has_text?(I18n.t('messages.no_diff'))
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
require "test_helper"
|
2
|
+
|
3
|
+
class UpdateCheckingTest < ActionDispatch::IntegrationTest
|
4
|
+
setup do
|
5
|
+
login_with(FactoryBot.build(:user))
|
6
|
+
end
|
7
|
+
|
8
|
+
teardown do
|
9
|
+
FluentdUI.latest_version = ::FluentdUI::VERSION
|
10
|
+
end
|
11
|
+
|
12
|
+
test "show popup if newer version is available" do
|
13
|
+
version = "9999.99"
|
14
|
+
FluentdUI.latest_version = version
|
15
|
+
visit root_path
|
16
|
+
within(".alert-info") do
|
17
|
+
assert_equal("fluentd-ui 9999.99 is available. Go to system information page", text)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
test "not show popup newer version is not available" do
|
22
|
+
visit root_path
|
23
|
+
assert do
|
24
|
+
!page.has_css?(".alert-info")
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,56 @@
|
|
1
|
+
require "test_helper"
|
2
|
+
|
3
|
+
class SessionsTest < ActionDispatch::IntegrationTest
|
4
|
+
sub_test_case "sign in with default password" do
|
5
|
+
test "correct credentials" do
|
6
|
+
login_with(FactoryBot.build(:user))
|
7
|
+
assert_equal(daemon_path, current_path)
|
8
|
+
end
|
9
|
+
|
10
|
+
test "wrond credentials" do
|
11
|
+
login_with(FactoryBot.build(:user, password: "wrongpassword"))
|
12
|
+
assert do
|
13
|
+
daemon_path != current_path
|
14
|
+
end
|
15
|
+
assert do
|
16
|
+
page.has_css?("form")
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
sub_test_case "sign in with modified password" do
|
22
|
+
setup do
|
23
|
+
new_password = "newpassword"
|
24
|
+
@user = FactoryBot.build(:user)
|
25
|
+
@user.update_attributes(current_password: Settings.default_password,
|
26
|
+
password: new_password,
|
27
|
+
password_confirmation: new_password)
|
28
|
+
|
29
|
+
|
30
|
+
end
|
31
|
+
|
32
|
+
teardown do
|
33
|
+
# reset password to the default
|
34
|
+
FileUtils.rm_f(User::ENCRYPTED_PASSWORD_FILE)
|
35
|
+
end
|
36
|
+
|
37
|
+
test "login success with correct password" do
|
38
|
+
login_with(@user)
|
39
|
+
assert_equal(daemon_path, current_path)
|
40
|
+
end
|
41
|
+
|
42
|
+
test "login failure with wrong password" do
|
43
|
+
login_with(@user, password: "wrongpassword")
|
44
|
+
assert do
|
45
|
+
daemon_path != current_path
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
test "at sign in page after sign out" do
|
51
|
+
login_with(FactoryBot.build(:user))
|
52
|
+
visit(root_path)
|
53
|
+
click_link(I18n.t("terms.sign_out"))
|
54
|
+
assert_equal(new_sessions_path, current_path)
|
55
|
+
end
|
56
|
+
end
|
@@ -0,0 +1,126 @@
|
|
1
|
+
require "test_helper"
|
2
|
+
|
3
|
+
class Setting < ActionDispatch::IntegrationTest
|
4
|
+
include ::ConfigHistories::DaemonHaveSomeConfigHistories
|
5
|
+
include ::ConfigHistories::DaemonHadBeenStartedOnce
|
6
|
+
|
7
|
+
setup do
|
8
|
+
login_with(FactoryBot.build(:user))
|
9
|
+
stub_daemon
|
10
|
+
daemon.agent.config_write("GREAT CONFIG HERE")
|
11
|
+
|
12
|
+
visit("/daemon/setting")
|
13
|
+
end
|
14
|
+
|
15
|
+
test "show setting" do
|
16
|
+
assert do
|
17
|
+
page.has_css?('h1', text: I18n.t('fluentd.settings.show.page_title'))
|
18
|
+
end
|
19
|
+
assert do
|
20
|
+
page.has_link?(I18n.t('terms.edit'))
|
21
|
+
end
|
22
|
+
assert do
|
23
|
+
page.has_css?('pre', text: 'GREAT CONFIG HERE')
|
24
|
+
end
|
25
|
+
assert_equal(Settings.histories_count_in_preview + 1, all('.row tr').count) # links to hisotries#show + 1 table header
|
26
|
+
assert do
|
27
|
+
page.has_link?(I18n.t('fluentd.settings.show.link_to_histories'))
|
28
|
+
end
|
29
|
+
assert do
|
30
|
+
page.has_text?(I18n.t('fluentd.settings.running_backup.title'))
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
test "go to histories#index" do
|
35
|
+
click_link(I18n.t('fluentd.settings.show.link_to_histories'))
|
36
|
+
|
37
|
+
assert do
|
38
|
+
page.has_css?('h1', text: I18n.t('fluentd.settings.histories.index.page_title'))
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
test "go to histories#show" do
|
43
|
+
all('.row tr td a').first.click
|
44
|
+
|
45
|
+
assert do
|
46
|
+
page.has_css?('h1', text: I18n.t('fluentd.settings.histories.show.page_title'))
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
test "edit setting" do
|
51
|
+
click_link(I18n.t('terms.edit'))
|
52
|
+
|
53
|
+
assert do
|
54
|
+
page.has_css?('h1', text: I18n.t('fluentd.settings.edit.page_title'))
|
55
|
+
end
|
56
|
+
assert do
|
57
|
+
page.has_css?('p.text-danger', text: I18n.t('terms.notice_restart_for_config_edit', brand: 'fluentd'))
|
58
|
+
end
|
59
|
+
|
60
|
+
fill_in('config', with: 'YET ANOTHER CONFIG')
|
61
|
+
|
62
|
+
click_button(I18n.t('terms.update'))
|
63
|
+
|
64
|
+
assert_equal('/daemon/setting', current_path)
|
65
|
+
assert do
|
66
|
+
page.has_css?('pre', text: 'YET ANOTHER CONFIG')
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
sub_test_case "plain config" do
|
71
|
+
setup do
|
72
|
+
any_instance_of(Fluentd::Agent::TdAgent) do |object|
|
73
|
+
@conf = <<-'CONFIG'
|
74
|
+
<source>
|
75
|
+
@type forward
|
76
|
+
</source>
|
77
|
+
CONFIG
|
78
|
+
stub(object).dryrun(anything) { true }
|
79
|
+
daemon.agent.config_write(@conf)
|
80
|
+
click_link(I18n.t('terms.edit'))
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
test "configtest" do
|
85
|
+
click_button(I18n.t('terms.configtest'))
|
86
|
+
assert do
|
87
|
+
page.has_css?('.alert-success')
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
test "update & restart check" do
|
92
|
+
click_button(I18n.t('terms.update'))
|
93
|
+
# CodeMirror exchange \n -> \r\n
|
94
|
+
assert_equal(@conf, daemon.agent.config.gsub("\r\n", "\n"))
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
98
|
+
sub_test_case "embedded config" do
|
99
|
+
setup do
|
100
|
+
any_instance_of(Fluentd::Agent::TdAgent) do |object|
|
101
|
+
@conf = <<-'CONFIG'
|
102
|
+
<source>
|
103
|
+
type forward
|
104
|
+
id "foo#{Time.now.to_s}"
|
105
|
+
</source>
|
106
|
+
CONFIG
|
107
|
+
stub(object).dryrun(anything) { true }
|
108
|
+
daemon.agent.config_write(@conf)
|
109
|
+
click_link(I18n.t('terms.edit'))
|
110
|
+
end
|
111
|
+
end
|
112
|
+
|
113
|
+
test "configtest" do
|
114
|
+
click_button(I18n.t('terms.configtest'))
|
115
|
+
assert do
|
116
|
+
page.has_css?('.alert-success')
|
117
|
+
end
|
118
|
+
end
|
119
|
+
|
120
|
+
test "update & restart check" do
|
121
|
+
click_button(I18n.t('terms.update'))
|
122
|
+
# CodeMirror exchange \n -> \r\n
|
123
|
+
assert_equal(@conf, daemon.agent.config.gsub("\r\n", "\n"))
|
124
|
+
end
|
125
|
+
end
|
126
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
require "test_helper"
|
2
|
+
|
3
|
+
class UsersTest < ActionDispatch::IntegrationTest
|
4
|
+
test "login required" do
|
5
|
+
login_required(user_path)
|
6
|
+
end
|
7
|
+
|
8
|
+
sub_test_case "edit" do
|
9
|
+
setup do
|
10
|
+
@user = FactoryBot.build(:user)
|
11
|
+
login_with(@user)
|
12
|
+
end
|
13
|
+
|
14
|
+
teardown do
|
15
|
+
# reset password to the default
|
16
|
+
FileUtils.rm_f(User::ENCRYPTED_PASSWORD_FILE)
|
17
|
+
end
|
18
|
+
|
19
|
+
sub_test_case "to change password" do
|
20
|
+
def update_password(current_password, password, password_confirmation)
|
21
|
+
visit user_path
|
22
|
+
fill_in 'user[current_password]', with: current_password
|
23
|
+
|
24
|
+
fill_in 'user[password]', with: password
|
25
|
+
fill_in 'user[password_confirmation]', with: password_confirmation
|
26
|
+
click_button I18n.t("terms.update_password")
|
27
|
+
end
|
28
|
+
|
29
|
+
test "when input valid new password/confirmation" do
|
30
|
+
update_password(@user.password, "newpassword", "newpassword")
|
31
|
+
page.has_css?(".alert-success")
|
32
|
+
assert_equal(@user.digest("newpassword"), @user.stored_digest)
|
33
|
+
end
|
34
|
+
|
35
|
+
test "when input invalid new password/confirmation" do
|
36
|
+
original_digest = @user.stored_digest
|
37
|
+
update_password(@user.password, "newpassword", "invalidpassword")
|
38
|
+
page.has_css?(".alert-danger")
|
39
|
+
assert_equal(original_digest, @user.stored_digest)
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
@@ -0,0 +1,63 @@
|
|
1
|
+
require "test_helper"
|
2
|
+
|
3
|
+
class FileReverseReaderTest < ActiveSupport::TestCase
|
4
|
+
sub_test_case "#each_line" do
|
5
|
+
data(
|
6
|
+
"small file" => File.size(fixture_path("error0.log")),
|
7
|
+
"large file" => 2,
|
8
|
+
)
|
9
|
+
test "read at once" do |step|
|
10
|
+
io = File.open(fixture_path("error0.log"))
|
11
|
+
reader = FileReverseReader.new(io, step)
|
12
|
+
subject = reader.enum_for(:each_line)
|
13
|
+
File.open(fixture_path("error0.log"), "r") do |file|
|
14
|
+
assert_equal(file.each_line.count, subject.count)
|
15
|
+
end
|
16
|
+
File.open(fixture_path("error0.log"), "r") do |file|
|
17
|
+
assert_equal(file.each_line.to_a.map(&:strip).reverse, subject.to_a)
|
18
|
+
end
|
19
|
+
io.close
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
data("contain ascii only" => ["ABCDE", false],
|
24
|
+
"contain non-ascii" => ["\x89NG", true])
|
25
|
+
test "#binary_file?" do |(content, is_binary)|
|
26
|
+
File.open(Rails.root + "tmp/log.log", "wb") do |file|
|
27
|
+
file.write(content)
|
28
|
+
end
|
29
|
+
File.open(Rails.root + "tmp/log.log") do |io|
|
30
|
+
reader = FileReverseReader.new(io)
|
31
|
+
assert_equal(is_binary, reader.binary_file?)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
sub_test_case "#tail" do
|
36
|
+
data("2" => [2, "foo\n" * 2],
|
37
|
+
"50" => [50, "foo\n" * 50],
|
38
|
+
"over log lines" => [100, "foo\n" * 200])
|
39
|
+
test "count" do |(count, content)|
|
40
|
+
logfile = Rails.root + "tmp/log.log"
|
41
|
+
File.open(logfile, "wb") do |file|
|
42
|
+
file.write(content)
|
43
|
+
end
|
44
|
+
File.open(logfile, "r") do |io|
|
45
|
+
reader = FileReverseReader.new(io)
|
46
|
+
assert_equal(count, reader.tail(count).to_a.size)
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
data("compatible with utf-8" => ["utf8あいう\n", ["utf8あいう"]],
|
51
|
+
"incompatible with utf-8" => ["eucあいう\n".encode('euc-jp'), []])
|
52
|
+
test "non-ascii encoding" do |(content, expected)|
|
53
|
+
logfile = Rails.root + "tmp/log.log"
|
54
|
+
File.open(logfile, "wb") do |file|
|
55
|
+
file.write(content)
|
56
|
+
end
|
57
|
+
File.open(logfile, "r") do |io|
|
58
|
+
reader = FileReverseReader.new(io)
|
59
|
+
assert_equal(expected, reader.tail)
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
require "test_helper"
|
2
|
+
|
3
|
+
class FluentdUITest < ActiveSupport::TestCase
|
4
|
+
sub_test_case ".update_available?" do
|
5
|
+
setup do
|
6
|
+
@current_version = FluentdUI::VERSION
|
7
|
+
end
|
8
|
+
|
9
|
+
test "unavailable" do
|
10
|
+
FluentdUI.latest_version = @current_version
|
11
|
+
assert do
|
12
|
+
!FluentdUI.update_available?
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
test "available" do
|
17
|
+
FluentdUI.latest_version = @current_version.succ
|
18
|
+
assert do
|
19
|
+
FluentdUI.update_available?
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
sub_test_case ".fluentd_version" do
|
25
|
+
test "not ready" do
|
26
|
+
stub(Fluentd).instance { nil }
|
27
|
+
assert_nil(FluentdUI.fluentd_version)
|
28
|
+
end
|
29
|
+
|
30
|
+
test "ready" do
|
31
|
+
target = FactoryBot.build(:fluentd)
|
32
|
+
stub(Fluentd).instance{ target }
|
33
|
+
assert_equal(target.agent.version, FluentdUI.fluentd_version)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|