Commit 586c7f7
authored
chore(bigtable): fix flaky batcher flush interval test (googleapis#17545)
**Flaky test**:
- The unit test `test_mutations_batcher_flush_interval` was flaky under
load because it relied on real wall-clock sleep durations
(`time.sleep(0.4)` and `time.sleep(0.1)`). On busy VM executors, minor
CPU scheduling delays caused the test thread to wake up out of sync with
the background `threading.Timer` execution thread, triggering sporadic
test failures.
**Solution**:
- Refactored the test to completely mock `threading.Timer` instead of
relying on real-time sleeps:
a. Verifies that `MutationsBatcher` instantiates the background timer
with the correct `flush_interval` and starts it.
b. Manually triggers the timer's callback function to verify it calls
`flush()` synchronously.
This makes the unit test 100% deterministic, immune to VM executor load,
and significantly faster.1 parent 234c7c5 commit 586c7f7
1 file changed
Lines changed: 7 additions & 10 deletions
Lines changed: 7 additions & 10 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
16 | | - | |
17 | | - | |
18 | 16 | | |
19 | 17 | | |
20 | 18 | | |
| |||
175 | 173 | | |
176 | 174 | | |
177 | 175 | | |
| 176 | + | |
178 | 177 | | |
179 | | - | |
| 178 | + | |
180 | 179 | | |
181 | 180 | | |
182 | 181 | | |
183 | 182 | | |
184 | | - | |
185 | | - | |
186 | | - | |
187 | | - | |
| 183 | + | |
| 184 | + | |
188 | 185 | | |
189 | 186 | | |
190 | | - | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
191 | 190 | | |
192 | 191 | | |
193 | | - | |
194 | | - | |
195 | 192 | | |
196 | 193 | | |
197 | 194 | | |
| |||
0 commit comments