From e868a5702e7eae91c0ea2067271672a3af877269 Mon Sep 17 00:00:00 2001 From: Alexsander Hamir Date: Sat, 10 Jan 2026 17:23:49 -0800 Subject: [PATCH] add 500k memory leak tests for comprehensive analysis - Add test_memory_baseline_500k for router (500,000 requests) - Add test_proxy_memory_baseline_500k for proxy (500,000 requests) - These high-volume tests are designed for manual execution and deep memory leak analysis - Not included in CI due to long runtime (~15-30 minutes each) - Useful for detecting very gradual memory accumulation patterns - Run individually with: pytest tests/load_tests/test_*_memory_growth.py::test_*_500k -v --- ...test_proxy_chat_completions_memory_growth.py | 17 +++++++++++++++++ .../test_router_acompletion_memory_growth.py | 17 +++++++++++++++++ 2 files changed, 34 insertions(+) diff --git a/tests/load_tests/test_proxy_chat_completions_memory_growth.py b/tests/load_tests/test_proxy_chat_completions_memory_growth.py index a7b0522a56d..ddab06555d1 100644 --- a/tests/load_tests/test_proxy_chat_completions_memory_growth.py +++ b/tests/load_tests/test_proxy_chat_completions_memory_growth.py @@ -439,3 +439,20 @@ async def test_proxy_memory_baseline_50k(proxy_server, limit_memory): pytest tests/load_tests/test_proxy_chat_completions_memory_growth.py::test_proxy_memory_baseline_50k -v """ await run_proxy_memory_baseline_test(50000, proxy_server, limit_memory) + +@pytest.mark.asyncio +@pytest.mark.limit_leaks(MEMORY_LIMIT) +@pytest.mark.no_parallel # Must run sequentially - measures process memory +async def test_proxy_memory_baseline_500k(proxy_server, limit_memory): + """ + Memory baseline test with 500,000 requests to the proxy server. + Uses @pytest.mark.limit_leaks("40 MB") to enforce memory limit. + If test_proxy_memory_baseline_1k and test_proxy_memory_baseline_2k pass but this fails, + it's a clear sign of sequential/progressive memory growth. + + NOTE: This test should be run INDIVIDUALLY, not with other tests in this file. + Running multiple tests together causes memory baseline drift, making it difficult + to accurately detect linear memory growth. Run with: + pytest tests/load_tests/test_proxy_chat_completions_memory_growth.py::test_proxy_memory_baseline_500k -v + """ + await run_proxy_memory_baseline_test(500000, proxy_server, limit_memory) diff --git a/tests/load_tests/test_router_acompletion_memory_growth.py b/tests/load_tests/test_router_acompletion_memory_growth.py index 406c38709e9..33b60d44c95 100644 --- a/tests/load_tests/test_router_acompletion_memory_growth.py +++ b/tests/load_tests/test_router_acompletion_memory_growth.py @@ -138,3 +138,20 @@ async def test_memory_baseline_50k(test_router, limit_memory): pytest tests/load_tests/test_router_acompletion_memory_growth.py::test_memory_baseline_50k -v """ await run_memory_baseline_test(50000, test_router, limit_memory) + +@pytest.mark.asyncio +@pytest.mark.limit_leaks(MEMORY_LIMIT) +@pytest.mark.no_parallel # Must run sequentially - measures process memory +async def test_memory_baseline_500k(test_router, limit_memory): + """ + Memory baseline test with 500,000 requests. + Uses @pytest.mark.limit_leaks("40 MB") to enforce memory limit. + If test_memory_baseline_1k and test_memory_baseline_2k pass but this fails, + it's a clear sign of sequential/progressive memory growth. + + NOTE: This test should be run INDIVIDUALLY, not with other tests in this file. + Running multiple tests together causes memory baseline drift, making it difficult + to accurately detect linear memory growth. Run with: + pytest tests/load_tests/test_router_acompletion_memory_growth.py::test_memory_baseline_500k -v + """ + await run_memory_baseline_test(500000, test_router, limit_memory) \ No newline at end of file