-
Notifications
You must be signed in to change notification settings - Fork 90
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
run mysql in docker and load sql scripts in test/integration/sql/ #25
base: v3
Are you sure you want to change the base?
Conversation
If you get |
Now passing on travis. I had to use another port than 3306, and had some issues around port forwarding. But it's now resolved. It did require some small changes to
I have a feeling that the host/port parsing need a little love. |
This looks great! Thanks for taking the time to do this. I was wondering if a What do you think? |
@mrjgreen As far as I understand, then As with Docker itself, there is no easy cross platform install. So you have to throw an error, instructing people to go to docker.com and install tools. It's already bad that there is no auto-install of Docker. Adding more required tools, to run When trying out docker configurations, you really want to be able to create/remove different layers easily. I find that the composer scripts does a very good job at that.
I think it's easier to grok these things, when you can see the implementation right there in It makes sense to use Docker Compose though, when managing multiple images for the same app. With the little caveat that a database docker image can not serve requests before the database is initialized and Docker Compose will start each container at the same time, so a container that needs to make DB requests will need to be paused for arbitrary seconds before making the first request. BTW, the configuration for |
One thing that would simplify the docker process, is if we could use the default Well, we still risk IP address collision but at least it would shave off two composer scripts. |
@mrjgreen So I eventually found out why I could not connect to the docker instance through the proxy port, when using an dynamic ip address in the default If you want to inspect the network, I can recommend There is now no risk of IP collision, since docker will assign IP in its network. If the user change the default network range, docker will assign the mysql image to that range. So all is good I can't think of any thing else to amend to this PR. I think you should handle the data conversion from PHP land to Better parsing of host:port would be nice. But unless I run it that problem in my project. I will probably not fix it. |
A few pointers to help you inspect Docker.
You can use 3 if you really just want to get inside mysql but I recommend 2, since that is the access every container or PHP script you write will gain access. 3 can work, even if 2 doesn't. |
This post helped me a lot to understand the workings of docker network: moby/moby#2174 (comment) |
- setup docker on travis - speed up travis build by caching the vendor directory - used by composer install - Describe how to run tests with Docker - be double sure that the docker instance has started before we run tests - this implementation asures that double dash parameters are forwarded correctly to phpunit from outside (e.i. .travis.yml)
This is a highly experimental PR but so far I have made good progress, running all tests in a mysql docker instance.
This requires docker to be installed: https://docs.docker.com/engine/installation/
I have not found an easy way to auto install docker cross platform.
Usage
In the terminal write:
composer docker:setup
, which is a shorthand for the following:1
composer docker:network:create
2
composer docker:create
3
composer docker:start
Then start the tests via
composer test
as usual.Feature
.sql
scripts found intest/integration/sql/
on creationI'm on linux ubuntu, so am eager to know how the setup works in other OS'es, especially Windows and macOS.
Give it a shot!