Skip to content

Commit

Permalink
Fix failing app tests (#19971)
Browse files Browse the repository at this point in the history
  • Loading branch information
awaelchli authored Jun 13, 2024
1 parent f6fd046 commit a42484c
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 10 deletions.
2 changes: 1 addition & 1 deletion requirements/app/app.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ Jinja2 <3.2.0
PyYAML <=6.0.1
requests <2.32.0
rich >=12.3.0, <13.6.0
urllib3 <2.1.0
urllib3 <2.0.0
uvicorn <0.24.0
websocket-client <1.7.0
websockets <11.1.0
2 changes: 2 additions & 0 deletions tests/tests_app/cli/test_cmd_launch.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from unittest import mock
from unittest.mock import ANY, MagicMock, Mock

import pytest
from click.testing import CliRunner
from lightning.app.cli.lightning_cli_launch import run_flow, run_flow_and_servers, run_frontend, run_server
from lightning.app.core.queues import QueuingSystem
Expand Down Expand Up @@ -189,6 +190,7 @@ def start_processes(**functions):


@_RunIf(skip_windows=True)
@pytest.mark.flaky(reruns=3)
def test_manage_server_processes_one_process_gets_killed(capfd):
functions = {"p1": run_forever_process, "p2": run_for_2_seconds_and_raise}
p = Process(target=start_processes, kwargs=functions)
Expand Down
2 changes: 1 addition & 1 deletion tests/tests_app/core/test_lightning_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -404,7 +404,7 @@ async def test_frontend_routes(path, expected_status_code):
assert response.status_code == expected_status_code


@pytest.mark.xfail(sys.platform == "linux", reason="No idea why... need to be fixed") # fixme
@pytest.mark.xfail(sys.platform == "linux", strict=False, reason="No idea why... need to be fixed") # fixme
def test_start_server_started():
"""This test ensures has_started_queue receives a signal when the REST API has started."""
api_publish_state_queue = mp.Queue()
Expand Down
1 change: 1 addition & 0 deletions tests/tests_app/core/test_lightning_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -1084,6 +1084,7 @@ def run_once(self):
return res


@pytest.mark.flaky(reruns=3)
def test_lightning_app_has_updated():
app = TestLightningHasUpdatedApp(FlowPath())
MultiProcessRuntime(app, start_server=False).dispatch()
Expand Down
16 changes: 8 additions & 8 deletions tests/tests_app/utilities/test_network.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,10 @@ def test_find_free_network_port_cloudspace(_, patch_constants):
@mock.patch("urllib3.connectionpool.HTTPConnectionPool._get_conn")
def test_http_client_retry_post(getconn_mock):
getconn_mock.return_value.getresponse.side_effect = [
mock.Mock(status=500, msg=HTTPMessage()),
mock.Mock(status=599, msg=HTTPMessage()),
mock.Mock(status=405, msg=HTTPMessage()),
mock.Mock(status=200, msg=HTTPMessage()),
mock.Mock(status=500, msg=HTTPMessage(), headers={}),
mock.Mock(status=599, msg=HTTPMessage(), headers={}),
mock.Mock(status=405, msg=HTTPMessage(), headers={}),
mock.Mock(status=200, msg=HTTPMessage(), headers={}),
]

client = HTTPClient(base_url="http://test.url")
Expand All @@ -69,10 +69,10 @@ def test_http_client_retry_post(getconn_mock):
@mock.patch("urllib3.connectionpool.HTTPConnectionPool._get_conn")
def test_http_client_retry_get(getconn_mock):
getconn_mock.return_value.getresponse.side_effect = [
mock.Mock(status=500, msg=HTTPMessage()),
mock.Mock(status=599, msg=HTTPMessage()),
mock.Mock(status=405, msg=HTTPMessage()),
mock.Mock(status=200, msg=HTTPMessage()),
mock.Mock(status=500, msg=HTTPMessage(), headers={}),
mock.Mock(status=599, msg=HTTPMessage(), headers={}),
mock.Mock(status=405, msg=HTTPMessage(), headers={}),
mock.Mock(status=200, msg=HTTPMessage(), headers={}),
]

client = HTTPClient(base_url="http://test.url")
Expand Down

0 comments on commit a42484c

Please sign in to comment.