-
Notifications
You must be signed in to change notification settings - Fork 22
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
feat: Add wait_for_* functions in NetworkUtil for performing check on port, host, http_code #216
feat: Add wait_for_* functions in NetworkUtil for performing check on port, host, http_code #216
Conversation
… port, host, http_code or 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.
This is a good start 👍🏼
The docker part add too much complexity IMHO. Could you split the PR in two? one without docker, and one with docker?
Like that we could merge the first one ASAP
Hey, thanks for your feedback 😃 I deleted the docker part, I'll do the PR later 😄 I've corrected the main feedback, I'm waiting to get home to finalize the last fixes :) (phpstan can't run in codespace 🥲) I'll refactor the code to add the |
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.
Except one little comment, the code is OKAY
Could you also
- Add a note in the CHANGELOG.md
- Add some documentation
Thanks
I really like your PR, thanks for your contribution @TheoD02 🙌 I only worry about the class NetworkUtil you introduced because every others helpers Castor provide are functions and not class methods. So I would prefer your new helpers to be functions too, alongside the ones already existing. |
Add documentation and examples Add CHANGELOG.md
Re, I fixed the latest feedback I added the doc, changelog, tests :) Can you review the NetworkUtil class again, I've made quite a few changes to it ? I've added a generic |
yes, there is a bug ATM in symfony :/ Could you try to add thanks |
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.
I let some comments about the arguments // options.
Otherwise, It's cool 👏🏼 thanks
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.
Yeah ! This is very nice. Thanks !
LGTM
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.
Nice work 🙂
Hello all! :)
The PR responds to the demand of the issue #207
Here is the first draft of what is possible 🙂
For all methods, a
$quiet = false
and$throw = false
parameter is available to permit not showing anything or throwing instead of returning a boolean on check success/fail.I have introduced a
wait_for_port
that can be useful to wait for port X on host X.wait_for_url
to wait for a certain URL to be accessible.wait_for_http_status
to wait for a certain URL with a specific status code (default to 200).Additional idea not in PR: A callable can be added to check if some content is present in the request to continue, for example.
(Maybe duplicate with the first
wait_for_url
. Is it useful to keep both?)wait_for_docker_container
is a helper that can be used only when Docker is present. It can autostart the container and use both Docker or Docker Compose approach, and auto-check the binded ports or those provided by default.Ports can be auto-detected by Docker inspect only when
portsToCheck
is equal to[]
.I added one callback
additionalCheck
that is useful when, for example, with MySQL, the container is UP, the port is accessible, but it cannot do anything for a certain time until the container is fully ready. For this case, I run a MySQL Query to check until it responds to go forward.Example for the MySQL case:
The container started, and 3306 seems to be accessible, but not really fully available.
When the available check is present, the check is performed before doing anything in the MySQL container.
That is a case I already have in a project. I think I'm not alone 😀
Please tell me your feedback and suggestions :)
I don't really know how I can fully test this for now, but I will work on it, at least for the non-Docker
wait_for
part.