Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: fix result ordering errors for emulator #81

Merged
merged 2 commits into from
May 26, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
18 changes: 10 additions & 8 deletions tests/system/test_system.py
Original file line number Diff line number Diff line change
Expand Up @@ -1359,12 +1359,12 @@ def test_transaction_read_w_abort(self):
@staticmethod
def _row_data(max_index):
for index in range(max_index):
yield [
yield (
index,
"First%09d" % (index,),
"Last%09d" % (max_index - index),
"test-%09d@example.com" % (index,),
]
)

def _set_up_table(self, row_count, database=None):
if database is None:
Expand Down Expand Up @@ -1895,18 +1895,17 @@ def _check_sql_results(

def test_multiuse_snapshot_execute_sql_isolation_strong(self):
ROW_COUNT = 40
SQL = "SELECT * FROM {}".format(self.TABLE)
self._set_up_table(ROW_COUNT)
all_data_rows = list(self._row_data(ROW_COUNT))
with self._db.snapshot(multi_use=True) as strong:

before = list(strong.execute_sql(SQL))
before = list(strong.execute_sql(self.SQL))
self._check_row_data(before, all_data_rows)

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

after = list(strong.execute_sql(SQL))
after = list(strong.execute_sql(self.SQL))
self._check_row_data(after, all_data_rows)

def test_execute_sql_returning_array_of_struct(self):
Expand Down Expand Up @@ -2334,13 +2333,16 @@ def test_partition_query(self):
row_count = 40
sql = "SELECT * FROM {}".format(self.TABLE)
committed = self._set_up_table(row_count)
all_data_rows = list(self._row_data(row_count))

union = []
# Paritioned query does not support ORDER BY
all_data_rows = set(self._row_data(row_count))
union = set()
batch_txn = self._db.batch_snapshot(read_timestamp=committed)
for batch in batch_txn.generate_query_batches(sql):
p_results_iter = batch_txn.process(batch)
union.extend(list(p_results_iter))
# Lists aren't hashable so the results need to be converted
rows = [tuple(result) for result in p_results_iter]
union.update(set(rows))

self.assertEqual(union, all_data_rows)
batch_txn.close()
Expand Down