-
Notifications
You must be signed in to change notification settings - Fork 592
chore: add test-services scripts per package #2932
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: add test-services scripts per package #2932
Conversation
npm run test:with-services-config # runs 'npm test' with envvars from test/test-services.env | ||
npm run test-services:stop # stops services in Docker | ||
npm run test-services:start # starts services in Docker | ||
npm run test:with-services-env # runs 'npm test' with envvars from test/test-services.env |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
note to reviewer: this was a typo from #2886
@@ -117,7 +117,7 @@ The required steps to start development on a pacakge are: | |||
|
|||
- `npm ci` from root folder to install dependencies ([see npm-ci docs](https://docs.npmjs.com/cli/v10/commands/npm-ci)) | |||
- `cd` into the pacakge you want to apply changes. | |||
- `npm run setup:dev` compiles the TypeScript files for this package and its dependencies within the repository. | |||
- `npm run compile:with-dependencies` compiles the TypeScript files for this package and its dependencies within the repository. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
note for reviewer: script name has changed to be more explicit about what it does. you will see this change on each package.json
that has it
"version:update": "node ../../scripts/version-update.js", | ||
"watch": "tsc -w", | ||
"test:docker:run": "docker run -d --hostname demo-amqplib-rabbit --name amqplib-unittests -p 22221:5672 --env RABBITMQ_DEFAULT_USER=username --env RABBITMQ_DEFAULT_PASS=password rabbitmq:3" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
note for reviewer: scripts with docker commands have been deleted because now the service is controlled via test-services:start
and test-services:stop
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #2932 +/- ##
==========================================
- Coverage 89.89% 89.79% -0.10%
==========================================
Files 188 188
Lines 9222 9222
Branches 1900 1900
==========================================
- Hits 8290 8281 -9
- Misses 932 941 +9 🚀 New features to boost your workflow:
|
@@ -33,62 +32,6 @@ import * as path from 'path'; | |||
import * as fs from 'fs'; | |||
import { InstrumentationBase } from '@opentelemetry/instrumentation'; | |||
|
|||
const dockerRunCmds = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
note for reviewer: not needed anymore
"tdd": "npm run test -- --watch-extensions ts --watch", | ||
"test": "nyc mocha 'test/**/*.test.ts'", | ||
"test:with-services-env": "cross-env NODE_OPTIONS='-r dotenv/config' DOTENV_CONFIG_PATH=../../test/test-services.env npm test", | ||
"//todo": "echo \"add test-all-versions\"", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
note for reviewer: this is a reminder to configure test all versions in order to get the coverage reports. There is a follow up PR which will take care of it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we necessarily want to add TAV testing for the packages that don't currently have it? For example, memcached
hasn't had a release since 2016.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd say is a nice to have.
This package does not have an assigned component owner and is considered unmaintained. As such this package is in feature-freeze and this PR will be closed with 14 days unless a new owner or a sponsor (a member of @open-telemetry/javascript-approvers) for the feature is found. It is the responsibility of the author to find a sponsor for this feature. |
…una/opentelemetry-js-contrib into add-services-scripts-per-package
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm tearing up. This is beautiful.
"tdd": "npm run test -- --watch-extensions ts --watch", | ||
"test": "nyc mocha 'test/**/*.test.ts'", | ||
"test:with-services-env": "cross-env NODE_OPTIONS='-r dotenv/config' DOTENV_CONFIG_PATH=../../test/test-services.env npm test", | ||
"//todo": "echo \"add test-all-versions\"", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we necessarily want to add TAV testing for the packages that don't currently have it? For example, memcached
hasn't had a release since 2016.
@@ -10,24 +10,24 @@ | |||
"directory": "packages/instrumentation-mongodb" | |||
}, | |||
"scripts": { | |||
"docker:start": "docker run -e MONGODB_DB=opentelemetry-tests -e MONGODB_PORT=27017 -e MONGODB_HOST=127.0.0.1 -p 27017:27017 --rm mongo", | |||
"test": "npm run test-v4 && npm run test-v5-v6", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should perhaps mention in the description that this PR is chaning the instr-mongodb tests to just test v5-v6, and leaving testing of the old versions to TAV.
"test": "npm run test-v1-v2 && npm run test-v3 && nyc merge .nyc_output ./coverage/coverage-final.json", | ||
"test-v1-v2": "tav winston 2.4.7 npm run test-run", | ||
"test-v3": "npm run test-run", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will need to deal with a merge conflict from my recent instr-winston testing change.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
commit bb454f5
@@ -1,5 +1,5 @@ | |||
RUN_CASSANDRA_TESTS=1 | |||
CASSANDRA_HOST=localhostç | |||
CASSANDRA_HOST=localhost |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps also git rm packages/instrumentation-mysql2/env
. I only just noticed this file exists. It is (almost) a subset of test/test-services.env. "Almost" because the port is different.
commit 8c2783d |
Which problem is this PR solving?
This PR is a follow-up of #2886 which aims to provide all the necessary tools/scripts in each package to work independently from others. As described in
CONTRIBUTING.md
with the added scripts a developer could start and stop the necessary services to test an instrumentation.Supersedes: #2214
Short description of the changes
test-services:start
andtest-services:stop
script in each package that requires services to run the tests. These scripts start/stop only the necessary services instead of all the ones defined in/test/docker-compose.yml
.test:with-services-env
where applies. The script sets the necessary environment variables for testing and runs the teststest-all-versions:with-services-env
script where applies. The script does liketes:with-services-env
but runstav
instead.Other changes
The scripts section of each package has been reordered to be grouped by topic: compilation, linting, test, ...
All packages now have a structure similar to this