-
Notifications
You must be signed in to change notification settings - Fork 5
Replace run-with-docker.sh with testcontainer #301
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
base: main
Are you sure you want to change the base?
Replace run-with-docker.sh with testcontainer #301
Conversation
This stack of pull requests is managed by Graphite. Learn more about stacking. |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #301 +/- ##
=======================================
Coverage 97.39% 97.39%
=======================================
Files 87 87
Lines 11894 11894
Branches 1038 962 -76
=======================================
Hits 11584 11584
- Misses 303 310 +7
+ Partials 7 0 -7
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
cd9cf6c
to
c2ca1e9
Compare
51c6e40
to
10d14c4
Compare
c2ca1e9
to
398852e
Compare
10d14c4
to
b0bbb62
Compare
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.
b0bbb62
to
8147db5
Compare
398852e
to
0038d63
Compare
8147db5
to
cfd54a3
Compare
e883c4e
to
5fc9b3b
Compare
5fc9b3b
to
cfeca43
Compare
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.
When I run yarn test
(or yarn test --selectProjects integration
) from the root, a decent number of tests time out. I have a feeling it might be due to each test starting its own container? In general, I worry that this slows down integration tests quite a bit now. I recall during an earlier iteration of this PR it still used a shared testcontainer? (the DockerComposeEnvironment
in integration-setup.js)
...ges/entity-full-integration-tests/src/__integration-tests__/EntityCacheInconsistency-test.ts
Outdated
Show resolved
Hide resolved
For example: I really like the idea of them being able to run concurrently though. |
b701e32
to
cc926dd
Compare
cc926dd
to
4822750
Compare
Each test starts its own service dependencies, transparently downloading and/or re-using docker images. This allows all tests to be run in one command.
4822750
to
448d75b
Compare
There's now a setup file that ensures all used images are pulled before any integration tests are run. This can't time out, but if it fails the error message will be visible. The tests consistently take about 10 seconds on my machine. |
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.
Couple issues:
- When I run
yarn integration
from the root on my machine (and re-running it, too), most tests seem to time out:Test Suites: 10 failed, 5 passed, 15 total Tests: 59 failed, 10 passed, 69 total Snapshots: 0 total Time: 11.9 s, estimated 12 s
- When I run
yarn integration
frompackages/entity-database-adapter-knex
I getUsage Error: Couldn't find a script named "test:integration"
.
Happy to hop on a call if you're unable to repro the timeouts on your side.
Why
In CI it takes the same time, but locally it's usually a lot faster, since the common case is that the docker images are already downloaded, and since each test suite running its own services means the integration tests can be run concurrently, even alongside unit tests.
Generally it's easier to run all the tests with the new command
yarn test:all
and also simpler to run individual tests, and anything in between.How
testcontainer is a library made by Docker to handle disposable containers for tests.
It can process docker compose files, and at first I was going to only replace the shell script with global setup js files, but to gain the advantages listed in 'Why`, since there weren't too many involved tests, I added code to each test suite to start and stop its own services. Also, there was no need to track and share ports or connection info.
I think some of this could be moved into entity-testing-utils, but I decided to wait on that.
Test plan
docker system prune -a
(delete all locally cached images)yarn test:all
(downloads images first)yarn test:all
(runs with downloaded images in less than 10 seconds)