Commit d7d02c0
Martin Balaz
Fix high memory usage in PyTests logging system
Polling functions like `wait_until...` often runs multiple
iterations. When ODL returns large response body
(e.g., PCEP topology dumps), logging every message leads to high
memmory usage. Pytest and Allure retain the complete history of all
logs in virtual memmory.
This patch implements a "Deferred Logging" mechanism:
1. Logs are temporarily captured in a lightweight memory buffer
during test execution.
2. If an attempt fails (and is not the last one), logs cpatured
in the buffer are discarded immediately.
3. The buffer is "replayed" to the main logger only if the attempt
succeeds or if it is the final failure.
Also introduce variable MAX_HTTP_RESPONSE_BODY_LOG_SIZE
for limitting maximum logged HTTP response body size.
JIRA: BGPCEP-1066
Change-Id: I37146943a79622e796fa92b03fe4f4f03a614eac
Signed-off-by: Martin Balaz <[email protected]>1 parent ed52135 commit d7d02c0
File tree
4 files changed
+107
-9
lines changed- tests/libraries
4 files changed
+107
-9
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
26 | 26 | | |
27 | 27 | | |
28 | 28 | | |
| 29 | + | |
29 | 30 | | |
30 | 31 | | |
31 | 32 | | |
| |||
55 | 56 | | |
56 | 57 | | |
57 | 58 | | |
58 | | - | |
59 | 59 | | |
60 | 60 | | |
61 | 61 | | |
| |||
68 | 68 | | |
69 | 69 | | |
70 | 70 | | |
71 | | - | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
72 | 75 | | |
73 | 76 | | |
74 | 77 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
| 21 | + | |
21 | 22 | | |
22 | 23 | | |
23 | 24 | | |
| |||
68 | 69 | | |
69 | 70 | | |
70 | 71 | | |
71 | | - | |
| 72 | + | |
| 73 | + | |
72 | 74 | | |
73 | 75 | | |
74 | 76 | | |
| |||
121 | 123 | | |
122 | 124 | | |
123 | 125 | | |
124 | | - | |
| 126 | + | |
| 127 | + | |
125 | 128 | | |
126 | 129 | | |
127 | 130 | | |
| |||
174 | 177 | | |
175 | 178 | | |
176 | 179 | | |
177 | | - | |
| 180 | + | |
| 181 | + | |
178 | 182 | | |
179 | 183 | | |
180 | 184 | | |
| |||
220 | 224 | | |
221 | 225 | | |
222 | 226 | | |
223 | | - | |
| 227 | + | |
| 228 | + | |
224 | 229 | | |
225 | 230 | | |
226 | 231 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
| 9 | + | |
9 | 10 | | |
10 | 11 | | |
11 | 12 | | |
12 | 13 | | |
13 | | - | |
| 14 | + | |
14 | 15 | | |
15 | 16 | | |
16 | 17 | | |
17 | 18 | | |
18 | 19 | | |
19 | 20 | | |
20 | 21 | | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
21 | 99 | | |
22 | 100 | | |
23 | 101 | | |
| |||
170 | 248 | | |
171 | 249 | | |
172 | 250 | | |
| 251 | + | |
173 | 252 | | |
174 | 253 | | |
175 | 254 | | |
176 | | - | |
| 255 | + | |
| 256 | + | |
177 | 257 | | |
| 258 | + | |
178 | 259 | | |
179 | 260 | | |
180 | 261 | | |
| |||
190 | 271 | | |
191 | 272 | | |
192 | 273 | | |
| 274 | + | |
| 275 | + | |
193 | 276 | | |
194 | 277 | | |
195 | 278 | | |
| |||
325 | 408 | | |
326 | 409 | | |
327 | 410 | | |
| 411 | + | |
| 412 | + | |
328 | 413 | | |
329 | 414 | | |
330 | | - | |
| 415 | + | |
| 416 | + | |
331 | 417 | | |
332 | 418 | | |
| 419 | + | |
333 | 420 | | |
334 | 421 | | |
335 | 422 | | |
336 | 423 | | |
337 | 424 | | |
338 | 425 | | |
| 426 | + | |
339 | 427 | | |
340 | 428 | | |
341 | 429 | | |
| |||
348 | 436 | | |
349 | 437 | | |
350 | 438 | | |
| 439 | + | |
351 | 440 | | |
352 | 441 | | |
353 | 442 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
40 | 40 | | |
41 | 41 | | |
42 | 42 | | |
| 43 | + | |
43 | 44 | | |
44 | 45 | | |
45 | 46 | | |
0 commit comments