From dadadf777d33cb12d8762f5be69057b85f95fab9 Mon Sep 17 00:00:00 2001 From: Alexsander Hamir Date: Sat, 10 Jan 2026 17:43:53 -0800 Subject: [PATCH] add 1 million request memory leak tests for extreme scale validation - Add test_memory_baseline_1m for router (1,000,000 requests) - Add test_proxy_memory_baseline_1m for proxy (1,000,000 requests) - Add clarifying comment: high-volume tests verify memory limit strictness - These extreme scale tests help detect very gradual leaks (~1-2 KB per 1000 requests) - Estimated runtime: router ~15-20 min, proxy ~50-60 min - For manual execution only, not included in CI - Run with: pytest tests/load_tests/test_*_memory_growth.py::test_*_1m -v --- ...st_proxy_chat_completions_memory_growth.py | 19 ++++++++++++++++ .../test_router_acompletion_memory_growth.py | 22 ++++++++++++++++++- 2 files changed, 40 insertions(+), 1 deletion(-) 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 4cb73b1e6d2..d20fc226e14 100644 --- a/tests/load_tests/test_proxy_chat_completions_memory_growth.py +++ b/tests/load_tests/test_proxy_chat_completions_memory_growth.py @@ -423,6 +423,7 @@ async def test_proxy_memory_baseline_30k(proxy_server, limit_memory): +# We're only supposed to make it here if we're in a good place, meaning the memory limit needs to be strict enough to catch any possible OOMs from the previous tests. @pytest.mark.asyncio @pytest.mark.limit_leaks(MEMORY_LIMIT) @pytest.mark.no_parallel # Must run sequentially - measures process memory @@ -456,3 +457,21 @@ async def test_proxy_memory_baseline_500k(proxy_server, limit_memory): 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) + + +@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_1m(proxy_server, limit_memory): + """ + Memory baseline test with 1,000,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_1m -v + """ + await run_proxy_memory_baseline_test(1000000, 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 05d0e7e630a..4bc9f1e8506 100644 --- a/tests/load_tests/test_router_acompletion_memory_growth.py +++ b/tests/load_tests/test_router_acompletion_memory_growth.py @@ -138,6 +138,7 @@ async def test_memory_baseline_50k(test_router, limit_memory): """ await run_memory_baseline_test(50000, test_router, limit_memory) +# We're only supposed to make it here if we're in a good place, meaning the memory limit needs to be strict enough to catch any possible OOMs from the previous tests. @pytest.mark.asyncio @pytest.mark.limit_leaks(MEMORY_LIMIT) @pytest.mark.no_parallel # Must run sequentially - measures process memory @@ -153,4 +154,23 @@ async def test_memory_baseline_500k(test_router, limit_memory): 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 + await run_memory_baseline_test(500000, 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_1m(test_router, limit_memory): + """ + Memory baseline test with 1,000,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_1m -v + """ + await run_memory_baseline_test(1000000, test_router, limit_memory) + \ No newline at end of file