Skip to content

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

Open
wants to merge 13 commits into
base: main
Choose a base branch
from

Conversation

david-luna
Copy link
Contributor

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

  • add test-services:start and test-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.
  • add test:with-services-env where applies. The script sets the necessary environment variables for testing and runs the tests
  • add test-all-versions:with-services-env script where applies. The script does like tes:with-services-env but runs tav instead.

Other changes

The scripts section of each package has been reordered to be grouped by topic: compilation, linting, test, ...

All packages no have s structure similar to this

{
    // compile topic
    "clean": "tsc --build --clean tsconfig.json tsconfig.esm.json",
    "compile": "tsc -p .",
    "compile:with-dependencies": "nx run-many -t compile -p @opentelemetry/sampler-aws-xray",
    // linting topic
    "lint": "eslint . --ext .ts",
    "lint:fix": "eslint . --ext .ts --fix",
    // publish topic
    "prepublishOnly": "npm run compile",
    // test topic
    "tdd": "npm run test -- --watch-extensions ts --watch",
    "test": "nyc mocha 'test/**/*.test.ts'",
    // others topic
    "version:update": "node ../../scripts/version-update.js",
    "watch": "tsc --build --watch tsconfig.json tsconfig.esm.json"
}

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
Copy link
Contributor Author

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.
Copy link
Contributor Author

@david-luna david-luna Jul 9, 2025

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"
Copy link
Contributor Author

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

Copy link

codecov bot commented Jul 9, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 88.95%. Comparing base (8d05684) to head (a2e0266).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2932      +/-   ##
==========================================
- Coverage   89.05%   88.95%   -0.10%     
==========================================
  Files         188      188              
  Lines        9189     9189              
  Branches     1891     1891              
==========================================
- Hits         8183     8174       -9     
- Misses       1006     1015       +9     

see 1 file with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@@ -33,62 +32,6 @@ import * as path from 'path';
import * as fs from 'fs';
import { InstrumentationBase } from '@opentelemetry/instrumentation';

const dockerRunCmds = {
Copy link
Contributor Author

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\"",
Copy link
Contributor Author

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

@david-luna david-luna changed the title chore: add test-services scripts chore: add test-services scripts per package Jul 9, 2025
Copy link
Contributor

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.
Are you familiar with this package? Consider becoming a component owner.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pkg:auto-configuration-propagators pkg:auto-instrumentations-node pkg:auto-instrumentations-web pkg:host-metrics pkg:id-generator-aws-xray pkg:instrumentation-amqplib pkg:instrumentation-aws-lambda pkg:instrumentation-aws-sdk pkg:instrumentation-bunyan pkg:instrumentation-cassandra-driver pkg:instrumentation-connect pkg:instrumentation-cucumber pkg:instrumentation-dataloader pkg:instrumentation-dns pkg:instrumentation-document-load pkg:instrumentation-express pkg:instrumentation-fastify pkg:instrumentation-fs pkg:instrumentation-generic-pool pkg:instrumentation-graphql pkg:instrumentation-hapi pkg:instrumentation-ioredis pkg:instrumentation-kafkajs pkg:instrumentation-knex pkg:instrumentation-koa pkg:instrumentation-long-task pkg:instrumentation-lru-memoizer pkg:instrumentation-memcached pkg:instrumentation-mongodb pkg:instrumentation-mongoose pkg:instrumentation-mysql pkg:instrumentation-mysql2 pkg:instrumentation-nestjs-core pkg:instrumentation-net pkg:instrumentation-oracledb pkg:instrumentation-pg pkg:instrumentation-pino pkg:instrumentation-redis pkg:instrumentation-restify pkg:instrumentation-router pkg:instrumentation-runtime-node pkg:instrumentation-socket.io pkg:instrumentation-tedious pkg:instrumentation-undici pkg:instrumentation-user-interaction pkg:instrumentation-winston pkg:plugin-react-load pkg:propagation-utils pkg:propagator-aws-xray pkg:propagator-aws-xray-lambda pkg:propagator-instana pkg:propagator-ot-trace pkg:redis-common pkg:resource-detector-alibaba-cloud pkg:resource-detector-aws pkg:resource-detector-azure pkg:resource-detector-container pkg:resource-detector-gcp pkg:resource-detector-github pkg:resource-detector-instana pkg:sampler-aws-xray pkg:sql-common pkg:test-utils pkg-status:unmaintained:autoclose-scheduled pkg-status:unmaintained This package is unmaintained. Only bugfixes may be acceped until a new owner has been found.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

10 participants