-
Notifications
You must be signed in to change notification settings - Fork 362
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
add script to start docker container with db for unit tests #3434
base: main
Are you sure you want to change the base?
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 <[email protected]> Co-authored-by: Geoff Franks <[email protected]>
Add mysql support
@@ -116,6 +116,14 @@ keep it up to date, documenting the purpose of the various types of tests. | |||
|
|||
By default `rspec` will randomly pick between postgres and mysql. | |||
|
|||
#### 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In scripts/docker-shell-with-started-db
the db
variable will be set to mysql
if e.g. DB=mysql8
; so the two OR
s are not needed.
} | ||
|
||
cd /cloud_controller_ng | ||
export GOPATH=$PWD |
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.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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-db
I have reviewed the contributing guide
I have viewed, signed, and submitted the Contributor License Agreement
I have made this pull request to the
main
branchI have run all the unit tests using
bundle exec rake
I have run CF Acceptance Tests