批量提交不同规模的请求,引擎不得抛出未处理异常。
| 150 | |
| 151 | |
| 152 | class 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 | # --------------------------------------------------------------------------- |
nothing calls this directly
no outgoing calls
no test coverage detected