-
Notifications
You must be signed in to change notification settings - Fork 99
Closed
Labels
api: spannerIssues related to the googleapis/python-spanner API.Issues related to the googleapis/python-spanner API.priority: p3Desirable enhancement or fix. May not be included in next release.Desirable enhancement or fix. May not be included in next release.type: cleanupAn internal cleanup or hygiene concern.An internal cleanup or hygiene concern.
Description
The OpenTelemetry assertions in the system tests fail if the transaction is aborted and retried. This is extremely brittle so the assertions need to be updated to account for retrying aborted transactions.
Example of test failure:
________ TestSessionAPI.test_transaction_read_and_insert_then_rollback _________
self = <tests.system.test_system.TestSessionAPI testMethod=test_transaction_read_and_insert_then_rollback>
@RetryErrors(exception=exceptions.ServerError)
@RetryErrors(exception=exceptions.Aborted)
def test_transaction_read_and_insert_then_rollback(self):
retry = RetryInstanceState(_has_all_ddl)
retry(self._db.reload)()
session = self._db.session()
session.create()
self.to_delete.append(session)
with self._db.batch() as batch:
batch.delete(self.TABLE, self.ALL)
transaction = session.transaction()
transaction.begin()
rows = list(transaction.read(self.TABLE, self.COLUMNS, self.ALL))
self.assertEqual(rows, [])
transaction.insert(self.TABLE, self.COLUMNS, self.ROW_DATA)
# Inserted rows can't be read until after commit.
rows = list(transaction.read(self.TABLE, self.COLUMNS, self.ALL))
self.assertEqual(rows, [])
transaction.rollback()
rows = list(session.read(self.TABLE, self.COLUMNS, self.ALL))
self.assertEqual(rows, [])
if HAS_OPENTELEMETRY_INSTALLED:
span_list = self.memory_exporter.get_finished_spans()
> self.assertEqual(len(span_list), 8)
E AssertionError: 14 != 8
tests/system/test_system.py:1026: AssertionError
----------------------------- Captured stdout call -----------------------------
409 Transaction was aborted., Trying again in 1 seconds...
------------------------------ Captured log call -------------------------------
WARNING opentelemetry.trace:__init__.py:468 Overriding current TracerProvider
WARNING opentelemetry.trace:__init__.py:468 Overriding current TracerProvider
Metadata
Metadata
Assignees
Labels
api: spannerIssues related to the googleapis/python-spanner API.Issues related to the googleapis/python-spanner API.priority: p3Desirable enhancement or fix. May not be included in next release.Desirable enhancement or fix. May not be included in next release.type: cleanupAn internal cleanup or hygiene concern.An internal cleanup or hygiene concern.