Add test/system/fluentd/setting/*_test.rb

Signed-off-by: Kenji Okimoto <okimoto@clear-code.com>
This commit is contained in:
Kenji Okimoto 2018-08-02 11:13:34 +09:00
parent 90e6df54f3
commit a2f0a29b54
No known key found for this signature in database
GPG Key ID: F9E3E329A5C5E4A1
8 changed files with 168 additions and 0 deletions

View File

@ -0,0 +1,26 @@
module ConfigurableDaemonSettings
extend ActiveSupport::Concern
included do
test "show form" do
visit(__send__("daemon_setting_#{@type}_path"))
assert do
page.has_css?("input[name=\"setting[#{@form_name}]\"]")
end
end
test "Update config" do
assert do
!@daemon.agent.config.include?(@form_value)
end
visit(__send__("daemon_setting_#{@type}_path"))
within("form") do
fill_in(@form_name.capitalize, with: @form_value)
end
click_button(I18n.t("fluentd.common.finish"))
assert do
@daemon.agent.config.include?(@form_value)
end
end
end
end

View File

@ -0,0 +1,13 @@
require "application_system_test_case"
class InForwardTest < ApplicationSystemTestCase
include ConfigurableDaemonSettings
setup do
login_with(FactoryBot.build(:user))
@type = "in_forward"
@form_name = "port"
@form_value = "12345"
@daemon = stub_daemon
end
end

View File

@ -0,0 +1,13 @@
require "application_system_test_case"
class InHttpTest < ApplicationSystemTestCase
include ConfigurableDaemonSettings
setup do
login_with(FactoryBot.build(:user))
@type = "in_http"
@form_name = "port"
@form_value = "12345"
@daemon = stub_daemon
end
end

View File

@ -0,0 +1,13 @@
require "application_system_test_case"
class InMonitorAgentTest < ApplicationSystemTestCase
include ConfigurableDaemonSettings
setup do
login_with(FactoryBot.build(:user))
@type = "in_monitor_agent"
@form_name = "port"
@form_value = "12345"
@daemon = stub_daemon
end
end

View File

@ -0,0 +1,32 @@
require "application_system_test_case"
class OutElasticsearchTest < ApplicationSystemTestCase
setup do
login_with(FactoryBot.build(:user))
@daemon = stub_daemon
@pattern = "test.out_forward.#{Time.now.to_i}.*"
end
test "show form" do
visit(daemon_setting_out_elasticsearch_path)
assert do
page.has_css?('input[name="setting[pattern]"]')
end
end
test "Update config" do
assert do
!@daemon.agent.config.include?(@pattern)
end
visit(daemon_setting_out_elasticsearch_path)
within("form") do
fill_in("Pattern", with: @pattern)
fill_in("Index name", with: "index")
fill_in("Type name", with: "type_name")
end
click_button(I18n.t("fluentd.common.finish"))
assert do
@daemon.agent.config.include?(@pattern)
end
end
end

View File

@ -0,0 +1,41 @@
require "application_system_test_case"
require "fluent/plugin/buf_file"
class OutForwardTest < ApplicationSystemTestCase
setup do
login_with(FactoryBot.build(:user))
@daemon = stub_daemon
@pattern = "test.out_forward.#{Time.now.to_i}.*"
end
test "show form" do
visit(daemon_setting_out_forward_path)
assert do
page.has_css?('input[name="setting[pattern]"]')
end
end
test "appendable server setting" do
visit(daemon_setting_out_forward_path)
assert_equal(1, all(".js-nested-column .js-append", visible: false).size)
all('.js-append').first.click
assert_equal(2, all(".js-nested-column .js-append", visible: false).size)
end
test "update config" do
assert do
!@daemon.agent.config.include?(@pattern)
end
visit(daemon_setting_out_forward_path)
within("form") do
fill_in("Pattern", with: @pattern)
fill_in("setting_server_0__host", with: "localhost")
fill_in("setting_server_0__port", with: "9999")
fill_in("Path", with: "/tmp/foo")
end
click_button(I18n.t("fluentd.common.finish"))
assert do
@daemon.agent.config.include?(@pattern)
end
end
end

View File

@ -0,0 +1,15 @@
require "application_system_test_case"
require "fluent/plugin/buf_file"
class OutStdoutTest < ApplicationSystemTestCase
include ConfigurableDaemonSettings
setup do
login_with(FactoryBot.build(:user))
@type = "out_stdout"
@form_name = "pattern"
@form_value = "stdout.**"
@daemon = stub_daemon
end
end

View File

@ -0,0 +1,15 @@
require "application_system_test_case"
require "fluent/plugin/buf_file"
class OutTdlogTest < ApplicationSystemTestCase
include ConfigurableDaemonSettings
setup do
login_with(FactoryBot.build(:user))
@type = "out_tdlog"
@form_name = "apikey"
@form_value = "dummydummy"
@daemon = stub_daemon
end
end