add script to start docker container with db for unit tests#3434
add script to start docker container with db for unit tests#3434
Conversation
I don't work on a machine that has a local DB. When I started working on readiness healthcheck stuff I spent 2+ hours just trying to get one setup. In the end, I made this script from a similar one in cf-networking-release. I don't promise that it works for every CAPI use case (it only works with postgres for example), but it works great for when a new person wants to run some tests and iterate quickly. To use, run: `./scripts/docker-shell-with-started-db`
|
Thanks @ameowlia for your PR. It's always good to lower the entry barrier for new contributors. Why did you decide to run We also have a local setup with multiple containers that @FloThinksPi converted into a Codespace (see #2881). Did you had a chance to try out this setup? |
|
👋 Hi @philippthun, thanks for the response.
This is the pattern we follow for the runtime components. That way someone can run the tests without having anything but docker setup on their machine. Though I can understand your preference.
Thank you for the pointer to this. I didn't see this before. I've never used codespaces before. I am curious to see if it works without an IDE since my team develops entirely in vim on gcp vms. Feel free to close this issue if this testing patterns isn't one you want to endorse. |
|
@ameowlia The setup we added work both as a github codespace and also localy by calling e.g. Happy to hear if this setup supports you working mode :) |
Signed-off-by: Geoff Franks <gfranks@vmware.com> Co-authored-by: Geoff Franks <gfranks@vmware.com>
Add mysql support
|
|
||
| #### Running the Units Tests in Docker | ||
|
|
||
| If you don't want to set up a up a test DB locally, you can run |
There was a problem hiding this comment.
| If you don't want to set up a up a test DB locally, you can run | |
| If you don't want to set up a test DB locally, you can run |
| if [ "${db}" = "postgres" ]; then | ||
| launchDB="(/postgres-entrypoint.sh postgres &> /var/log/postgres-boot.log) &" | ||
| testConnection="psql -h localhost -U postgres -c '\conninfo'" | ||
| elif [ "${db}" = "mysql" ] || [ "${db}" = "mysql-5.6" ] || [ "${db}" = "mysql8" ]; then |
There was a problem hiding this comment.
In scripts/docker-shell-with-started-db the db variable will be set to mysql if e.g. DB=mysql8; so the two ORs are not needed.
| } | ||
|
|
||
| cd /cloud_controller_ng | ||
| export GOPATH=$PWD |
There was a problem hiding this comment.
Is this needed? We don't have Golang code...
| #### Running the Units Tests in Docker | ||
|
|
||
| If you don't want to set up a up a test DB locally, you can run | ||
| `./scripts/start-db-in-docker.sh`. This script will start a docker container |
There was a problem hiding this comment.
You run scripts/docker-shell-with-started-db from the command line, right?
I don't work on a machine that has a local DB. When I started working on readiness healthcheck stuff I spent 2+ hours just trying to get one setup. In the end, I made this script from a similar one in cf-networking-release. I don't promise that it works for every CAPI use case (it only works with postgres for example), but it works great for when a new person wants to run some tests and iterate quickly.
To use, run:
./scripts/docker-shell-with-started-dbI have reviewed the contributing guide
I have viewed, signed, and submitted the Contributor License Agreement
I have made this pull request to the
mainbranchI have run all the unit tests using
bundle exec rakeI have run CF Acceptance Tests