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,48 @@
|
|
1
|
+
require "test_helper"
|
2
|
+
|
3
|
+
class UserTest < ActiveSupport::TestCase
|
4
|
+
setup do
|
5
|
+
@user = FactoryBot.build(:user)
|
6
|
+
end
|
7
|
+
|
8
|
+
sub_test_case "password" do
|
9
|
+
def set_password(current_password, password, password_confirmation)
|
10
|
+
@user.current_password = current_password
|
11
|
+
@user.password = password
|
12
|
+
@user.password_confirmation = password_confirmation
|
13
|
+
end
|
14
|
+
|
15
|
+
sub_test_case "when current password is correct" do
|
16
|
+
test "password/confirmation is 8 characters" do
|
17
|
+
set_password(@user.password, "a" * 8, "a" * 8)
|
18
|
+
assert do
|
19
|
+
@user.valid?
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
test "password is 7 characters" do
|
24
|
+
set_password(@user.password, "a" * 7, "a" * 7)
|
25
|
+
assert do
|
26
|
+
!@user.valid?
|
27
|
+
end
|
28
|
+
assert_equal([:password], @user.errors.keys)
|
29
|
+
end
|
30
|
+
|
31
|
+
test "password != password_confirmation" do
|
32
|
+
set_password(@user.password, "a" * 8, "b" * 8)
|
33
|
+
assert do
|
34
|
+
!@user.valid?
|
35
|
+
end
|
36
|
+
assert_equal([:password], @user.errors.keys)
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
test "current_password is wrong" do
|
41
|
+
set_password("invalid_password", "a" * 8, "a" * 8)
|
42
|
+
assert do
|
43
|
+
!@user.valid?
|
44
|
+
end
|
45
|
+
assert_equal([:current_password], @user.errors.keys)
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
@@ -0,0 +1,72 @@
|
|
1
|
+
require_relative "./stub_daemon"
|
2
|
+
|
3
|
+
module ConfigHistories
|
4
|
+
module DaemonHaveSomeConfigHistories
|
5
|
+
extend ActiveSupport::Concern
|
6
|
+
include ::StubDaemon
|
7
|
+
|
8
|
+
included do
|
9
|
+
def daemon
|
10
|
+
@daemon ||= stub_daemon(variant: "fluentd_gem")
|
11
|
+
end
|
12
|
+
|
13
|
+
setup do
|
14
|
+
config_contents = <<-CONFIG.strip_heredoc
|
15
|
+
<source>
|
16
|
+
@type forward
|
17
|
+
port 24224
|
18
|
+
</source>
|
19
|
+
CONFIG
|
20
|
+
new_config = <<-CONFIG.strip_heredoc
|
21
|
+
<source>
|
22
|
+
@type http
|
23
|
+
port 8899
|
24
|
+
</source>
|
25
|
+
CONFIG
|
26
|
+
|
27
|
+
three_hours_ago = Time.zone.now - 3.hours
|
28
|
+
Timecop.freeze(three_hours_ago)
|
29
|
+
FileUtils.rm_rf(daemon.agent.config_backup_dir)
|
30
|
+
|
31
|
+
7.times do |i|
|
32
|
+
backup_time = three_hours_ago - (i+1).hours
|
33
|
+
FileUtils.touch(File.join(daemon.agent.config_backup_dir, "#{backup_time.strftime("%Y%m%d_%H%M%S")}.conf"))
|
34
|
+
end
|
35
|
+
|
36
|
+
Timecop.freeze(three_hours_ago + 1.hours)
|
37
|
+
daemon.agent.config_write(config_contents)
|
38
|
+
|
39
|
+
Timecop.freeze(three_hours_ago + 2.hours)
|
40
|
+
daemon.agent.config_write(new_config)
|
41
|
+
|
42
|
+
Timecop.freeze(three_hours_ago + 3.hours)
|
43
|
+
end
|
44
|
+
|
45
|
+
teardown do
|
46
|
+
FileUtils.rm_rf(daemon.agent.config_backup_dir)
|
47
|
+
Timecop.return
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
module DaemonHadBeenStartedOnce
|
53
|
+
extend ActiveSupport::Concern
|
54
|
+
|
55
|
+
included do
|
56
|
+
setup do
|
57
|
+
@backup_content = "Running backup file content"
|
58
|
+
File.open(daemon.agent.running_config_backup_file, "w") do |file|
|
59
|
+
file.write(@backup_content)
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
def backup_content
|
64
|
+
@backup_content
|
65
|
+
end
|
66
|
+
|
67
|
+
teardown do
|
68
|
+
FileUtils.rm_rf(daemon.agent.running_config_backup_dir)
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
module ConfigurableDaemonSettings
|
2
|
+
extend ActiveSupport::Concern
|
3
|
+
|
4
|
+
included do
|
5
|
+
test "show form" do
|
6
|
+
visit(__send__("daemon_setting_#{@type}_path"))
|
7
|
+
assert do
|
8
|
+
page.has_css?("input[name=\"setting[#{@form_name}]\"]")
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
test "Update config" do
|
13
|
+
assert do
|
14
|
+
!@daemon.agent.config.include?(@form_value)
|
15
|
+
end
|
16
|
+
visit(__send__("daemon_setting_#{@type}_path"))
|
17
|
+
within("form") do
|
18
|
+
fill_in(@form_name.capitalize, with: @form_value)
|
19
|
+
end
|
20
|
+
click_button(I18n.t("fluentd.common.finish"))
|
21
|
+
assert do
|
22
|
+
@daemon.agent.config.include?(@form_value)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
module LoginMacro
|
2
|
+
def login_with(user, password: nil)
|
3
|
+
visit("/sessions/new")
|
4
|
+
within("form") do
|
5
|
+
fill_in("session_name", :with => user.name)
|
6
|
+
fill_in("session_password", :with => password || user.password)
|
7
|
+
end
|
8
|
+
click_button(I18n.t("terms.sign_in"))
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
ActionDispatch::IntegrationTest.include(LoginMacro)
|
@@ -0,0 +1,14 @@
|
|
1
|
+
module StubDaemon
|
2
|
+
def stub_daemon(running: false, variant: "td-agent")
|
3
|
+
daemon = FactoryBot.build(:fluentd, variant: variant)
|
4
|
+
stub(Fluentd).instance { daemon }
|
5
|
+
any_instance_of(Fluentd::Agent::TdAgent) do |object|
|
6
|
+
stub(object).detached_command { true }
|
7
|
+
stub(object).running? { running }
|
8
|
+
end
|
9
|
+
daemon.agent.config_write("")
|
10
|
+
daemon
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
ActionDispatch::IntegrationTest.include(StubDaemon)
|
@@ -0,0 +1,13 @@
|
|
1
|
+
require "application_system_test_case"
|
2
|
+
|
3
|
+
class InForwardTest < ApplicationSystemTestCase
|
4
|
+
include ConfigurableDaemonSettings
|
5
|
+
|
6
|
+
setup do
|
7
|
+
login_with(FactoryBot.build(:user))
|
8
|
+
@type = "in_forward"
|
9
|
+
@form_name = "port"
|
10
|
+
@form_value = "12345"
|
11
|
+
@daemon = stub_daemon
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
require "application_system_test_case"
|
2
|
+
|
3
|
+
class InHttpTest < ApplicationSystemTestCase
|
4
|
+
include ConfigurableDaemonSettings
|
5
|
+
|
6
|
+
setup do
|
7
|
+
login_with(FactoryBot.build(:user))
|
8
|
+
@type = "in_http"
|
9
|
+
@form_name = "port"
|
10
|
+
@form_value = "12345"
|
11
|
+
@daemon = stub_daemon
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
require "application_system_test_case"
|
2
|
+
|
3
|
+
class InMonitorAgentTest < ApplicationSystemTestCase
|
4
|
+
include ConfigurableDaemonSettings
|
5
|
+
|
6
|
+
setup do
|
7
|
+
login_with(FactoryBot.build(:user))
|
8
|
+
@type = "in_monitor_agent"
|
9
|
+
@form_name = "port"
|
10
|
+
@form_value = "12345"
|
11
|
+
@daemon = stub_daemon
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
require "application_system_test_case"
|
2
|
+
|
3
|
+
class OutElasticsearchTest < ApplicationSystemTestCase
|
4
|
+
setup do
|
5
|
+
login_with(FactoryBot.build(:user))
|
6
|
+
@daemon = stub_daemon
|
7
|
+
@pattern = "test.out_forward.#{Time.now.to_i}.*"
|
8
|
+
end
|
9
|
+
|
10
|
+
test "show form" do
|
11
|
+
visit(daemon_setting_out_elasticsearch_path)
|
12
|
+
assert do
|
13
|
+
page.has_css?('input[name="setting[pattern]"]')
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
test "Update config" do
|
18
|
+
assert do
|
19
|
+
!@daemon.agent.config.include?(@pattern)
|
20
|
+
end
|
21
|
+
visit(daemon_setting_out_elasticsearch_path)
|
22
|
+
within("form") do
|
23
|
+
fill_in("Pattern", with: @pattern)
|
24
|
+
fill_in("Index name", with: "index")
|
25
|
+
fill_in("Type name", with: "type_name")
|
26
|
+
end
|
27
|
+
click_button(I18n.t("fluentd.common.finish"))
|
28
|
+
assert do
|
29
|
+
@daemon.agent.config.include?(@pattern)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
require "application_system_test_case"
|
2
|
+
require "fluent/plugin/buf_file"
|
3
|
+
|
4
|
+
class OutForwardTest < ApplicationSystemTestCase
|
5
|
+
setup do
|
6
|
+
login_with(FactoryBot.build(:user))
|
7
|
+
@daemon = stub_daemon
|
8
|
+
@pattern = "test.out_forward.#{Time.now.to_i}.*"
|
9
|
+
end
|
10
|
+
|
11
|
+
test "show form" do
|
12
|
+
visit(daemon_setting_out_forward_path)
|
13
|
+
assert do
|
14
|
+
page.has_css?('input[name="setting[pattern]"]')
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
test "appendable server setting" do
|
19
|
+
visit(daemon_setting_out_forward_path)
|
20
|
+
assert_equal(1, all(".js-nested-column .js-append", visible: false).size)
|
21
|
+
all('.js-append').first.click
|
22
|
+
assert_equal(2, all(".js-nested-column .js-append", visible: false).size)
|
23
|
+
end
|
24
|
+
|
25
|
+
test "update config" do
|
26
|
+
assert do
|
27
|
+
!@daemon.agent.config.include?(@pattern)
|
28
|
+
end
|
29
|
+
visit(daemon_setting_out_forward_path)
|
30
|
+
within("form") do
|
31
|
+
fill_in("Pattern", with: @pattern)
|
32
|
+
fill_in("setting_server_0__host", with: "localhost")
|
33
|
+
fill_in("setting_server_0__port", with: "9999")
|
34
|
+
fill_in("Path", with: "/tmp/foo")
|
35
|
+
end
|
36
|
+
click_button(I18n.t("fluentd.common.finish"))
|
37
|
+
assert do
|
38
|
+
@daemon.agent.config.include?(@pattern)
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require "application_system_test_case"
|
2
|
+
|
3
|
+
require "fluent/plugin/buf_file"
|
4
|
+
|
5
|
+
class OutStdoutTest < ApplicationSystemTestCase
|
6
|
+
include ConfigurableDaemonSettings
|
7
|
+
|
8
|
+
setup do
|
9
|
+
login_with(FactoryBot.build(:user))
|
10
|
+
@type = "out_stdout"
|
11
|
+
@form_name = "pattern"
|
12
|
+
@form_value = "stdout.**"
|
13
|
+
@daemon = stub_daemon
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require "application_system_test_case"
|
2
|
+
|
3
|
+
require "fluent/plugin/buf_file"
|
4
|
+
|
5
|
+
class OutTdlogTest < ApplicationSystemTestCase
|
6
|
+
include ConfigurableDaemonSettings
|
7
|
+
|
8
|
+
setup do
|
9
|
+
login_with(FactoryBot.build(:user))
|
10
|
+
@type = "out_tdlog"
|
11
|
+
@form_name = "apikey"
|
12
|
+
@form_value = "dummydummy"
|
13
|
+
@daemon = stub_daemon
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,184 @@
|
|
1
|
+
require "application_system_test_case"
|
2
|
+
|
3
|
+
class SourceAndOutputTest < ApplicationSystemTestCase
|
4
|
+
setup do
|
5
|
+
login_with(FactoryBot.build(:user))
|
6
|
+
@daemon = stub_daemon
|
7
|
+
end
|
8
|
+
|
9
|
+
test "config is blank" do
|
10
|
+
@daemon.agent.config_write("")
|
11
|
+
visit(source_and_output_daemon_setting_path)
|
12
|
+
|
13
|
+
page.has_content?(I18n.t("fluentd.settings.source_and_output.setting_empty"))
|
14
|
+
page.has_css?(".input .empty")
|
15
|
+
page.has_css?(".output .empty")
|
16
|
+
end
|
17
|
+
|
18
|
+
sub_test_case "config is given" do
|
19
|
+
setup do
|
20
|
+
config = <<-CONFIG.strip_heredoc
|
21
|
+
<source>
|
22
|
+
# http://docs.fluentd.org/articles/in_forward
|
23
|
+
type forward
|
24
|
+
port 24224
|
25
|
+
</source>
|
26
|
+
|
27
|
+
<match debug.*>
|
28
|
+
# http://docs.fluentd.org/articles/out_stdout
|
29
|
+
type stdout
|
30
|
+
</match>
|
31
|
+
|
32
|
+
<match s3.*>
|
33
|
+
type s3
|
34
|
+
aws_key_id fofoaiofa
|
35
|
+
aws_sec_key aaaaaaaaaaaaaae
|
36
|
+
s3_bucket test
|
37
|
+
s3_endpoint s3-us-west-1.amazonaws.com
|
38
|
+
format out_file
|
39
|
+
include_time_key false
|
40
|
+
add_newline false
|
41
|
+
output_tag true
|
42
|
+
output_time true
|
43
|
+
store_as gzip
|
44
|
+
use_ssl true
|
45
|
+
buffer_type memory
|
46
|
+
</match>
|
47
|
+
CONFIG
|
48
|
+
@daemon.agent.config_write(config)
|
49
|
+
visit(source_and_output_daemon_setting_path)
|
50
|
+
end
|
51
|
+
|
52
|
+
test "elements" do
|
53
|
+
assert do
|
54
|
+
!page.has_content?(I18n.t("fluentd.settings.source_and_output.setting_empty"))
|
55
|
+
end
|
56
|
+
assert do
|
57
|
+
page.has_css?('.input .card .card-header')
|
58
|
+
end
|
59
|
+
assert do
|
60
|
+
page.has_css?('.output .card .card-header')
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
test ".card-body is hidden by default and click .card-header for display" do
|
65
|
+
assert do
|
66
|
+
!page.has_css?('.input .card .card-body')
|
67
|
+
end
|
68
|
+
assert do
|
69
|
+
!page.has_css?('.output .card .card-body')
|
70
|
+
end
|
71
|
+
all(".input .card .card-header").first.click
|
72
|
+
assert do
|
73
|
+
page.has_css?('.input .card .card-body')
|
74
|
+
end
|
75
|
+
all(".output .card .card-header").first.click
|
76
|
+
assert do
|
77
|
+
page.has_css?('.output .card .card-body')
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
test "display plugin name" do
|
82
|
+
within ".input" do
|
83
|
+
assert do
|
84
|
+
page.has_content?("forward")
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
within ".output" do
|
89
|
+
assert do
|
90
|
+
page.has_content?("stdout")
|
91
|
+
end
|
92
|
+
assert do
|
93
|
+
page.has_content?("s3")
|
94
|
+
end
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
98
|
+
sub_test_case "edit, update, delete" do
|
99
|
+
setup do
|
100
|
+
@config = <<-CONFIG.strip_heredoc
|
101
|
+
<source>
|
102
|
+
type forward
|
103
|
+
port 24224
|
104
|
+
</source>
|
105
|
+
CONFIG
|
106
|
+
@new_config = <<-CONFIG.strip_heredoc
|
107
|
+
<source>
|
108
|
+
@type http
|
109
|
+
port 8899
|
110
|
+
</source>
|
111
|
+
CONFIG
|
112
|
+
@daemon.agent.config_write(@config)
|
113
|
+
visit(source_and_output_daemon_setting_path)
|
114
|
+
all(".input .card .card-header").first.click
|
115
|
+
end
|
116
|
+
|
117
|
+
test "click edit button transform textarea, then click cancel button to reset" do
|
118
|
+
assert do
|
119
|
+
!page.has_css?(".input textarea")
|
120
|
+
end
|
121
|
+
find(".btn", text: I18n.t("terms.edit")).click
|
122
|
+
original_contents = page.evaluate_script(<<-JS)
|
123
|
+
document.querySelector(".CodeMirror").CodeMirror.getValue()
|
124
|
+
JS
|
125
|
+
assert_equal(@config, original_contents)
|
126
|
+
page.execute_script(<<-JS)
|
127
|
+
var cm = document.querySelector('.CodeMirror').CodeMirror;
|
128
|
+
cm.setValue(#{@new_config.to_json});
|
129
|
+
JS
|
130
|
+
find(".btn", text: I18n.t("terms.cancel")).click
|
131
|
+
contents = page.evaluate_script("document.querySelector('.input pre').textContent")
|
132
|
+
assert_equal(@config, contents)
|
133
|
+
assert_equal(@daemon.agent.config.strip, @config.strip)
|
134
|
+
end
|
135
|
+
|
136
|
+
test "click edit button transform textarea, then click update button to be stored" do
|
137
|
+
assert do
|
138
|
+
!page.has_css?(".input textarea")
|
139
|
+
end
|
140
|
+
find(".btn", text: I18n.t("terms.edit")).click
|
141
|
+
original_contents = page.evaluate_script(<<-JS)
|
142
|
+
document.querySelector(".CodeMirror").CodeMirror.getValue()
|
143
|
+
JS
|
144
|
+
assert_equal(@config, original_contents)
|
145
|
+
page.execute_script(<<-JS)
|
146
|
+
var cm = document.querySelector('.CodeMirror').CodeMirror;
|
147
|
+
cm.setValue(#{@new_config.to_json});
|
148
|
+
JS
|
149
|
+
find(".btn", text: I18n.t("terms.save")).click
|
150
|
+
contents = page.evaluate_script("document.querySelector('.input pre').textContent")
|
151
|
+
pend("contents does not include all lines under '.input pre'")
|
152
|
+
assert_equal(@new_config, contents)
|
153
|
+
assert_equal(@daemon.agent.config.strip, @new_config.strip)
|
154
|
+
end
|
155
|
+
|
156
|
+
test "click delete button transform textarea" do
|
157
|
+
assert do
|
158
|
+
page.has_css?(".input .card-body")
|
159
|
+
end
|
160
|
+
button = find(".btn", text: I18n.t('terms.destroy'))
|
161
|
+
page.accept_confirm do
|
162
|
+
button.click
|
163
|
+
end
|
164
|
+
assert do
|
165
|
+
!page.has_css?(".input .card-body")
|
166
|
+
end
|
167
|
+
assert_equal("", @daemon.agent.config.strip)
|
168
|
+
end
|
169
|
+
|
170
|
+
test "click delete button then cancel it" do
|
171
|
+
assert do
|
172
|
+
page.has_css?(".input .card-body")
|
173
|
+
end
|
174
|
+
page.dismiss_confirm("really?") do
|
175
|
+
find(".btn", text: I18n.t('terms.destroy')).click
|
176
|
+
end
|
177
|
+
assert do
|
178
|
+
page.has_css?(".input .card-body")
|
179
|
+
end
|
180
|
+
assert_equal(@config.strip, @daemon.agent.config.strip)
|
181
|
+
end
|
182
|
+
end
|
183
|
+
end
|
184
|
+
end
|