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

feat: pass agent options when using agent pool config #149

Merged
merged 4 commits into from Apr 5, 2020

Conversation

zamnuts
Copy link
Contributor

@zamnuts zamnuts commented Mar 31, 2020

  1. Defines the pool as used in @google-cloud/common: https://github.com/googleapis/nodejs-common/blob/v3.0.0/src/util.ts#L37-L40
  2. All properties optionally defined in pool are passed through to the underlying agent, only if the agent is to be created
  3. pool is now a "protected" member, only to make test cases possible given the singleton~ish variable bleed
  4. fixed forever tests that were supposed to test https, but actually were testing http
  5. enhanced existing agent tests to ensure the proxy data was actually picked up by the agent
  • Make sure to open an issue as a bug/issue before writing your code! That way we can discuss the change, evaluate designs, and agree on the general idea
  • Ensure the tests and linter pass
  • Code coverage does not decrease (if any source code was changed)
  • Appropriate docs were updated (if necessary)

Fixes #148 🦕

@googlebot googlebot added the cla: yes This human has signed the Contributor License Agreement. label Mar 31, 2020
@codecov
Copy link

codecov bot commented Mar 31, 2020

Codecov Report

Merging #149 into master will increase coverage by 0.47%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #149      +/-   ##
==========================================
+ Coverage   73.48%   73.95%   +0.47%     
==========================================
  Files           2        2              
  Lines         396      407      +11     
  Branches       41       40       -1     
==========================================
+ Hits          291      301      +10     
  Misses        104      104              
- Partials        1        2       +1     
Impacted Files Coverage Δ
src/agents.ts 98.59% <100.00%> (-1.41%) ⬇️
src/index.ts 68.75% <100.00%> (+0.18%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 2e12180...ba77e2d. Read the comment docs.

src/agents.ts Outdated Show resolved Hide resolved
Copy link
Contributor

@bcoe bcoe left a comment

Choose a reason for hiding this comment

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

This looks good to me, if @JustinBeckwith's comments about deferred loading are addressed.

Have you tested manually end to end (since we unfortunately don't have a system test suite).

@zamnuts
Copy link
Contributor Author

zamnuts commented Apr 1, 2020

@bcoe i did not test manually end-to-end (e.g. npm link ...). the unit tests have nock for which all tests passed FYI, but I'll go ahead and run system-test in a few libraries that use it and report back.

@zamnuts
Copy link
Contributor Author

zamnuts commented Apr 5, 2020

Manual regression testing was performed against nodejs-logging and nodejs-bigquery using their system-test with npm link teeny-request, and both were successful. I tried nodejs-pubsub, but its system-test didn't complete successfully (even w/o link, i.e. unrelated).

Note in the expandable log output below, the "using linked agent with options" output is not in this PR, but was a console logging entry used for illustrative purposes during testing. Additionally, some unnecessary information was redacted.

Evidence for nodejs-logging
nodejs-logging (master ✔) ᐅ npm link teeny-request
/home/user/.../nodejs-logging/node_modules/teeny-request -> /home/user/.nvm/versions/node/v10.19.0/lib/node_modules/teeny-request -> /home/user/.../teeny-request
nodejs-logging (master ✔) ᐅ git rev-parse HEAD
ce29b498ebb357403c093053d1b9989f1a56f5af
nodejs-logging (master ✔) ᐅ GOOGLE_APPLICATION_CREDENTIALS=/home/user/....json npm run system-test
> @google-cloud/logging@7.3.0 system-test /home/user/.../nodejs-logging
> mocha build/system-test --timeout 600000

  typescript consumer tests
using linked agent with options:  { maxSockets: Infinity }
using linked agent with options:  { maxSockets: Infinity }
using linked agent with options:  { maxSockets: Infinity }
    ✓ should have correct type signature for typescript users (7065ms)
    ✓ should have correct type signature for javascript users (8996ms)

  sinks
using linked agent with options:  { maxSockets: Infinity }
    ✓ should create a sink with a Bucket destination (1235ms)
using linked agent with options:  { maxSockets: Infinity }
using linked agent with options:  { maxSockets: Infinity }
    ✓ should create a sink with a Dataset destination (1404ms)
    ✓ should create a sink with a Topic destination (1828ms)
    metadata
      ✓ should set metadata (389ms)

...

Deleting 24 test logs...
23/24 logs deleted

  34 passing (3m)
Evidence for nodejs-bigquery
nodejs-bigquery (insert-retries ✔) ᐅ npm link teeny-request
/home/user/.../nodejs-bigquery/node_modules/teeny-request -> /home/user/.nvm/versions/node/v10.19.0/lib/node_modules/teeny-request -> /home/user/.../teeny-request
nodejs-bigquery (insert-retries ✔) ᐅ git rev-parse HEAD
ef1b538176103dea09c82e3ce4e2fe437a26c183
nodejs-bigquery (insert-retries ✔) ᐅ GOOGLE_APPLICATION_CREDENTIALS=/home/user/....json npm run system-test
> @google-cloud/bigquery@4.7.0 system-test /home/user/.../nodejs-bigquery
> mocha build/system-test --timeout 600000

  BigQuery
using linked agent with options:  { maxSockets: Infinity }
using linked agent with options:  { maxSockets: Infinity }
using linked agent with options:  { maxSockets: Infinity }
using linked agent with options:  { maxSockets: Infinity }
using linked agent with options:  { maxSockets: Infinity }
using linked agent with options:  { maxSockets: Infinity }
    ✓ should get a list of datasets (492ms)
using linked agent with options:  { maxSockets: Infinity }
    ✓ should allow limiting API calls (520ms)
using linked agent with options:  { maxSockets: Infinity }
    ✓ should return a promise (209ms)
using linked agent with options:  { maxSockets: Infinity }
    ✓ should allow limiting API calls via promises (518ms)

...

    ✓ should be able to use the d.ts (12252ms)


  95 passing (4m)

Copy link
Contributor

@JustinBeckwith JustinBeckwith left a comment

Choose a reason for hiding this comment

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

LGTM assuming it works everywhere we expect it to 🙃

@zamnuts zamnuts merged commit 38ece79 into master Apr 5, 2020
@zamnuts zamnuts deleted the feature/pass-agent-options branch April 5, 2020 22:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla: yes This human has signed the Contributor License Agreement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

maxSockets is not passed to the underlying agent when forever:true
4 participants