Skip to content

Fix for getaddrinfo failures on Windows 10 in MongoDbContainer #100

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

Closed
wants to merge 19 commits into from

Conversation

arpost
Copy link

@arpost arpost commented Jun 8, 2020

Windows npipe URIs are rewritten by the docker-py client library to http+docker://localnpipe. Other pipe-like URIs are rewritten this way too. So, core/docker_client.py should detect the http+docker scheme instead of "npipe" and return localhost. Because the check for "http" schemes will inadvertently pick up the http+docker scheme too, do the check for pipes first and for real URLs second. Fixes issue #99. All tests pass with this fix on Windows 10 with Docker Desktop running locally.

…-py client library to http+docker://localnpipe. Other pipe-like URIs are rewritten this way too. So, the code should detect the http+docker scheme instead of "npipe" and return localhost. Because the check for "http" schemes will inadvertently pick up the http+docker scheme too, do the check for pipes first and for real URLs second.
if 'http' in url.scheme or 'tcp' in url.scheme:
return url.hostname
if 'unix' in url.scheme or 'npipe' in url.scheme:
if 'unix' in url.scheme or 'http+docker' == url.scheme:
Copy link
Collaborator

Choose a reason for hiding this comment

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

Should npipe also be included in this check for backwards compatibility?

@arpost
Copy link
Author

arpost commented Jun 20, 2020 via email

@arpost
Copy link
Author

arpost commented Jul 4, 2020

I updated the pull request with the npipe check.

@codecov-io
Copy link

Codecov Report

Merging #100 (2685685) into master (48ea7b8) will increase coverage by 1.32%.
The diff coverage is 88.57%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #100      +/-   ##
==========================================
+ Coverage   80.61%   81.93%   +1.32%     
==========================================
  Files          20       20              
  Lines         459      476      +17     
  Branches       34       35       +1     
==========================================
+ Hits          370      390      +20     
+ Misses         70       66       -4     
- Partials       19       20       +1     
Impacted Files Coverage Δ
testcontainers/core/container.py 80.23% <0.00%> (-0.95%) ⬇️
testcontainers/core/docker_client.py 55.55% <25.00%> (-1.59%) ⬇️
testcontainers/compose.py 100.00% <100.00%> (ø)
testcontainers/core/generic.py 100.00% <100.00%> (ø)
testcontainers/mongodb.py 100.00% <100.00%> (+23.80%) ⬆️

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 95ac492...1413124. Read the comment docs.

arpost and others added 3 commits March 19, 2021 17:21
* adding kafka containers support

* Removing the assertions inside the for loop as they are not guarenteed to provide correct feedback
@@ -9,6 +10,7 @@ def test_docker_run_nginx():
port = nginx.port_to_expose
url = "http://{}:{}/".format(nginx.get_container_host_ip(),
nginx.get_exposed_port(port))
time.sleep(5)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can we drop the sleeps?

@arpost
Copy link
Author

arpost commented Mar 29, 2021 via email

Petrosyuk and others added 8 commits April 15, 2021 18:42
* adding support for passing custom env-file (testcontainers#134)

* adding support for passing env-file to DockerCompose (testcontainers#134)

* fixed flake8

* trigger Gihub Actions again

Co-authored-by: Anton Petrosyuk <[email protected]>
…-py client library to http+docker://localnpipe. Other pipe-like URIs are rewritten this way too. So, the code should detect the http+docker scheme instead of "npipe" and return localhost. Because the check for "http" schemes will inadvertently pick up the http+docker scheme too, do the check for pipes first and for real URLs second.
@codecov-commenter
Copy link

codecov-commenter commented Jul 15, 2021

Codecov Report

Merging #100 (2685685) into master (48ea7b8) will increase coverage by 1.32%.
The diff coverage is 88.57%.

❗ Current head 2685685 differs from pull request most recent head 1106e3b. Consider uploading reports for the commit 1106e3b to get more accurate results
Impacted file tree graph

@@            Coverage Diff             @@
##           master     #100      +/-   ##
==========================================
+ Coverage   80.61%   81.93%   +1.32%     
==========================================
  Files          20       20              
  Lines         459      476      +17     
  Branches       34       35       +1     
==========================================
+ Hits          370      390      +20     
+ Misses         70       66       -4     
- Partials       19       20       +1     
Impacted Files Coverage Δ
testcontainers/core/container.py 80.23% <0.00%> (-0.95%) ⬇️
testcontainers/core/docker_client.py 55.55% <25.00%> (-1.59%) ⬇️
testcontainers/compose.py 100.00% <100.00%> (ø)
testcontainers/core/generic.py 100.00% <100.00%> (ø)
testcontainers/mongodb.py 100.00% <100.00%> (+23.80%) ⬆️

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 95ac492...1106e3b. Read the comment docs.

@arpost arpost closed this Jul 16, 2021
@arpost arpost deleted the npipe-hostname-fix branch July 16, 2021 00:28
@alexanderankin
Copy link
Member

what was the end outcome here?

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

Successfully merging this pull request may close these issues.

8 participants