In #155 we attempted to address incompatibility with Ruby 1.9.x and instead introduced a regression which broke api_request method under Ruby 2.x. This change is intended to correct a regression introduced in #155.
Motivation and Context
Comparing the arguments for Net::HTTPGenericRequest on
1.9.1 vs 2.3.0, I see that 1.9.1 expects argument path where as 2.3.0 takes
uri_or_path argument. If the uri_or_path is not a URI object,
it is treated as the path.
I believe we can unconditionally pass the value of uri.path to
net_http_req_class(method).new on both ruby 1.9 and 2.x, as the hostname, port
and scheme are explicitly set when calling Net::HTTP.start.
In order to test this change I created an Ubuntu 16.04 VM and used the ruby-build and rbenv tools to configure two separate Ruby environments: 1.9.3-p551 and 2.3.3, respectively.
I configured a Sensu stack to process events submitted via the client's local socket and installed sensu-plugin 1.4.3 and a handler plugin in each of the aforementioned Ruby environments.
This enabled me to test this change with regard to handler accessing the API for check dependencies and silence stashes, both of which are working under both Rubies with this change.
Types of changes
[x] Bug fix (non-breaking change which fixes an issue)
[ ] New feature (non-breaking change which adds functionality)
[ ] Breaking change (fix or feature that would cause existing functionality to change)
Checklist:
[ ] My change requires a change to the documentation.
[ ] I have updated the documentation accordingly.
[x] I have updated the Changelog following the conventions laid out on Keep A Changelog
Description
In #155 we attempted to address incompatibility with Ruby 1.9.x and instead introduced a regression which broke
api_request
method under Ruby 2.x. This change is intended to correct a regression introduced in #155.Motivation and Context
Comparing the arguments for
Net::HTTPGenericRequest
on 1.9.1 vs 2.3.0, I see that 1.9.1 expects argumentpath
where as 2.3.0 takesuri_or_path
argument. If theuri_or_path
is not aURI
object, it is treated as the path.I believe we can unconditionally pass the value of
uri.path
tonet_http_req_class(method).new
on both ruby 1.9 and 2.x, as the hostname, port and scheme are explicitly set when callingNet::HTTP.start
.Closes https://github.com/sensu-plugins/sensu-plugins-sensu/issues/18 Closes https://github.com/sensu-plugins/sensu-plugin/issues/160 Closes https://github.com/sensu-plugins/sensu-plugin/issues/161
How Has This Been Tested?
In order to test this change I created an Ubuntu 16.04 VM and used the ruby-build and rbenv tools to configure two separate Ruby environments: 1.9.3-p551 and 2.3.3, respectively.
I configured a Sensu stack to process events submitted via the client's local socket and installed sensu-plugin 1.4.3 and a handler plugin in each of the aforementioned Ruby environments.
This enabled me to test this change with regard to handler accessing the API for check dependencies and silence stashes, both of which are working under both Rubies with this change.
Types of changes
Checklist:
Known Caveats