Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 31 additions & 2 deletions test/plugin/test_in_monitor_agent.rb
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,6 @@ def test_enable_input_metrics(with_config)
tag monitor
emit_interval 1
")
d.instance.start
Comment thread
kenhys marked this conversation as resolved.
d.end_if do
d.events.size >= 5
end
Expand Down Expand Up @@ -539,6 +538,8 @@ def get(uri, header = {})
test_filter = response.split("\n")[3]
assert_equal(expected_test_in_response, test_in)
assert_equal(expected_test_filter_response, test_filter)

d.instance_shutdown
end

data(:include_config_and_retry_yes => [true, true, "include_config yes", "include_retry yes"],
Expand Down Expand Up @@ -593,6 +594,8 @@ def get(uri, header = {})
null_response = response["plugins"][5]
assert_equal(expected_test_in_response, test_in_response)
assert_fuzzy_equal(expected_null_response, null_response)

d.instance_shutdown
end

test "/api/plugins.json/not_found" do
Expand All @@ -607,6 +610,8 @@ def get(uri, header = {})
assert_equal('404', resp.code)
body = JSON.parse(resp.body)
assert_equal(body['message'], 'Not found')

d.instance_shutdown
end

data(:with_config_and_retry_yes => [true, true, "?with_config=yes&with_retry"],
Expand Down Expand Up @@ -659,6 +664,8 @@ def get(uri, header = {})
null_response = response["plugins"][5]
assert_equal(expected_test_in_response, test_in_response)
assert_fuzzy_include(expected_null_response, null_response)

d.instance_shutdown
end

test "/api/plugins.json with 'with_ivars'. response contains specified instance variables of each plugin" do
Expand Down Expand Up @@ -708,6 +715,8 @@ def get(uri, header = {})
null_response = response["plugins"][5]
assert_equal(expected_test_in_response, test_in_response)
assert_fuzzy_equal(expected_null_response, null_response)

d.instance_shutdown
end

test "/api/config" do
Expand All @@ -721,6 +730,8 @@ def get(uri, header = {})
expected_response_regex = %r{pid:\d+\tppid:\d+\tversion:#{Fluent::VERSION}\tconfig_path:#{@filepath}\tpid_file:\tplugin_dirs:/etc/fluent/plugin\tlog_path:}
assert_match(expected_response_regex,
get("http://127.0.0.1:#{@port}/api/config").body)

d.instance_shutdown
end

test "/api/config.json" do
Expand All @@ -737,6 +748,8 @@ def get(uri, header = {})
assert_equal(["/etc/fluent/plugin"], res["plugin_dirs"])
assert_nil(res["log_path"])
assert_equal(Fluent::VERSION, res["version"])

d.instance_shutdown
end

test "/api/config.json?debug=1" do
Expand All @@ -750,6 +763,8 @@ def get(uri, header = {})
# To check pretty print
assert_true !get("http://127.0.0.1:#{@port}/api/config.json").body.include?("\n")
assert_true get("http://127.0.0.1:#{@port}/api/config.json?debug=1").body.include?("\n")

d.instance_shutdown
end

test "/api/config.json/not_found" do
Expand All @@ -764,6 +779,8 @@ def get(uri, header = {})
assert_equal('404', resp.code)
body = JSON.parse(resp.body)
assert_equal(body['message'], 'Not found')

d.instance_shutdown
end
end

Expand Down Expand Up @@ -855,6 +872,11 @@ def write(chunk)
# it's very hard to check exact retry count (because retries are called by output flush thread scheduling)
assert{ response_retry_count >= 1 && response_retry["steps"] >= 0 }
assert{ response_retry_count == response_retry["steps"] + 1 }

output.before_shutdown
output.shutdown
output.after_shutdown
d.instance_shutdown
end
end

Expand All @@ -868,12 +890,15 @@ def write(chunk)
")
d.instance.start
assert_equal("200", get("http://127.0.0.1:#{port}/api/plugins").code)

d.instance_shutdown
end

test "worker_id = 2 on multi worker environment" do
port = unused_port(protocol: :tcp)
driver = nil
Fluent::SystemConfig.overwrite_system_config('workers' => 4) do
d = Fluent::Test::Driver::Input.new(Fluent::Plugin::MonitorAgentInput)
driver = d = Fluent::Test::Driver::Input.new(Fluent::Plugin::MonitorAgentInput)
d.instance.instance_eval{ @_fluentd_worker_id = 2 }
d.configure("
@type monitor_agent
Expand All @@ -883,6 +908,8 @@ def write(chunk)
d.instance.start
end
assert_equal("200", get("http://127.0.0.1:#{port}/api/plugins").code)

driver.instance_shutdown
end
end

Expand Down Expand Up @@ -937,6 +964,8 @@ def filter(tag, time, record)
assert_equal("200", get("http://127.0.0.1:#{port}/api/plugins.json").code)
assert{ d.logs.none?{|log| log.include?("NoMethodError") } }
assert_equal(false, d.instance.instance_variable_get(:@first_warn))

d.instance_shutdown
end
end
end