Page MenuHomePhabricator

httptest often fails with Gateway Timeout or Bad Gateway
Closed, ResolvedPublicBUG REPORT

Description

Steps to replicate the issue (include links if applicable):

pwb http_tests -v LiveFakeUserAgentTestCase

What happens?:

======================================================================
ERROR: test_fetch_with_fake_useragent (tests.http_tests.LiveFakeUserAgentTestCase)
Test method with fake_useragent module.
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/runner/work/pywikibot/pywikibot/tests/http_tests.py", line 302, in test_fetch_with_fake_useragent
    self._test_fetch_use_fake_user_agent()
  File "/home/runner/work/pywikibot/pywikibot/tests/http_tests.py", line 270, in _test_fetch_use_fake_user_agent
    r = http.fetch(self.get_httpbin_url('/status/200'),
  File "/home/runner/work/pywikibot/pywikibot/pywikibot/comms/http.py", line 448, in fetch
    callback(response)
  File "/home/runner/work/pywikibot/pywikibot/pywikibot/comms/http.py", line 344, in error_handling_callback
    raise ServerError(
pywikibot.exceptions.ServerError: 502 Server Error: Bad Gateway

----------------------------------------------------------------------
======================================================================
ERROR: test_fetch (tests.http_tests.DataBodyParameterTestCase)
Test that using the data and body params produce same results.
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/runner/work/pywikibot/pywikibot/tests/http_tests.py", line 572, in test_fetch
    data={'fish&chips': 'delicious'})
  File "/home/runner/work/pywikibot/pywikibot/pywikibot/comms/http.py", line 448, in fetch
    callback(response)
  File "/home/runner/work/pywikibot/pywikibot/pywikibot/comms/http.py", line 340, in error_handling_callback
    .format(urlparse(response.url).netloc))
pywikibot.exceptions.Server504Error: Server httpbin.org timed out

What should have happened instead?:
The test should be skipped. The aspects.CheckHostnameMixin class already skips the tests within setUpClass when a response.status is not in
[

HTTPStatus.OK,
HTTPStatus.MOVED_PERMANENTLY,
HTTPStatus.FOUND,
HTTPStatus.SEE_OTHER,
HTTPStatus.TEMPORARY_REDIRECT,
HTTPStatus.PERMANENT_REDIRECT

]

but the gateway error can also occurr later in the tests

Event Timeline

Xqt triaged this task as High priority.Apr 29 2023, 10:29 AM

Change 913564 had a related patch set uploaded (by Xqt; author: Xqt):

[pywikibot/core@master] [tests] Skip HttpbinTestCase tests when a ServerError occurs

https://gerrit.wikimedia.org/r/913564

Change 913564 merged by jenkins-bot:

[pywikibot/core@master] [tests] Skip HttpbinTestCase tests when a ServerError occurs

https://gerrit.wikimedia.org/r/913564