Skip to content
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 waitForSqlWithHost implementation. #310

Closed

Conversation

michielboekhoff
Copy link
Contributor

This implementation mostly copies the prior waitForSql implementation, the difference being that the waitForSqlWithHost allows the user to construct a connection string using the host of the DB container. This is especially useful in a scenario like CI (where tests are being executed in a container) or even remote Docker hosts.

To preserve backwards compatibility, and because of the way that waitForSql works, waitForSqlWithHost replicates the existing behaviour mostly. In a v1 of testcontainers-go, you would probably want to unify these two differing implementations.

One thing I would like to (personally) see in a v1 of testcontainers-go is that the underlying strategy struct is not exposed to the calling code (instead opting to return the Strategy interface) so that we can change its implementation, whereas right now we cannot, as all the fields are exposed to calling code.

This implementation mostly copies the prior waitForSql implementation,
the difference being that the waitForSqlWithHost allows the user to
construct a connection string using the host of the DB container. This
is especially useful in a scenario like CI (where our tests are being
executed in a container) or even remote Docker hosts.

To preserve backwards-compatibility, and because of the way that
`waitForSql` works, `waitForSqlWithHost` replicates the existing
behaviour mostly. In a v1 of testcontainers-go, you would probably want
to unify these two differing implementations.
@codecov
Copy link

codecov bot commented Apr 13, 2021

Codecov Report

Merging #310 (ec477cb) into main (b5ff9a2) will decrease coverage by 2.24%.
The diff coverage is 0.00%.

@@            Coverage Diff             @@
##             main     #310      +/-   ##
==========================================
- Coverage   69.79%   67.55%   -2.25%     
==========================================
  Files          21       21              
  Lines        1947     2000      +53     
==========================================
- Hits         1359     1351       -8     
- Misses        472      530      +58     
- Partials      116      119       +3     
Impacted Files Coverage Δ
wait/sql.go 11.88% <0.00%> (-13.12%) ⬇️
docker.go 69.63% <0.00%> (-0.93%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update b5ff9a2...ec477cb. Read the comment docs.

@michielboekhoff
Copy link
Contributor Author

Also, we might want to wait for #214 to be merged in before we look at this.

@michielboekhoff
Copy link
Contributor Author

@gianarb - might be great to get your feedback on this if you get a chance!

}

//Timeout sets the maximum waiting time for the strategy after which it'll give up and return an error
func (w *waitForSqlWithHost) Timeout(duration time.Duration) *waitForSqlWithHost {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In PR #322 we are considering to change the name of this method to WithTimeout in the other wait strategies.
It could be renamed here as well

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that's a great change, I'll do that when I get a chance to.

@mdelapenya
Copy link
Collaborator

@michielboekhoff I think this PR has been superseded by #524

Please let me know if I can close it, as its original intention has been already implemented and merged into main (not released yet)

@michielboekhoff
Copy link
Contributor Author

@michielboekhoff I think this PR has been superseded by #524

Please let me know if I can close it, as its original intention has been already implemented and merged into main (not released yet)

Yep, seems like it. I've closed this PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants