Skip to content

Commit

Permalink
Add systets for multiuse snapshots w/ read_timestamp / exact_staleness.
Browse files Browse the repository at this point in the history
  • Loading branch information
tseaver committed Jul 19, 2017
1 parent 26bdbc5 commit 7d6fa02
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions spanner/tests/system/test_system.py
Original file line number Diff line number Diff line change
Expand Up @@ -589,6 +589,43 @@ def test_multiuse_snapshot_read_isolation_strong(self):
after = list(strong.read(self.TABLE, self.COLUMNS, self.ALL))
self._check_row_data(after, all_data_rows)

def test_multiuse_snapshot_read_isolation_read_timestamp(self):
ROW_COUNT = 40
session, committed = self._set_up_table(ROW_COUNT)
all_data_rows = list(self._row_data(ROW_COUNT))
read_ts = session.snapshot(read_timestamp=committed, multi_use=True)

before = list(read_ts.read(self.TABLE, self.COLUMNS, self.ALL))
self._check_row_data(before, all_data_rows)

with self._db.batch() as batch:
batch.delete(self.TABLE, self.ALL)

after = list(read_ts.read(self.TABLE, self.COLUMNS, self.ALL))
self._check_row_data(after, all_data_rows)

def test_multiuse_snapshot_read_isolation_exact_staleness(self):
import time
from datetime import timedelta
ROW_COUNT = 40

session, committed = self._set_up_table(ROW_COUNT)
all_data_rows = list(self._row_data(ROW_COUNT))

time.sleep(1)
delta = timedelta(microseconds=1000)

exact = session.snapshot(exact_staleness=delta, multi_use=True)

before = list(exact.read(self.TABLE, self.COLUMNS, self.ALL))
self._check_row_data(before, all_data_rows)

with self._db.batch() as batch:
batch.delete(self.TABLE, self.ALL)

after = list(exact.read(self.TABLE, self.COLUMNS, self.ALL))
self._check_row_data(after, all_data_rows)

def test_read_w_manual_consume(self):
ROW_COUNT = 4000
session, committed = self._set_up_table(ROW_COUNT)
Expand Down

0 comments on commit 7d6fa02

Please sign in to comment.