Skip to content

Commit 42a1123

Browse files
committed
chore: update docs
1 parent 864fe05 commit 42a1123

File tree

2 files changed

+29
-1
lines changed

2 files changed

+29
-1
lines changed

CONTRIBUTING.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,34 @@ The conventional commit type (in PR title) is very important to automatically bu
135135

136136
There is no need to update the CHANGELOG in a PR because it will be updated as part of the release process (see [RELEASING.md](RELEASING.md) for more details).
137137

138+
### Testing
139+
140+
Most unit tests case be run via:
141+
142+
```sh
143+
npm test
144+
```
145+
146+
However, some instrumentations require test-services to be running (e.g. the `instrumentation-mongodb` package requires a MongoDB server). Use the `test-services`-related npm scripts to start all required services in Docker and then run the tests with the appropriate configuration to use those services:
147+
148+
```sh
149+
npm run test-services:start # starts services in Docker
150+
npm run test:with-services-config # runs 'npm test' with envvars from test/test-services.env
151+
npm run test-services:stop # stops services in Docker
152+
```
153+
154+
If you only want to test a sigle package (e.g. the `instrumentation-mongodb`) you can `cd` into it and run the tests after you started the services.
155+
156+
```sh
157+
npm run test-services:start # starts services in Docker
158+
cd plugins/node/opentelemetry-instrumentation-mongodb # get into the instrumenation folder
159+
RUN_MONGODB_TESTS=1 npm test # run the test with the proper config (check each package)
160+
cd ../../.. # go back to root folder
161+
npm run test-services:stop # stops services in Docker
162+
```
163+
164+
NOTE: scripts for each package will be added to avoid extra consumption of resources and improve the development experience.
165+
138166
### Benchmarks
139167

140168
When two or more approaches must be compared, please write a benchmark in the benchmark/index.js module so that we can keep track of the most efficient algorithm.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
"test-all-versions": "nx run-many -t test-all-versions",
2222
"test-services:start": "docker compose -f ./test/docker-compose.yaml up -d --wait",
2323
"test-services:stop": "docker compose -f ./test/docker-compose.yaml down",
24-
"test:with-test-services": "NODE_OPTIONS='-r dotenv/config' DOTENV_CONFIG_PATH=./test/test-services.env npm test",
24+
"test:with-services-config": "NODE_OPTIONS='-r dotenv/config' DOTENV_CONFIG_PATH=./test/test-services.env npm test",
2525
"changelog": "lerna-changelog",
2626
"lint": "nx run-many -t lint && npm run lint:deps && npm run lint:readme && npm run lint:markdown && npm run lint:semconv-deps",
2727
"lint:fix": "nx run-many -t lint:fix && npm run lint:markdown:fix",

0 commit comments

Comments
 (0)