Skip to content

Improve the stability of mock servers in tests #808

@seratch

Description

@seratch

We use http.server module for building mock servers in unit tests. The module occasionally (often?) can be unstable when running a number of tests. A small number of HTTP requests in tests result in [Errno 54] Connection reset by peer in the case. Probably, we should switch to a more reliable HTTP server library for mock web servers. bolt-python project has the same issue.

----------------------------------------
127.0.0.1 - - [16/Sep/2020 19:21:39] "POST /admin.apps.restricted.list HTTP/1.1" 200 -
----------------------------------------
Exception happened during processing of request from ('127.0.0.1', 62987)
Traceback (most recent call last):
  File "/Users/ksera/.pyenv/versions/3.8.5/lib/python3.8/socketserver.py", line 316, in _handle_request_noblock
    self.process_request(request, client_address)
  File "/Users/ksera/.pyenv/versions/3.8.5/lib/python3.8/socketserver.py", line 347, in process_request
    self.finish_request(request, client_address)
  File "/Users/ksera/.pyenv/versions/3.8.5/lib/python3.8/socketserver.py", line 360, in finish_request
    self.RequestHandlerClass(request, client_address, self)
  File "/Users/ksera/.pyenv/versions/3.8.5/lib/python3.8/http/server.py", line 647, in __init__
    super().__init__(*args, **kwargs)
  File "/Users/ksera/.pyenv/versions/3.8.5/lib/python3.8/socketserver.py", line 720, in __init__
    self.handle()
  File "/Users/ksera/.pyenv/versions/3.8.5/lib/python3.8/http/server.py", line 427, in handle
    self.handle_one_request()
  File "/Users/ksera/.pyenv/versions/3.8.5/lib/python3.8/http/server.py", line 416, in handle_one_request
    self.wfile.flush() #actually send the response if not already done.
ValueError: I/O operation on closed file.
========================================================================================= short test summary info ==========================================================================================
FAILED tests/slack_sdk_tests/webhook/test_webhook.py::TestWebhook::test_send - ConnectionResetError: [Errno 54] Connection reset by peer
FAILED tests/slack_sdk_tests_async/web/test_web_client_coverage.py::TestWebClientCoverage::test_coverage - TypeError: admin_conversations_restrictAccess_addGroup() missing 2 required keyword-only argum...
========================================================================== 2 failed, 486 passed, 1 skipped, 3 warnings in 42.30s ===========================================================================

Requirements

Please read the Contributing guidelines and Code of Conduct before creating this issue or pull request. By submitting, you are agreeing to those rules.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions