Skip to content

Commit

Permalink
Sort system-test.test_transaction_abort_then_retry_spans spans by cre…
Browse files Browse the repository at this point in the history
…ate time
  • Loading branch information
odeke-em committed Dec 16, 2024
1 parent a69a4dc commit 3ac60b9
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions tests/system/test_observability_options.py
Original file line number Diff line number Diff line change
Expand Up @@ -213,14 +213,16 @@ def select_in_txn(txn):
db.run_in_transaction(select_in_txn)

span_list = trace_exporter.get_finished_spans()
# Sort the spans by their start time in the hierarchy.
span_list = sorted(span_list, key=lambda span: span.start_time)
got_span_names = [span.name for span in span_list]
want_span_names = [
"CloudSpanner.Database.run_in_transaction",
"CloudSpanner.CreateSession",
"CloudSpanner.Session.run_in_transaction",
"CloudSpanner.Transaction.execute_streaming_sql",
"CloudSpanner.Transaction.execute_streaming_sql",
"CloudSpanner.Transaction.commit",
"CloudSpanner.Session.run_in_transaction",
"CloudSpanner.Database.run_in_transaction",
]

assert got_span_names == want_span_names
Expand All @@ -245,28 +247,28 @@ def select_in_txn(txn):

# Check for the series of events
want_events = [
("Starting Commit", {}),
("Commit Done", {}),
(
"Transaction was aborted in user operation, retrying",
{"delay_seconds": "EPHEMERAL", "cause": "EPHEMERAL", "attempt": 1},
),
("Acquiring session", {"kind": "BurstyPool"}),
("Waiting for a session to become available", {"kind": "BurstyPool"}),
("No sessions available in pool. Creating session", {"kind": "BurstyPool"}),
("Creating Session", {}),
(
"Transaction was aborted in user operation, retrying",
{"delay_seconds": "EPHEMERAL", "cause": "EPHEMERAL", "attempt": 1},
),
("Starting Commit", {}),
("Commit Done", {}),
]
assert got_events == want_events

# Check for the statues.
codes = StatusCode
want_statuses = [
("CloudSpanner.Database.run_in_transaction", codes.OK, None),
("CloudSpanner.CreateSession", codes.OK, None),
("CloudSpanner.Session.run_in_transaction", codes.OK, None),
("CloudSpanner.Transaction.execute_streaming_sql", codes.OK, None),
("CloudSpanner.Transaction.execute_streaming_sql", codes.OK, None),
("CloudSpanner.Transaction.commit", codes.OK, None),
("CloudSpanner.Session.run_in_transaction", codes.OK, None),
("CloudSpanner.Database.run_in_transaction", codes.OK, None),
]
assert got_statuses == want_statuses

Expand Down

0 comments on commit 3ac60b9

Please sign in to comment.