What does this PR do?
Prevents WebMock from interfering with Datadog backend communication without requiring any custom configuration on users' side. We do this by using WebMock::HttpLibAdapters::NetHttpAdapter::OriginalNetHTTP in place of Net::HTTP (if OriginalNetHTTP is present).
This change required datadog-ci to introduce its own Net::HTTP adapter as well.
Motivation
WebMock and VCR are popular libraries that are being used to stub HTTP requests when running tests. This interferes with datadog-ci communication to the Datadog backend. Users of datadog-ci have to change WebMock configuration manually to make test visibility work: it is error-prone and hard-to-debug process.
How to test the change?
Unit tests are provided. Tested using https://github.com/anmarchenko/rubocop by removing custom webmock configuration and running tests in agentless mode:
What does this PR do? Prevents WebMock from interfering with Datadog backend communication without requiring any custom configuration on users' side. We do this by using
WebMock::HttpLibAdapters::NetHttpAdapter::OriginalNetHTTP
in place ofNet::HTTP
(if OriginalNetHTTP is present).One can see that WebMock stores the original Net::HTTP in this constant here: https://github.com/bblimke/webmock/blob/fc6a2ab897a069d861adbc1c88e51b2cf8aa88ac/lib/webmock/http_lib_adapters/net_http.rb#L14
This change required
datadog-ci
to introduce its own Net::HTTP adapter as well.Motivation WebMock and VCR are popular libraries that are being used to stub HTTP requests when running tests. This interferes with
datadog-ci
communication to the Datadog backend. Users of datadog-ci have to change WebMock configuration manually to make test visibility work: it is error-prone and hard-to-debug process.How to test the change? Unit tests are provided. Tested using https://github.com/anmarchenko/rubocop by removing custom webmock configuration and running tests in agentless mode: