Repository navigation
Commit 701269c
committed
test(spanner): speed up unit test suite and eliminate idle retry sleeps
Speed up the unit test suite by ~55% (reducing full suite runtime from ~66s to ~29s) by eliminating wall-clock sleep delays, avoiding live gRPC transport initialization, and reducing cryptographic CPU burn in protocol tests.
Key changes:
- Intercept retry backoff sleeps: Mock localized `time.sleep` and `asyncio.sleep` in transaction, snapshot, and batch commit retry tests. Each test now verifies retry counts and delay values without idling in real time.
- Deterministic concurrency synchronization: Replace arbitrary timing sleeps in session manager and metrics tests with explicit `asyncio.Event` and `threading.Barrier` coordination, eliminating CI flakiness under CPU contention.
- Eliminate teardown polling: Remove `_assert_true_with_timeout` and sleep polling from `test_database_session_manager.py` by relying on event-driven rotation callbacks and blocking thread joins.
- Isolate GAPIC admin transports: Use autospec mock transports in `test_client.py` and `test_instance.py` instead of default credentials, eliminating live gRPC channel creation and 60-second network timeout risks.
- Lower Omni Argon2id test parameters: Use minimal valid test parameters (1 iteration, 8 KB RAM) in protocol flow and state machine tests, reducing key derivation time by ~1,100x while leaving RFC golden vector tests untouched.
- Clean up legacy mocks: Convert legacy global `mock.patch("time.sleep")` calls in `test_session.py` to localized module paths adhering to repository mock hygiene rules.1 parent 37123e5 commit 701269c
12 files changed
Lines changed: 169 additions & 110 deletions
File tree
- packages/google-cloud-spanner/tests/unit
- _async
- omni
Lines changed: 15 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1219 | 1219 | | |
1220 | 1220 | | |
1221 | 1221 | | |
1222 | | - | |
| 1222 | + | |
| 1223 | + | |
| 1224 | + | |
| 1225 | + | |
1223 | 1226 | | |
1224 | 1227 | | |
| 1228 | + | |
1225 | 1229 | | |
1226 | 1230 | | |
1227 | 1231 | | |
| |||
1261 | 1265 | | |
1262 | 1266 | | |
1263 | 1267 | | |
1264 | | - | |
| 1268 | + | |
| 1269 | + | |
| 1270 | + | |
| 1271 | + | |
1265 | 1272 | | |
1266 | 1273 | | |
1267 | 1274 | | |
| 1275 | + | |
1268 | 1276 | | |
1269 | 1277 | | |
1270 | 1278 | | |
| |||
1308 | 1316 | | |
1309 | 1317 | | |
1310 | 1318 | | |
1311 | | - | |
| 1319 | + | |
| 1320 | + | |
| 1321 | + | |
| 1322 | + | |
1312 | 1323 | | |
1313 | 1324 | | |
1314 | 1325 | | |
| 1326 | + | |
1315 | 1327 | | |
1316 | 1328 | | |
1317 | 1329 | | |
| |||
Lines changed: 6 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1367 | 1367 | | |
1368 | 1368 | | |
1369 | 1369 | | |
1370 | | - | |
| 1370 | + | |
| 1371 | + | |
| 1372 | + | |
| 1373 | + | |
| 1374 | + | |
1371 | 1375 | | |
1372 | 1376 | | |
| 1377 | + | |
1373 | 1378 | | |
1374 | 1379 | | |
1375 | 1380 | | |
| |||
Lines changed: 6 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
135 | 135 | | |
136 | 136 | | |
137 | 137 | | |
138 | | - | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
139 | 143 | | |
| 144 | + | |
140 | 145 | | |
141 | 146 | | |
142 | 147 | | |
| |||
Lines changed: 6 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
41 | 41 | | |
42 | 42 | | |
43 | 43 | | |
44 | | - | |
45 | | - | |
46 | | - | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
47 | 47 | | |
48 | 48 | | |
49 | 49 | | |
| |||
248 | 248 | | |
249 | 249 | | |
250 | 250 | | |
251 | | - | |
252 | | - | |
253 | | - | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
254 | 254 | | |
255 | 255 | | |
256 | 256 | | |
| |||
Lines changed: 18 additions & 18 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
486 | 486 | | |
487 | 487 | | |
488 | 488 | | |
489 | | - | |
490 | | - | |
491 | | - | |
| 489 | + | |
| 490 | + | |
| 491 | + | |
492 | 492 | | |
493 | 493 | | |
494 | 494 | | |
| |||
512 | 512 | | |
513 | 513 | | |
514 | 514 | | |
515 | | - | |
516 | | - | |
517 | | - | |
| 515 | + | |
| 516 | + | |
| 517 | + | |
518 | 518 | | |
519 | 519 | | |
520 | 520 | | |
| |||
541 | 541 | | |
542 | 542 | | |
543 | 543 | | |
544 | | - | |
545 | | - | |
546 | | - | |
| 544 | + | |
| 545 | + | |
| 546 | + | |
547 | 547 | | |
548 | 548 | | |
549 | 549 | | |
| |||
584 | 584 | | |
585 | 585 | | |
586 | 586 | | |
587 | | - | |
588 | | - | |
589 | | - | |
| 587 | + | |
| 588 | + | |
| 589 | + | |
590 | 590 | | |
591 | 591 | | |
592 | 592 | | |
| |||
708 | 708 | | |
709 | 709 | | |
710 | 710 | | |
711 | | - | |
712 | | - | |
713 | | - | |
| 711 | + | |
| 712 | + | |
| 713 | + | |
714 | 714 | | |
715 | 715 | | |
716 | 716 | | |
| |||
964 | 964 | | |
965 | 965 | | |
966 | 966 | | |
967 | | - | |
968 | | - | |
969 | | - | |
| 967 | + | |
| 968 | + | |
| 969 | + | |
970 | 970 | | |
971 | 971 | | |
972 | 972 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
345 | 345 | | |
346 | 346 | | |
347 | 347 | | |
348 | | - | |
349 | | - | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
350 | 362 | | |
351 | 363 | | |
352 | 364 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
59 | 59 | | |
60 | 60 | | |
61 | 61 | | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
62 | 73 | | |
63 | 74 | | |
64 | 75 | | |
| |||
627 | 638 | | |
628 | 639 | | |
629 | 640 | | |
630 | | - | |
631 | | - | |
632 | | - | |
| 641 | + | |
633 | 642 | | |
634 | 643 | | |
635 | | - | |
| 644 | + | |
| 645 | + | |
636 | 646 | | |
637 | 647 | | |
638 | | - | |
| 648 | + | |
639 | 649 | | |
640 | 650 | | |
641 | 651 | | |
| |||
676 | 686 | | |
677 | 687 | | |
678 | 688 | | |
679 | | - | |
680 | | - | |
681 | | - | |
| 689 | + | |
682 | 690 | | |
683 | 691 | | |
684 | | - | |
| 692 | + | |
| 693 | + | |
685 | 694 | | |
686 | 695 | | |
687 | 696 | | |
688 | | - | |
| 697 | + | |
689 | 698 | | |
690 | 699 | | |
691 | 700 | | |
| |||
756 | 765 | | |
757 | 766 | | |
758 | 767 | | |
759 | | - | |
760 | 768 | | |
761 | 769 | | |
762 | 770 | | |
763 | 771 | | |
| 772 | + | |
764 | 773 | | |
765 | | - | |
766 | 774 | | |
767 | 775 | | |
768 | 776 | | |
| |||
806 | 814 | | |
807 | 815 | | |
808 | 816 | | |
809 | | - | |
810 | 817 | | |
811 | 818 | | |
812 | 819 | | |
813 | 820 | | |
| 821 | + | |
814 | 822 | | |
815 | | - | |
816 | 823 | | |
817 | 824 | | |
818 | 825 | | |
| |||
0 commit comments