Test regression with urllib3 2.0.1

Bug #2020112 reported by Michał Górny
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
keystoneauth
New
Undecided
Unassigned
betamax (Ubuntu)
Fix Released
High
James Page

Bug Description

When running the test suite after urllib3 was upgraded to 2.0.1, we are getting the following test failure:

```
======================================================================
ERROR: test_keystoneauth_betamax_fixture (keystoneauth1.tests.unit.test_betamax_fixture.TestBetamaxFixture)
keystoneauth1.tests.unit.test_betamax_fixture.TestBetamaxFixture.test_keystoneauth_betamax_fixture
----------------------------------------------------------------------
testtools.testresult.real._StringException: Traceback (most recent call last):
  File "/usr/lib/python3.10/site-packages/urllib3/response.py", line 705, in _error_catcher
    yield
  File "/usr/lib/python3.10/site-packages/urllib3/response.py", line 830, in _raw_read
    raise IncompleteRead(self._fp_bytes_read, self.length_remaining)
urllib3.exceptions.IncompleteRead: IncompleteRead(780 bytes read, 1904 more expected)

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/lib/python3.10/site-packages/urllib3/response.py", line 722, in _error_catcher
    raise ProtocolError(f"Connection broken: {e!r}", e) from e
urllib3.exceptions.ProtocolError: ('Connection broken: IncompleteRead(780 bytes read, 1904 more expected)', IncompleteRead(780 bytes read, 1904 more expected))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/var/tmp/portage/dev-python/keystoneauth1-5.2.0/work/keystoneauth1-5.2.0/keystoneauth1/tests/unit/test_betamax_fixture.py", line 54, in test_keystoneauth_betamax_fixture
    self._replay_cassette()
  File "/var/tmp/portage/dev-python/keystoneauth1-5.2.0/work/keystoneauth1-5.2.0/keystoneauth1/tests/unit/test_betamax_fixture.py", line 51, in _replay_cassette
    s.get_token(auth=plugin)
  File "/var/tmp/portage/dev-python/keystoneauth1-5.2.0/work/keystoneauth1-5.2.0/keystoneauth1/session.py", line 1215, in get_token
    return (self.get_auth_headers(auth) or {}).get('X-Auth-Token')
  File "/var/tmp/portage/dev-python/keystoneauth1-5.2.0/work/keystoneauth1-5.2.0/keystoneauth1/session.py", line 1193, in get_auth_headers
    return auth.get_headers(self, **kwargs)
  File "/var/tmp/portage/dev-python/keystoneauth1-5.2.0/work/keystoneauth1-5.2.0/keystoneauth1/plugin.py", line 106, in get_headers
    token = self.get_token(session)
  File "/var/tmp/portage/dev-python/keystoneauth1-5.2.0/work/keystoneauth1-5.2.0/keystoneauth1/identity/base.py", line 85, in get_token
    return self.get_access(session).auth_token
  File "/var/tmp/portage/dev-python/keystoneauth1-5.2.0/work/keystoneauth1-5.2.0/keystoneauth1/identity/base.py", line 131, in get_access
    self.auth_ref = self.get_auth_ref(session)
  File "/var/tmp/portage/dev-python/keystoneauth1-5.2.0/work/keystoneauth1-5.2.0/keystoneauth1/identity/v2.py", line 59, in get_auth_ref
    resp = session.post(url, json=params, headers=headers,
  File "/var/tmp/portage/dev-python/keystoneauth1-5.2.0/work/keystoneauth1-5.2.0/keystoneauth1/session.py", line 1141, in post
    return self.request(url, 'POST', **kwargs)
  File "/var/tmp/portage/dev-python/keystoneauth1-5.2.0/work/keystoneauth1-5.2.0/keystoneauth1/session.py", line 923, in request
    resp = send(**kwargs)
  File "/var/tmp/portage/dev-python/keystoneauth1-5.2.0/work/keystoneauth1-5.2.0/keystoneauth1/session.py", line 1014, in _send_request
    resp = self.session.request(method, url, **kwargs)
  File "/usr/lib/python3.10/site-packages/requests/sessions.py", line 587, in request
    resp = self.send(prep, **send_kwargs)
  File "/usr/lib/python3.10/site-packages/requests/sessions.py", line 745, in send
    r.content
  File "/usr/lib/python3.10/site-packages/requests/models.py", line 899, in content
    self._content = b"".join(self.iter_content(CONTENT_CHUNK_SIZE)) or b""
  File "/usr/lib/python3.10/site-packages/requests/models.py", line 816, in generate
    yield from self.raw.stream(chunk_size, decode_content=True)
  File "/usr/lib/python3.10/site-packages/urllib3/response.py", line 935, in stream
    data = self.read(amt=amt, decode_content=decode_content)
  File "/usr/lib/python3.10/site-packages/urllib3/response.py", line 906, in read
    data = self._raw_read(amt)
  File "/usr/lib/python3.10/site-packages/urllib3/response.py", line 808, in _raw_read
    with self._error_catcher():
  File "/usr/lib/python3.10/contextlib.py", line 153, in __exit__
    self.gen.throw(typ, value, traceback)
  File "/usr/lib/python3.10/site-packages/urllib3/response.py", line 735, in _error_catcher
    self._original_response.close()
AttributeError: 'MockHTTPResponse' object has no attribute 'close'
```

I suspect this may be a problem inside betamax but FWICS its own test suite passes 100%, so I'm reporting it here instead, in case it was something keystoneauth does to it.

Original report: https://bugs.gentoo.org/906661

Revision history for this message
James Page (james-page) wrote :
James Page (james-page)
Changed in betamax (Ubuntu):
status: New → Fix Committed
importance: Undecided → High
assignee: nobody → James Page (james-page)
Revision history for this message
Michał Górny (mgorny) wrote :
Download full text (5.5 KiB)

Thanks for the fix. However, I'm afraid that doesn't resolve all the issues. After installing betamax from https://github.com/jhatler/betamax/, I get:

==============================
Failed 1 tests - output below:
==============================

keystoneauth1.tests.unit.test_betamax_fixture.TestBetamaxFixture.test_keystoneauth_betamax_fixture
--------------------------------------------------------------------------------------------------

Captured traceback:
~~~~~~~~~~~~~~~~~~~
    Traceback (most recent call last):

      File "/tmp/keystoneauth/.tox/py311/lib/python3.11/site-packages/urllib3/response.py", line 712, in _error_catcher
    yield

      File "/tmp/keystoneauth/.tox/py311/lib/python3.11/site-packages/urllib3/response.py", line 833, in _raw_read
    raise IncompleteRead(self._fp_bytes_read, self.length_remaining)

    urllib3.exceptions.IncompleteRead: IncompleteRead(780 bytes read, 1904 more expected)

The above exception was the direct cause of the following exception:

    Traceback (most recent call last):

      File "/tmp/keystoneauth/.tox/py311/lib/python3.11/site-packages/requests/models.py", line 816, in generate
    yield from self.raw.stream(chunk_size, decode_content=True)

      File "/tmp/keystoneauth/.tox/py311/lib/python3.11/site-packages/urllib3/response.py", line 934, in stream
    data = self.read(amt=amt, decode_content=decode_content)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

      File "/tmp/keystoneauth/.tox/py311/lib/python3.11/site-packages/urllib3/response.py", line 905, in read
    data = self._raw_read(amt)
           ^^^^^^^^^^^^^^^^^^^

      File "/tmp/keystoneauth/.tox/py311/lib/python3.11/site-packages/urllib3/response.py", line 811, in _raw_read
    with self._error_catcher():

      File "/usr/lib/python3.11/contextlib.py", line 158, in __exit__
    self.gen.throw(typ, value, traceback)

      File "/tmp/keystoneauth/.tox/py311/lib/python3.11/site-packages/urllib3/response.py", line 729, in _error_catcher
    raise ProtocolError(f"Connection broken: {e!r}", e) from e

    urllib3.exceptions.ProtocolError: ('Connection broken: IncompleteRead(780 bytes read, 1904 more expected)', IncompleteRead(780 bytes read, 1904 more expected))

During handling of the above exception, another exception occurred:

    Traceback (most recent call last):

      File "/tmp/keystoneauth/keystoneauth1/session.py", line 1021, in _send_request
    resp = self.session.request(method, url, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

      File "/tmp/keystoneauth/.tox/py311/lib/python3.11/site-packages/requests/sessions.py", line 589, in request
    resp = self.send(prep, **send_kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

      File "/tmp/keystoneauth/.tox/py311/lib/python3.11/site-packages/requests/sessions.py", line 747, in send
    r.content

      File "/tmp/keystoneauth/.tox/py311/lib/python3.11/site-packages/requests/models.py", line 899, in content
    self._content = b"".join(self.iter_content(CONTENT_CHUNK_SIZE)) or b""
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

      File "/tmp/keystoneauth/.tox/py311/lib/python3.11/site-...

Read more...

Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package betamax - 0.8.1-3ubuntu1

---------------
betamax (0.8.1-3ubuntu1) noble; urgency=medium

  * d/p/urllib3-2-compat.patch: Cherry pick commit to resolve
    compatibility issues with urllib3 >= 2 (LP: #2020112).

 -- James Page <email address hidden> Thu, 18 Jan 2024 11:28:05 +0000

Changed in betamax (Ubuntu):
status: Fix Committed → Fix Released
Revision history for this message
Alexandre Detiste (alexandre-detiste) wrote :

updated in Debian before Ubuntu import freeze

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.