Skip to content
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

fix(dns): remove lookupPromise polyfill for node8 dns promise tests #1223

Merged
merged 3 commits into from
Oct 10, 2022

Conversation

evantorrie
Copy link
Contributor

Which problem is this PR solving?

In #110 the dns promise based tests were reinstated for node 8 via a "polyfill"-style function in the test source with
this comment.

It's unclear to me what exactly was being attempted here, since the net result of making all calls in the test function funnel through this lookupPromise() function was that the functionality that was supposed to be tested (i.e. dns.promises.lookup() was no longer tested at all.

This may have been missed because code coverage was probably not run as part of CI then, but looking at code coverage now, the code in instrumentation.ts that handles patching promise based calls is uncovered by the tests in this file.

Short description of the changes

  • Remove lookupPromise() test polyfill for dns.promise.lookup()
  • Restore original intent of test: directly call dns.promises.lookup() function.

The `lookupPromise` function emulates a Promise based dns.lookup by
creating its own Promise() object, and then calling the async callback
version of `dns.lookup()` inside it.

While this does make the tests work under Node 8, it is not at all
what these tests were originally intended to test. That is, all of the
functions in this file were testing the polyfill in this test file,
and *not* testing the promise based version of dns.lookup() that was
introduced in Node 10.6.0.

Tellingly, the tests in this code never exercise the patch code in
instrumentation.ts that handles the non-callback (i.e. Promise-based)
version of the lookup() function.

This change removes the irrelevant test function and instead reverts
to directly calling dns.promises.lookup() as existed in this code
prior to the "cleanup" in PR# 110 that nominally was "Setting up
ESLint".
@codecov
Copy link

codecov bot commented Oct 9, 2022

Codecov Report

Merging #1223 (25bffa1) into main (180b336) will increase coverage by 1.14%.
The diff coverage is 100.00%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1223      +/-   ##
==========================================
+ Coverage   96.08%   97.22%   +1.14%     
==========================================
  Files          14        4      -10     
  Lines         893      180     -713     
  Branches      191       26     -165     
==========================================
- Hits          858      175     -683     
+ Misses         35        5      -30     
Impacted Files Coverage Δ
...ode/opentelemetry-instrumentation-dns/src/utils.ts 97.95% <100.00%> (ø)
...etry-plugin-react-load/src/enums/AttributeNames.ts
...emetry-propagator-instana/src/InstanaPropagator.ts
...lugin-react-load/src/BaseOpenTelemetryComponent.ts
...metry-propagator-aws-xray/src/AWSXRayPropagator.ts
...trumentation-document-load/src/enums/EventNames.ts
...metry-propagator-ot-trace/src/OTTracePropagator.ts
...y-instrumentation-long-task/src/instrumentation.ts
...erator-aws-xray/src/internal/xray-id-generation.ts
...umentation-user-interaction/src/instrumentation.ts
... and 9 more

@evantorrie evantorrie marked this pull request as ready for review October 9, 2022 18:46
@evantorrie evantorrie requested a review from a team October 9, 2022 18:46
Copy link
Member

@rauno56 rauno56 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@rauno56 rauno56 merged commit 2777a79 into open-telemetry:main Oct 10, 2022
@dyladan dyladan mentioned this pull request Oct 10, 2022
@evantorrie evantorrie deleted the dns-node8-removal branch October 10, 2022 17:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants