Skip to content

Fix for getaddrinfo failures on Windows 10 in MongoDbContainer - #100

Closed
arpost wants to merge 19 commits into
testcontainers:masterfrom
arpost:npipe-hostname-fix
Closed

arpost wants to merge 19 commits into
testcontainers:masterfrom
arpost:npipe-hostname-fix

Conversation

@arpost

@arpost arpost commented Jun 8, 2020

Copy link
Copy Markdown

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.
Comment thread testcontainers/core/docker_client.py Outdated
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
Copy Markdown
Contributor

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

arpost commented Jun 20, 2020 via email

Copy link
Copy Markdown
Author

@arpost

arpost commented Jul 4, 2020

Copy link
Copy Markdown
Author

I updated the pull request with the npipe check.

@codecov-io

Copy link
Copy Markdown

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
Comment thread tests/test_nginx_container.py Outdated
port = nginx.port_to_expose
url = "http://{}:{}/".format(nginx.get_container_host_ip(),
nginx.get_exposed_port(port))
time.sleep(5)

Copy link
Copy Markdown
Contributor

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

arpost commented Mar 29, 2021 via email

Copy link
Copy Markdown
Author

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

codecov-commenter commented Jul 15, 2021 •

Copy link
Copy Markdown

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
Copy Markdown
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