Skip to content

test(node): Add mysql2 auto instrumentation test for @sentry/node-experimental #10259

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

Merged
merged 5 commits into from
Jan 25, 2024

Conversation

timfish
Copy link
Collaborator

@timfish timfish commented Jan 19, 2024

This PR adds a test for mysql2 auto instrumentation for @sentry/node-experimental.

mysql2 will not query unless there is a connection and it does not want to work without one like mysql.

This PR adds a withDockerCompose method to the test runner which handles:

  • Starting the docker container
  • Waiting until some specific output has been seen from the container so we know the server is up
  • Closing and cleaning up the docker container/volumes
 createRunner(__dirname, 'scenario.js')
      .withDockerCompose({ workingDirectory: [__dirname], readyMatches: ['port: 3306'] })
      .expect({ transaction: EXPECTED_TRANSACTION })
      .start(done);

My only minor concern is that the mysql docker container creates a volume to store data. If the cleanup code does not run, a 180MB volume is left behind after every run. This will only be an issue when testing locally but we could start to fill developers machines. These can be cleaned up via docker volume prune --force but I would not want to run this on peoples machines without telling them!


mysql
.createConnection({
user: 'root',

Check failure

Code scanning / CodeQL

Hard-coded credentials

The hard-coded value "root" is used as [user name](1).
@timfish timfish marked this pull request as ready for review January 19, 2024 11:03
Copy link
Member

@mydea mydea left a comment

Choose a reason for hiding this comment

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

Is there a way to auto clean the docker stuff? Or at least to add it to yarn clean for node-integration-tests to remove all of the ones we added, or something like this? 🤔

@timfish
Copy link
Collaborator Author

timfish commented Jan 24, 2024

yarn clean will now force cleanup of the docker container and volumes

@timfish timfish requested a review from AbhiPrasad January 24, 2024 21:40
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.

3 participants