-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Apply newer service_discovery plugin helper methods #3362
Conversation
Signed-off-by: TAGOMORI Satoshi <[email protected]>
I'll merge it after CI is completed. |
Hmm, 2 tests are failed on all platforms 🤔
|
Plugin type is a string value, so the test should exepect a string value while the previous out_forward code pass a symbol value as a service_discovery plugin type by one-off code. Signed-off-by: Takuro Ashie <[email protected]>
A test should ensure to have only one assertion because trailing assertions aren't evalueated when an assertions is failed. It makes debugging hard. Here is an example output of the test: before: Failure: test: server is an abbreviation of static type of service_discovery(ForwardOutputTest) /home/aho/Projects/Fluentd/fluentd/test/plugin/test_out_forward.rb:282:in `block in <class:ForwardOutputTest>' <1234> expected but was <1235> diff: ? 1234 ? 5 after: Failure: test: server is an abbreviation of static type of service_discovery(ForwardOutputTest) /home/aho/Projects/Fluentd/fluentd/test/plugin/test_out_forward.rb:281:in `block in <class:ForwardOutputTest>' <[{:host=>"127.0.0.1", :port=>1234}, {:host=>"127.0.0.1", :port=>1235}]> expected but was <[{:host=>"127.0.0.1", :port=>1235}, {:host=>"127.0.0.1", :port=>1234}]> diff: ? [{:host=>"127.0.0.1", :port=>1234}, {:host=>"127.0.0.1", :port=>1235}] ? 5 4 The later one is easy to understand that the array is inverted. Signed-off-by: Takuro Ashie <[email protected]>
BTW although tests in fluentd tend to check arrays by separated assertions like this: assert_equal 2, d.instance.discovery_manager.services.size
assert_equal '127.0.0.1', d.instance.discovery_manager.services[0].host
assert_equal 1234, d.instance.discovery_manager.services[0].port
assert_equal '127.0.0.1', d.instance.discovery_manager.services[1].host
assert_equal 1235, d.instance.discovery_manager.services[1].port I don't like such tests because it makes hard to debug. assert_equal(
[
{ host: '127.0.0.1', port: 1234 },
{ host: '127.0.0.1', port: 1235 },
],
d.instance.discovery_manager.services.collect do |service|
{ host: service.host, port: service.port }
end
) Here is an example output: before:
after:
The later one is easy to understand that the array is inverted. |
"server" directive should have higher priority than "service" in "service_discovery" to keep backward compatibility. Signed-off-by: Takuro Ashie <[email protected]>
tests passed (without a known unstable test). |
Don't worry 😃 |
That looks perfect! |
Which issue(s) this PR fixes:
none
What this PR does / why we need it:
Apply a new helper method added at #3299 to out_forward.
This PR is revised version of #3300 which was closed unexpectedly.
Docs Changes:
Same with #3299
Release Note:
Same with #3299