diff --git a/test/support/configurable_daemon_settings.rb b/test/support/configurable_daemon_settings.rb new file mode 100644 index 0000000..a95bc99 --- /dev/null +++ b/test/support/configurable_daemon_settings.rb @@ -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 diff --git a/test/system/fluentd/setting/in_forward_test.rb b/test/system/fluentd/setting/in_forward_test.rb new file mode 100644 index 0000000..e46692b --- /dev/null +++ b/test/system/fluentd/setting/in_forward_test.rb @@ -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 diff --git a/test/system/fluentd/setting/in_http_test.rb b/test/system/fluentd/setting/in_http_test.rb new file mode 100644 index 0000000..ed81bbe --- /dev/null +++ b/test/system/fluentd/setting/in_http_test.rb @@ -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 diff --git a/test/system/fluentd/setting/in_monitor_agent.rb b/test/system/fluentd/setting/in_monitor_agent.rb new file mode 100644 index 0000000..cd92c00 --- /dev/null +++ b/test/system/fluentd/setting/in_monitor_agent.rb @@ -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 diff --git a/test/system/fluentd/setting/out_elasticsearch_test.rb b/test/system/fluentd/setting/out_elasticsearch_test.rb new file mode 100644 index 0000000..9af32fc --- /dev/null +++ b/test/system/fluentd/setting/out_elasticsearch_test.rb @@ -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 diff --git a/test/system/fluentd/setting/out_forward_test.rb b/test/system/fluentd/setting/out_forward_test.rb new file mode 100644 index 0000000..0a178d8 --- /dev/null +++ b/test/system/fluentd/setting/out_forward_test.rb @@ -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 diff --git a/test/system/fluentd/setting/out_stdout_test.rb b/test/system/fluentd/setting/out_stdout_test.rb new file mode 100644 index 0000000..631b100 --- /dev/null +++ b/test/system/fluentd/setting/out_stdout_test.rb @@ -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 diff --git a/test/system/fluentd/setting/out_tdlog_test.rb b/test/system/fluentd/setting/out_tdlog_test.rb new file mode 100644 index 0000000..53ba23d --- /dev/null +++ b/test/system/fluentd/setting/out_tdlog_test.rb @@ -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