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

Perform UnitTest with real application insights too long #475

Closed
guenogu opened this issue Jan 4, 2019 · 3 comments · Fixed by #478
Closed

Perform UnitTest with real application insights too long #475

guenogu opened this issue Jan 4, 2019 · 3 comments · Fixed by #478

Comments

@guenogu
Copy link

guenogu commented Jan 4, 2019

Hello,

I'm working on a Hapi server application.
I try to integrate the package applicationinsights to my application.

My application is cover by unit test (mocha), but when I use a real instrumentation key the unit test execution is quite long ( >60s) and when the instrumentation key is a fake ikey then the execution is more performant (<3s).

To help you to reproduce and understand my issue, I have push the code in this branch
https://github.com/guenogu/repro/tree/hapi-wreck-appinsights

Thanks for your help.

@OsvaldoRosado
Copy link
Member

OsvaldoRosado commented Jan 8, 2019

This SDK is optimized for use in long-running server scenarios, rather than quick termination. One such optimization is that it will wait for 15 seconds before sending telemetry to optimize network traffic by batching all of the telemetry into a single request. There are other optimizations in place similar to this - and I'm guessing that these are what impact its use within unit tests.

Some things to try, in no particular order (you may need all of them, or only one):

  1. .setUseDiskRetryCaching(false)
  2. appInsights.defaultClient.config.maxBatchIntervalMs = 0
  3. .setAutoCollectPerformance(false)
  4. appInsights.defaultClient.flush() (at the end of your test sequence)

If your tests don't actually need to emit telemetry, you can also use appInsights.defaultClient.config.disableAppInsights = true;

@markwolff
Copy link
Contributor

markwolff commented Jan 11, 2019

@guenogu which version of mocha are you using?
Edit: looked at your repo, you are using 5.2

@markwolff
Copy link
Contributor

@guenogu You can fix this for now by adding --exit to your mocha command, as per links below. We should investigate why our tests do not terminate.
mochajs/mocha#2879
https://boneskull.com/mocha-v4-nears-release/#mochawontforceexit

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants