Skip to content

Commit 26bdbc5

Browse files
committed
Add system tests exercising multi-use snapshots.
1 parent ac1028c commit 26bdbc5

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

spanner/tests/system/test_system.py

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -574,6 +574,21 @@ def test_snapshot_read_w_various_staleness(self):
574574
rows = list(strong.read(self.TABLE, self.COLUMNS, self.ALL))
575575
self._check_row_data(rows, all_data_rows)
576576

577+
def test_multiuse_snapshot_read_isolation_strong(self):
578+
ROW_COUNT = 40
579+
session, committed = self._set_up_table(ROW_COUNT)
580+
all_data_rows = list(self._row_data(ROW_COUNT))
581+
strong = session.snapshot(multi_use=True)
582+
583+
before = list(strong.read(self.TABLE, self.COLUMNS, self.ALL))
584+
self._check_row_data(before, all_data_rows)
585+
586+
with self._db.batch() as batch:
587+
batch.delete(self.TABLE, self.ALL)
588+
589+
after = list(strong.read(self.TABLE, self.COLUMNS, self.ALL))
590+
self._check_row_data(after, all_data_rows)
591+
577592
def test_read_w_manual_consume(self):
578593
ROW_COUNT = 4000
579594
session, committed = self._set_up_table(ROW_COUNT)
@@ -723,6 +738,22 @@ def _check_sql_results(self, snapshot, sql, params, param_types, expected):
723738
sql, params=params, param_types=param_types))
724739
self._check_row_data(rows, expected=expected)
725740

741+
def test_multiuse_snapshot_execute_sql_isolation_strong(self):
742+
ROW_COUNT = 40
743+
SQL = 'SELECT * FROM {}'.format(self.TABLE)
744+
session, committed = self._set_up_table(ROW_COUNT)
745+
all_data_rows = list(self._row_data(ROW_COUNT))
746+
strong = session.snapshot(multi_use=True)
747+
748+
before = list(strong.execute_sql(SQL))
749+
self._check_row_data(before, all_data_rows)
750+
751+
with self._db.batch() as batch:
752+
batch.delete(self.TABLE, self.ALL)
753+
754+
after = list(strong.execute_sql(SQL))
755+
self._check_row_data(after, all_data_rows)
756+
726757
def test_execute_sql_returning_array_of_struct(self):
727758
SQL = (
728759
"SELECT ARRAY(SELECT AS STRUCT C1, C2 "

0 commit comments

Comments
 (0)