mirror of
https://github.com/PrefectHQ/fastmcp.git
synced 2026-08-21 13:04:18 +02:00
test: run Windows tests without xdist parallelism
This commit is contained in:
parent
c02c73f556
commit
cf101c2a82
2 changed files with 7 additions and 39 deletions
8
.github/workflows/run-tests.yml
vendored
8
.github/workflows/run-tests.yml
vendored
|
|
@ -48,7 +48,13 @@ jobs:
|
||||||
run: uv sync --upgrade
|
run: uv sync --upgrade
|
||||||
|
|
||||||
- name: Run tests (excluding integration and client_process)
|
- name: Run tests (excluding integration and client_process)
|
||||||
run: uv run pytest --inline-snapshot=disable tests -m "not integration and not client_process" --numprocesses auto --maxprocesses 4 --dist worksteal
|
run: |
|
||||||
|
if [ "$RUNNER_OS" == "Windows" ]; then
|
||||||
|
# Run without parallelism on Windows to debug xdist crashes
|
||||||
|
uv run pytest --inline-snapshot=disable tests -m "not integration and not client_process"
|
||||||
|
else
|
||||||
|
uv run pytest --inline-snapshot=disable tests -m "not integration and not client_process" --numprocesses auto --maxprocesses 4 --dist worksteal
|
||||||
|
fi
|
||||||
shell: bash
|
shell: bash
|
||||||
|
|
||||||
- name: Run client process tests separately
|
- name: Run client process tests separately
|
||||||
|
|
|
||||||
|
|
@ -1,51 +1,13 @@
|
||||||
import asyncio
|
|
||||||
import socket
|
import socket
|
||||||
from collections.abc import Callable
|
from collections.abc import Callable
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from typing import Any
|
from typing import Any
|
||||||
from unittest.mock import patch
|
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
from fastmcp.utilities.tests import temporary_settings
|
from fastmcp.utilities.tests import temporary_settings
|
||||||
|
|
||||||
|
|
||||||
# Fakeredis doesn't properly implement blocking xread - it returns immediately
|
|
||||||
# instead of waiting. This causes Docket._monitor_strikes to busy-loop, which
|
|
||||||
# overwhelms pytest-xdist workers on Windows. Replace with a simple sleep loop.
|
|
||||||
# See: https://github.com/cunla/fakeredis-py/issues/274
|
|
||||||
async def _mock_monitor_strikes(self):
|
|
||||||
while True:
|
|
||||||
await asyncio.sleep(60)
|
|
||||||
|
|
||||||
|
|
||||||
_monitor_strikes_patch = patch(
|
|
||||||
"docket.docket.Docket._monitor_strikes", _mock_monitor_strikes
|
|
||||||
)
|
|
||||||
_monitor_strikes_patch.start()
|
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture(autouse=True)
|
|
||||||
def fresh_fakeredis_server():
|
|
||||||
"""Give each test a fresh FakeServer instead of sharing one.
|
|
||||||
|
|
||||||
Docket stores a shared FakeServer as a class attribute (_memory_server).
|
|
||||||
This can cause issues when many tests run in parallel on Windows.
|
|
||||||
Reset it before each test to ensure isolation.
|
|
||||||
"""
|
|
||||||
from docket import Docket
|
|
||||||
|
|
||||||
# Clear the shared server so each test gets a fresh one
|
|
||||||
if hasattr(Docket, "_memory_server"):
|
|
||||||
delattr(Docket, "_memory_server")
|
|
||||||
|
|
||||||
yield
|
|
||||||
|
|
||||||
# Clean up after test
|
|
||||||
if hasattr(Docket, "_memory_server"):
|
|
||||||
delattr(Docket, "_memory_server")
|
|
||||||
|
|
||||||
|
|
||||||
def pytest_collection_modifyitems(items):
|
def pytest_collection_modifyitems(items):
|
||||||
"""Automatically mark tests in integration_tests folder with 'integration' marker."""
|
"""Automatically mark tests in integration_tests folder with 'integration' marker."""
|
||||||
for item in items:
|
for item in items:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue