Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
odeke-em committed Nov 20, 2024
1 parent 0c9bff3 commit f767159
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 8 deletions.
7 changes: 4 additions & 3 deletions google/cloud/spanner_v1/session.py
Original file line number Diff line number Diff line change
Expand Up @@ -439,7 +439,8 @@ def run_in_transaction(self, func, *args, **kw):

attempts += 1

span_attributes = {"transaction.id": txn.id, "attempt": attempts}
txn_id = getattr(txn, "_transaction_id", None) or ""
span_attributes = {"transaction.id": txn_id, "attempt": attempts}
if span:
span.add_event("Using Transaction", span_attributes)

Expand All @@ -448,7 +449,7 @@ def run_in_transaction(self, func, *args, **kw):
except Aborted as exc:
del self._transaction
if span:
delay_seconds = _get_retry_delay(exc, attempts)
delay_seconds = _get_retry_delay(exc.errors[0], attempts)
attributes = dict(delay_seconds=delay_seconds)
attributes.update(span_attributes)
span.add_event("Transaction was aborted, retrying", attributes)
Expand Down Expand Up @@ -481,7 +482,7 @@ def run_in_transaction(self, func, *args, **kw):
except Aborted as exc:
del self._transaction
if span:
delay_seconds = _get_retry_delay(exc, attempts)
delay_seconds = _get_retry_delay(exc.errors[0], attempts)
attributes = dict(delay_seconds=delay_seconds)
attributes.update(span_attributes)
span.add_event(
Expand Down
7 changes: 2 additions & 5 deletions tests/system/test_session_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -1194,11 +1194,8 @@ def unit_of_work(transaction):
]
assert [span.name for span in span_list] == expected_span_names
for span in span_list[2:-2]:
assert (
span.get_span_context().trace_id
== span_list[-1].get_span_context().trace_id
)
assert span.parent.span_id == span_list[-2].get_span_context().span_id
assert span.context.trace_id == span_list[-2].context.trace_id
assert span.parent.span_id == span_list[-2].context.span_id


def test_execute_partitioned_dml(
Expand Down

0 comments on commit f767159

Please sign in to comment.