Skip to content

Commit 94d8f2a

Browse files
committed
fix flaky abort retry error
1 parent e909d22 commit 94d8f2a

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

tests/unit/test_session.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1702,8 +1702,9 @@ def unit_of_work(txn, *args, **kw):
17021702
def _time(_results=[1, 2, 4, 8]):
17031703
return _results.pop(0)
17041704

1705-
with mock.patch("time.time", _time):
1706-
with mock.patch("time.sleep") as sleep_mock:
1705+
with mock.patch("time.time", _time), \
1706+
mock.patch("google.cloud.spanner_v1._helpers.random.random", return_value=0), \
1707+
mock.patch("time.sleep") as sleep_mock:
17071708
with self.assertRaises(Aborted):
17081709
session.run_in_transaction(unit_of_work, timeout_secs=8)
17091710

0 commit comments

Comments
 (0)