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

chore: split test script into test/test:coverage #3633

Closed

Conversation

pichlermarc
Copy link
Member

@pichlermarc pichlermarc commented Feb 24, 2023

Which problem is this PR solving?

Tests in windows are running out of heap space while running the @opentelemetry/instrumentation-http tests. On Linux slightly less memory is used, thus preventing the crash. As it seems like nyc is the culprit, and coverage is not reported in Windows tests in CI, this PR splits the node test script into two:

  • test which now does not run nyc
  • test:coverage which does run nyc

Workflows have been adjusted to run test:coverage when needed. We may have to increase --max-old-space-size for the tests collecting coverage in the future if this also becomes a problem on Linux. This change also has the added benefit of reducing overall memory usage while running tests and speeding up the test script in cases where collecting coverage is not needed.

Fixes #3628

Short description of the changes

  • split test script into test/test:coverage
  • adjust workflows to use the test:coverage script only when needed

Type of change

  • Internal

How Has This Been Tested?

  • Running tests locally, inspecting memory usage

Checklist:

  • Followed the style guidelines of this project
  • Unit tests have been added
  • Documentation has been updated

@codecov
Copy link

codecov bot commented Feb 24, 2023

Codecov Report

Merging #3633 (6732108) into main (abfe059) will decrease coverage by 1.30%.
The diff coverage is n/a.

❗ Current head 6732108 differs from pull request most recent head 0e23125. Consider uploading reports for the commit 0e23125 to get more accurate results

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3633      +/-   ##
==========================================
- Coverage   93.63%   92.34%   -1.30%     
==========================================
  Files         265      160     -105     
  Lines        7417     3773    -3644     
  Branches     1511      765     -746     
==========================================
- Hits         6945     3484    -3461     
+ Misses        472      289     -183     
Impacted Files Coverage Δ
.../packages/api-logs/src/platform/node/globalThis.ts 0.00% <0.00%> (-100.00%) ⬇️
...ckages/opentelemetry-exporter-zipkin/src/zipkin.ts 84.74% <0.00%> (-15.26%) ⬇️
...er-metrics-otlp-http/src/OTLPMetricExporterBase.ts 52.27% <0.00%> (-11.37%) ⬇️
packages/sdk-metrics/src/aggregator/Drop.ts
...entelemetry-instrumentation-grpc/src/grpc/index.ts
...imental/packages/opentelemetry-sdk-node/src/sdk.ts
...ental/packages/otlp-transformer/src/trace/types.ts
...nstrumentation/src/platform/node/ModuleNameTrie.ts
...ges/opentelemetry-exporter-jaeger/src/transform.ts
...s/src/exemplar/SimpleFixedSizeExemplarReservoir.ts
... and 98 more

@pichlermarc pichlermarc marked this pull request as ready for review February 24, 2023 11:48
@pichlermarc pichlermarc requested a review from a team February 24, 2023 11:48
.github/workflows/unit-test.yml Outdated Show resolved Hide resolved
@@ -24,7 +24,8 @@
"lint:fix": "eslint . --ext .ts --fix",
"lint": "eslint . --ext .ts",
"test:browser": "nyc karma start --single-run",
"test": "nyc ts-mocha -p tsconfig.json 'test/**/*.test.ts'",
"test": "ts-mocha -p tsconfig.json 'test/**/*.test.ts'",
"test:coverage": "nyc npm run test",
Copy link
Contributor

Choose a reason for hiding this comment

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

Personally, I "like" having the test coverage when compiling locally as a guide to what I'm missing....

eg. My preference would be to flip these around

  • test => full test run (with coverage)
  • test:no-coverage => just run the tests

But I may just be a bit weird 🤷‍♂️

Copy link
Member Author

@pichlermarc pichlermarc Feb 27, 2023

Choose a reason for hiding this comment

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

Actually, I may be the weird one having different workflow than most, as I'm running JetBrains WebStorm as an IDE. It may make sense to flip it around. 🙂

pinging @open-telemetry/javascript-approvers, wdyt?

Copy link
Member

Choose a reason for hiding this comment

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

What if we run the coverage by default when a single package is tested, but no coverage by default when all packages are tested? I doubt anyone is looking through coverage information when they test all 36 packages.

/package.json

{
  "scripts": {
    "test": "lerna run test:nocov",
    "test:cov": "lerna run test"
  }
}

somepackage/package.json

{
  "scripts": {
    "test": "<test command with coverage>",
    "test:nocov": "<test command without coverage"
  }
}

@pichlermarc
Copy link
Member Author

I investigated a bit further, and have come up with an alternative that (I think) tackles the cause of the excessive memory use instead and enables us to keep the scripts as-is. 🙂
See #3642

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 this pull request may close these issues.

Windows tests are failing
4 participants