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

proxy from environment variable transport tests fail #1968

Closed
xrmx opened this issue Feb 15, 2024 · 1 comment · Fixed by #1969
Closed

proxy from environment variable transport tests fail #1968

xrmx opened this issue Feb 15, 2024 · 1 comment · Fixed by #1969
Labels
agent-python community Issues opened by the community triage Issues awaiting triage

Comments

@xrmx
Copy link
Member

xrmx commented Feb 15, 2024

Describe the bug:

==================================================================================================== FAILURES =====================================================================================================
______________________________________________________________________________________ test_https_proxy_environment_variable ______________________________________________________________________________________

elasticapm_client = <tests.fixtures.TempStoreClient object at 0x7f7d6cca0810>

    def test_https_proxy_environment_variable(elasticapm_client):
        with mock.patch.dict("os.environ", {"HTTPS_PROXY": "https://example.com"}):
            transport = Transport("http://localhost:9999", client=elasticapm_client)
>           assert isinstance(transport.http, urllib3.poolmanager.ProxyManager)
E           AssertionError: assert False
E            +  where False = isinstance(<urllib3.poolmanager.PoolManager object at 0x7f7d6ccb7c90>, <class 'urllib3.poolmanager.ProxyManager'>)
E            +    where <urllib3.poolmanager.PoolManager object at 0x7f7d6ccb7c90> = <elasticapm.transport.http.Transport object at 0x7f7d6ccb6610>.http
E            +    and   <class 'urllib3.poolmanager.ProxyManager'> = <module 'urllib3.poolmanager' from '/home/rm/work/elastic/apm-agent-python/venv311/lib/python3.11/site-packages/urllib3/poolmanager.py'>.ProxyManager
E            +      where <module 'urllib3.poolmanager' from '/home/rm/work/elastic/apm-agent-python/venv311/lib/python3.11/site-packages/urllib3/poolmanager.py'> = urllib3.poolmanager

tests/transports/test_urllib3.py:126: AssertionError
_______________________________________________________________________________ test_https_proxy_environment_variable_is_preferred ________________________________________________________________________________

elasticapm_client = <tests.fixtures.TempStoreClient object at 0x7f7d6ccade10>

    def test_https_proxy_environment_variable_is_preferred(elasticapm_client):
        with mock.patch.dict("os.environ", {"https_proxy": "https://example.com", "HTTP_PROXY": "http://example.com"}):
            transport = Transport("http://localhost:9999", client=elasticapm_client)
>           assert isinstance(transport.http, urllib3.poolmanager.ProxyManager)
E           AssertionError: assert False
E            +  where False = isinstance(<urllib3.poolmanager.PoolManager object at 0x7f7d6cc86a90>, <class 'urllib3.poolmanager.ProxyManager'>)
E            +    where <urllib3.poolmanager.PoolManager object at 0x7f7d6cc86a90> = <elasticapm.transport.http.Transport object at 0x7f7d6ccacad0>.http
E            +    and   <class 'urllib3.poolmanager.ProxyManager'> = <module 'urllib3.poolmanager' from '/home/rm/work/elastic/apm-agent-python/venv311/lib/python3.11/site-packages/urllib3/poolmanager.py'>.ProxyManager
E            +      where <module 'urllib3.poolmanager' from '/home/rm/work/elastic/apm-agent-python/venv311/lib/python3.11/site-packages/urllib3/poolmanager.py'> = urllib3.poolmanager

tests/transports/test_urllib3.py:132: AssertionError
______________________________________________________________________________________ test_http_proxy_environment_variable _______________________________________________________________________________________

elasticapm_client = <tests.fixtures.TempStoreClient object at 0x7f7d6c35fe10>

    def test_http_proxy_environment_variable(elasticapm_client):
        with mock.patch.dict("os.environ", {"HTTP_PROXY": "http://example.com"}):
            transport = Transport("http://localhost:9999", client=elasticapm_client)
>           assert isinstance(transport.http, urllib3.ProxyManager)
E           AssertionError: assert False
E            +  where False = isinstance(<urllib3.poolmanager.PoolManager object at 0x7f7d6c3422d0>, <class 'urllib3.poolmanager.ProxyManager'>)
E            +    where <urllib3.poolmanager.PoolManager object at 0x7f7d6c3422d0> = <elasticapm.transport.http.Transport object at 0x7f7d6c36e810>.http
E            +    and   <class 'urllib3.poolmanager.ProxyManager'> = urllib3.ProxyManager

tests/transports/test_urllib3.py:120: AssertionError

To Reproduce

  1. pip install -r tests/requirements/reqs-base.txt
  2. pytest

Environment (please complete the following information)

  • OS: [e.g. Linux] Linux
  • Python version: 3.11.8
  • Framework and version [e.g. Django 2.1]: -
  • APM Server version: -
  • Agent version: main

Additional context

None

@github-actions github-actions bot added agent-python community Issues opened by the community triage Issues awaiting triage labels Feb 15, 2024
@xrmx xrmx changed the title tests fails with urllib3 2.0.6 proxy from environment variable transport tests fail Feb 15, 2024
@xrmx
Copy link
Member Author

xrmx commented Feb 15, 2024

For some reasons I have localhost in proxy_bypass_environment.

xrmx added a commit to xrmx/apm-agent-python that referenced this issue Feb 15, 2024
When mocking os.environ pass clear=True to avoid getting host
configurations.

Fix elastic#1968
xrmx added a commit to xrmx/apm-agent-python that referenced this issue Feb 15, 2024
When mocking os.environ pass clear=True to avoid getting host
configurations.

Fix elastic#1968
xrmx added a commit to xrmx/apm-agent-python that referenced this issue Feb 15, 2024
When mocking os.environ pass clear=True to avoid getting host
configurations.

Fix elastic#1968
xrmx added a commit that referenced this issue Feb 16, 2024
…1969)

When mocking os.environ pass clear=True to avoid getting host
configurations.

Fix #1968
xrmx added a commit that referenced this issue Mar 20, 2024
…1969)

When mocking os.environ pass clear=True to avoid getting host
configurations.

Fix #1968
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
agent-python community Issues opened by the community triage Issues awaiting triage
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant