test: Migrate load test framework to anyio as well
This commit is contained in:
@@ -18,6 +18,7 @@ from collections import Counter
|
|||||||
from contextlib import asynccontextmanager
|
from contextlib import asynccontextmanager
|
||||||
from typing import Any
|
from typing import Any
|
||||||
|
|
||||||
|
import anyio
|
||||||
import click
|
import click
|
||||||
from mcp import ClientSession
|
from mcp import ClientSession
|
||||||
from mcp.client.streamable_http import streamablehttp_client
|
from mcp.client.streamable_http import streamablehttp_client
|
||||||
@@ -494,7 +495,7 @@ def main(
|
|||||||
print(f"Results exported to: {output}")
|
print(f"Results exported to: {output}")
|
||||||
|
|
||||||
try:
|
try:
|
||||||
asyncio.run(run())
|
anyio.run(run)
|
||||||
except KeyboardInterrupt:
|
except KeyboardInterrupt:
|
||||||
print("\nBenchmark interrupted by user")
|
print("\nBenchmark interrupted by user")
|
||||||
sys.exit(130)
|
sys.exit(130)
|
||||||
|
|||||||
@@ -11,9 +11,9 @@ Usage:
|
|||||||
uv run python -m tests.load.cleanup_loadtest_users --dry-run
|
uv run python -m tests.load.cleanup_loadtest_users --dry-run
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import asyncio
|
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
|
import anyio
|
||||||
import click
|
import click
|
||||||
|
|
||||||
from nextcloud_mcp_server.client import NextcloudClient
|
from nextcloud_mcp_server.client import NextcloudClient
|
||||||
@@ -110,7 +110,7 @@ def main(prefix: str, dry_run: bool):
|
|||||||
# Delete users with custom prefix
|
# Delete users with custom prefix
|
||||||
uv run python -m tests.load.cleanup_loadtest_users --prefix mytest
|
uv run python -m tests.load.cleanup_loadtest_users --prefix mytest
|
||||||
"""
|
"""
|
||||||
asyncio.run(cleanup_users(prefix=prefix, dry_run=dry_run))
|
anyio.run(cleanup_users, prefix, dry_run)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ from http.server import BaseHTTPRequestHandler, HTTPServer
|
|||||||
from typing import Any
|
from typing import Any
|
||||||
from urllib.parse import parse_qs, urlparse
|
from urllib.parse import parse_qs, urlparse
|
||||||
|
|
||||||
|
import anyio
|
||||||
import click
|
import click
|
||||||
import httpx
|
import httpx
|
||||||
from playwright.async_api import async_playwright
|
from playwright.async_api import async_playwright
|
||||||
@@ -729,7 +730,7 @@ def main(
|
|||||||
print(f"Results exported to: {output}")
|
print(f"Results exported to: {output}")
|
||||||
|
|
||||||
try:
|
try:
|
||||||
asyncio.run(run())
|
anyio.run(run)
|
||||||
except KeyboardInterrupt:
|
except KeyboardInterrupt:
|
||||||
print("\nBenchmark interrupted by user")
|
print("\nBenchmark interrupted by user")
|
||||||
sys.exit(130)
|
sys.exit(130)
|
||||||
|
|||||||
@@ -180,13 +180,8 @@ class OAuthUserPool:
|
|||||||
# Clean up streamable context if session creation failed
|
# Clean up streamable context if session creation failed
|
||||||
try:
|
try:
|
||||||
await streamable_context.__aexit__(None, None, None)
|
await streamable_context.__aexit__(None, None, None)
|
||||||
except RuntimeError as cleanup_error:
|
except Exception as cleanup_error:
|
||||||
if "cancel scope" in str(cleanup_error):
|
logger.debug(f"Error during cleanup: {cleanup_error}")
|
||||||
logger.debug(
|
|
||||||
f"Ignoring cancel scope teardown issue: {cleanup_error}"
|
|
||||||
)
|
|
||||||
else:
|
|
||||||
raise
|
|
||||||
raise e
|
raise e
|
||||||
|
|
||||||
async def close_user_session(self, username: str):
|
async def close_user_session(self, username: str):
|
||||||
@@ -200,13 +195,6 @@ class OAuthUserPool:
|
|||||||
if profile.session:
|
if profile.session:
|
||||||
try:
|
try:
|
||||||
await profile.session.__aexit__(None, None, None)
|
await profile.session.__aexit__(None, None, None)
|
||||||
except RuntimeError as e:
|
|
||||||
if "cancel scope" in str(e):
|
|
||||||
logger.debug(
|
|
||||||
f"Ignoring cancel scope teardown issue for {username}: {e}"
|
|
||||||
)
|
|
||||||
else:
|
|
||||||
logger.debug(f"Error closing session for {username}: {e}")
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.debug(f"Error closing session for {username}: {e}")
|
logger.debug(f"Error closing session for {username}: {e}")
|
||||||
profile.session = None
|
profile.session = None
|
||||||
@@ -215,15 +203,6 @@ class OAuthUserPool:
|
|||||||
if profile.streamable_context:
|
if profile.streamable_context:
|
||||||
try:
|
try:
|
||||||
await profile.streamable_context.__aexit__(None, None, None)
|
await profile.streamable_context.__aexit__(None, None, None)
|
||||||
except RuntimeError as e:
|
|
||||||
if "cancel scope" in str(e):
|
|
||||||
logger.debug(
|
|
||||||
f"Ignoring cancel scope teardown issue for {username}: {e}"
|
|
||||||
)
|
|
||||||
else:
|
|
||||||
logger.debug(
|
|
||||||
f"Error closing streamable context for {username}: {e}"
|
|
||||||
)
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.debug(f"Error closing streamable context for {username}: {e}")
|
logger.debug(f"Error closing streamable context for {username}: {e}")
|
||||||
profile.streamable_context = None
|
profile.streamable_context = None
|
||||||
|
|||||||
Reference in New Issue
Block a user