-
Notifications
You must be signed in to change notification settings - Fork 463
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor tests to have less globals. This will allow to hopefully write more complex tests for our new metric collection requirements in #5297. Includes reverted work from #4761 related to test globals. Co-authored-by: Alexander Bayandin <[email protected]> Co-authored-by: MMeent <[email protected]>
- Loading branch information
1 parent
1697e7b
commit ffd146c
Showing
9 changed files
with
224 additions
and
172 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
from typing import Tuple | ||
|
||
import pytest | ||
from pytest_httpserver import HTTPServer | ||
|
||
# TODO: mypy fails with: | ||
# Module "fixtures.neon_fixtures" does not explicitly export attribute "PortDistributor" [attr-defined] | ||
# from fixtures.neon_fixtures import PortDistributor | ||
|
||
# compared to the fixtures from pytest_httpserver with same names, these are | ||
# always function scoped, so you can check and stop the server in tests. | ||
|
||
|
||
@pytest.fixture(scope="function") | ||
def httpserver_ssl_context(): | ||
return None | ||
|
||
|
||
@pytest.fixture(scope="function") | ||
def make_httpserver(httpserver_listen_address, httpserver_ssl_context): | ||
host, port = httpserver_listen_address | ||
if not host: | ||
host = HTTPServer.DEFAULT_LISTEN_HOST | ||
if not port: | ||
port = HTTPServer.DEFAULT_LISTEN_PORT | ||
|
||
server = HTTPServer(host=host, port=port, ssl_context=httpserver_ssl_context) | ||
server.start() | ||
yield server | ||
server.clear() | ||
if server.is_running(): | ||
server.stop() | ||
|
||
|
||
@pytest.fixture(scope="function") | ||
def httpserver(make_httpserver): | ||
server = make_httpserver | ||
yield server | ||
server.clear() | ||
|
||
|
||
@pytest.fixture(scope="function") | ||
def httpserver_listen_address(port_distributor) -> Tuple[str, int]: | ||
port = port_distributor.get_port() | ||
return ("localhost", port) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
ffd146c
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
2540 tests run: 2414 passed, 0 failed, 126 skipped (full report)
Flaky tests (2)
Postgres 16
test_partial_evict_tenant
: debugPostgres 14
test_download_remote_layers_api[local_fs]
: debugCode coverage (full report)
functions
:53.0% (7667 of 14453 functions)
lines
:81.0% (44773 of 55281 lines)
ffd146c at 2023-09-14T09:56:26.449Z :recycle: