-
-
Notifications
You must be signed in to change notification settings - Fork 500
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(wait): skip internal host port check #2691
feat(wait): skip internal host port check #2691
Conversation
✅ Deploy Preview for testcontainers-go ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
wait/host_port.go
Outdated
func NewHostPortStrategy(port nat.Port) *HostPortStrategy { | ||
return &HostPortStrategy{ | ||
Port: port, | ||
PollInterval: defaultPollInterval(), | ||
} | ||
} | ||
|
||
// ForExposedPortOnly returns a host port strategy that waits for the given port | ||
// to be exposed only, it does not wait for the port to be bound inside the container. | ||
func ForExposedPortOnly(port nat.Port) *HostPortStrategy { |
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 could see the value in adding a new constructor function, but I'd prefer consistency across the different wait strategies using the fluid builder pattern, something like this:
wait.ForListeningPort().SkipInternalCheck() // or any other relevant method name
I think this would be more consistent. Thoughts?
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.
Personally I find that needlessly verbose for a common option, so opted to follow the existing example set by ForListeningPort
and ForExposedPort
which admittedly only configure the port.
It could also be a bit confusing because the use case for this is when the port isn't actually listening.
What do you recon?
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.
We can probably find a better name:
- ForExternalPort, using the comments you added for the current
Only
function - ForNotBoundPort
- ForPort
- ...
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.
Agreed the Only
does seem unnecessary, how about just ForExposedPort
as that matches the existing docker terminology so makes it clear what its looking to achieve?
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.
Mmm we already have the ForExposedPort
that's why I'd add the fluid builder option to the strategy. In v1, we could go with functional options instead of the builder pattern for wait strategies.
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.
Yep forgot I added Only for that reason and naming things is hard :)
Think I'm gonna do a 180, should we do the builder SkipInternalCheck
and then review the approach for v1?
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.
Went for WithoutInternalCheck
as the SkipInternalCheck
conflicts with the field name.
409eb00
to
9b7b296
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.
LGTM! will merge once the comment on private Vs public fields is addressed.
Thanks agains for your hard work
Add the ability to skip the internal host port check when performing as HostPortStrategy check. This is useful when a container does bind to the internal port until additional conditions are met. Also improve wait for port function documentation while there.
9b7b296
to
096b855
Compare
Given we changed the field to be private, we can declare the new function as Thanks |
@stevenh the CI passed, so if my changes are good to you, then we can merge, 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.
Looks good to me!
* main: fix: config via environment (#2725) fix(redpanda): race condition on port check (#2692) fix: logging restart (#2697) fix!: docker authentication setup (#2727) chore: improve error wrapping (#2720) chore: run make tests in verbose mode (#2734) chore(deps): bump github.com/docker/docker from 27.1.0+incompatible to 27.1.1+incompatible (#2733) fix(kafka): port race on start (#2696) docs: fix broken doc tags (#2732) fix: nginx request failures (#2723) fix(compose): container locking (#2722) fix(wait): log test timeout (#2716) chore: increase timeout values (#2719) chore: remove unused parameters (#2721) chore(mockserver): silence warning about internal port (#2730) feat(wait): skip internal host port check (#2691)
Add the ability to skip the internal host port check when performing as HostPortStrategy check. This is useful when a container does bind to the internal port until additional conditions are met.