Commit fabf0fd
test: stop the cross-loop startup tests from racing on their own mock
Both cross-loop startup tests entered mock.patch.object on the shared
plugin instance from inside each worker thread. patch.object swaps and
restores one attribute on one object and is not thread safe: when two
threads read the original before either installs its mock, both record
that the attribute was absent from the instance, and both delete it on
exit. The second delete raises, so the test failed with
AttributeError: object has no attribute "_lazy_setup"
which is the mock unwinding itself, not anything about coalescing.
Install the mock once from the test thread and let the worker threads
race only on _ensure_started, which is what these tests are for. The
behaviour under test is unchanged: both loops still call in concurrently
and setup still has to coalesce to a single run.
Co-authored-by: George Weale <gweale@google.com>
PiperOrigin-RevId: 9537466271 parent 472e463 commit fabf0fd
1 file changed
Lines changed: 30 additions & 26 deletions
Lines changed: 30 additions & 26 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
10460 | 10460 | | |
10461 | 10461 | | |
10462 | 10462 | | |
10463 | | - | |
10464 | | - | |
10465 | | - | |
10466 | | - | |
| 10463 | + | |
10467 | 10464 | | |
10468 | 10465 | | |
10469 | 10466 | | |
10470 | | - | |
10471 | | - | |
10472 | | - | |
10473 | | - | |
10474 | | - | |
10475 | | - | |
10476 | | - | |
| 10467 | + | |
| 10468 | + | |
| 10469 | + | |
| 10470 | + | |
| 10471 | + | |
| 10472 | + | |
| 10473 | + | |
| 10474 | + | |
| 10475 | + | |
| 10476 | + | |
| 10477 | + | |
10477 | 10478 | | |
10478 | 10479 | | |
10479 | 10480 | | |
| |||
10593 | 10594 | | |
10594 | 10595 | | |
10595 | 10596 | | |
10596 | | - | |
10597 | | - | |
10598 | | - | |
| 10597 | + | |
| 10598 | + | |
10599 | 10599 | | |
10600 | 10600 | | |
10601 | 10601 | | |
10602 | | - | |
10603 | | - | |
10604 | | - | |
10605 | | - | |
10606 | | - | |
10607 | | - | |
10608 | | - | |
10609 | | - | |
10610 | | - | |
10611 | | - | |
10612 | | - | |
10613 | | - | |
| 10602 | + | |
| 10603 | + | |
| 10604 | + | |
| 10605 | + | |
| 10606 | + | |
| 10607 | + | |
| 10608 | + | |
| 10609 | + | |
| 10610 | + | |
| 10611 | + | |
| 10612 | + | |
| 10613 | + | |
| 10614 | + | |
| 10615 | + | |
| 10616 | + | |
| 10617 | + | |
10614 | 10618 | | |
10615 | 10619 | | |
10616 | 10620 | | |
| |||
0 commit comments