MCPcopy Create free account
hub / github.com/Tong89/smartNode / TestNoUncaughtExceptions

Class TestNoUncaughtExceptions

tests/load/test_stress_engine.py:152–181  ·  view source on GitHub ↗

批量提交不同规模的请求,引擎不得抛出未处理异常。

Source from the content-addressed store, hash-verified

150
151
152class TestNoUncaughtExceptions:
153 """批量提交不同规模的请求,引擎不得抛出未处理异常。"""
154
155 @pytest.mark.parametrize("n_requests", [10, 50, 200])
156 def test_sequential_no_exception(self, isolated_engine, n_requests: int):
157 """顺序提交 n_requests 次,无任何异常。"""
158 payload = dict(_HIGH_PRI_PAYLOAD)
159 for _ in range(n_requests):
160 result = isolated_engine.submit_request(dict(payload))
161 assert isinstance(result, dict), "submit_request 应返回字典"
162
163 @pytest.mark.parametrize("n_threads,per_thread", [(4, 10), (8, 25), (16, 12)])
164 def test_concurrent_no_exception(self, isolated_engine, n_threads: int, per_thread: int):
165 """多线程并发提交,无任何未捕获异常。"""
166 results, errors = _submit_concurrent(isolated_engine, _HIGH_PRI_PAYLOAD, n_threads, per_thread)
167 assert len(errors) == 0, f"发现未捕获异常: {errors[:3]}"
168 assert len(results) == n_threads * per_thread
169
170 @pytest.mark.parametrize("data_type", list(DATA_TYPES.keys()))
171 def test_all_data_types_no_exception(self, isolated_engine, data_type: str):
172 """所有数据类型各提交 20 次,无任何异常。"""
173 payload = {
174 "data_type": data_type,
175 "data_size": 100,
176 "priority": 5,
177 "max_delay": 600,
178 }
179 for _ in range(20):
180 result = isolated_engine.submit_request(dict(payload))
181 assert isinstance(result, dict)
182
183
184# ---------------------------------------------------------------------------

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected