Skip to content

Commit 85dddcf

Browse files
1 parent f224acb commit 85dddcf

File tree

3 files changed

+68
-16
lines changed

3 files changed

+68
-16
lines changed

‎tests/system/_sample_data.py‎

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -88,10 +88,14 @@ def _assert_timestamp(value, nano_value):
8888
if time_diff < 1:
8989
if isinstance(value, datetime_helpers.DatetimeWithNanoseconds):
9090
expected_ns = value.nanosecond
91-
found_ns = getattr(nano_value, 'nanosecond', nano_value.microsecond * 1000)
92-
assert abs(expected_ns - found_ns) <= 1_000_000, f"Nanosecond diff {abs(expected_ns - found_ns)} > 1ms"
91+
found_ns = getattr(nano_value, "nanosecond", nano_value.microsecond * 1000)
92+
assert (
93+
abs(expected_ns - found_ns) <= 1_000_000
94+
), f"Nanosecond diff {abs(expected_ns - found_ns)} > 1ms"
9395
else:
94-
assert abs(value.microsecond - nano_value.microsecond) <= 1, f"Microsecond diff {abs(value.microsecond - nano_value.microsecond)} > 1"
96+
assert (
97+
abs(value.microsecond - nano_value.microsecond) <= 1
98+
), f"Microsecond diff {abs(value.microsecond - nano_value.microsecond)} > 1"
9599

96100

97101
def _check_rows_data(rows_data, expected=ROW_DATA, recurse_into_lists=True):
@@ -117,7 +121,11 @@ def _check_cell_data(found_cell, expected_cell, recurse_into_lists=True):
117121
elif isinstance(found_cell, float) and math.isnan(found_cell):
118122
assert math.isnan(expected_cell)
119123

120-
elif isinstance(found_cell, list) and isinstance(expected_cell, list) and all(isinstance(x, datetime.datetime) for x in found_cell):
124+
elif (
125+
isinstance(found_cell, list)
126+
and isinstance(expected_cell, list)
127+
and all(isinstance(x, datetime.datetime) for x in found_cell)
128+
):
121129
assert len(found_cell) == len(expected_cell)
122130
for found_item, expected_item in zip(found_cell, expected_cell):
123131
_assert_timestamp(expected_item, found_item)

‎tests/system/test_observability_options.py‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -416,17 +416,17 @@ def tx_update(txn):
416416
# Sort the spans by their start time in the hierarchy.
417417
span_list = sorted(span_list, key=lambda span: span.start_time)
418418
got_span_names = [span.name for span in span_list]
419-
419+
420420
# Check if multiplexed sessions are enabled for read-write transactions
421421
multiplexed_enabled = is_multiplexed_enabled(TransactionType.READ_WRITE)
422-
422+
423423
# Determine expected session span name based on multiplexed sessions
424424
expected_session_span_name = (
425425
"CloudSpanner.CreateMultiplexedSession"
426426
if multiplexed_enabled
427427
else "CloudSpanner.CreateSession"
428428
)
429-
429+
430430
want_span_names = [
431431
"CloudSpanner.Database.run_in_transaction",
432432
expected_session_span_name,

‎tests/system/test_session_api.py‎

Lines changed: 53 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -693,9 +693,9 @@ def transaction_work(transaction):
693693
multiplexed_enabled = is_multiplexed_enabled(TransactionType.READ_WRITE)
694694

695695
span_list = ot_exporter.get_finished_spans()
696-
print('DEBUG: Actual span names:')
696+
print("DEBUG: Actual span names:")
697697
for i, span in enumerate(span_list):
698-
print(f'{i}: {span.name}')
698+
print(f"{i}: {span.name}")
699699

700700
# Determine the first request ID from the spans,
701701
# and use an atomic counter to track it.
@@ -716,13 +716,57 @@ def _build_request_id():
716716
# Replace the entire block that builds expected_span_properties with:
717717
if multiplexed_enabled:
718718
expected_span_properties = [
719-
{"name": "CloudSpanner.Batch.commit", "attributes": _make_attributes(db_name, num_mutations=1, x_goog_spanner_request_id=_build_request_id())},
720-
{"name": "CloudSpanner.Transaction.read", "attributes": _make_attributes(db_name, table_id=sd.TABLE, columns=sd.COLUMNS, x_goog_spanner_request_id=_build_request_id())},
721-
{"name": "CloudSpanner.Transaction.read", "attributes": _make_attributes(db_name, table_id=sd.TABLE, columns=sd.COLUMNS, x_goog_spanner_request_id=_build_request_id())},
722-
{"name": "CloudSpanner.Transaction.rollback", "attributes": _make_attributes(db_name, x_goog_spanner_request_id=_build_request_id())},
723-
{"name": "CloudSpanner.Session.run_in_transaction", "status": ot_helpers.StatusCode.ERROR, "attributes": _make_attributes(db_name)},
724-
{"name": "CloudSpanner.Database.run_in_transaction", "status": ot_helpers.StatusCode.ERROR, "attributes": _make_attributes(db_name)},
725-
{"name": "CloudSpanner.Snapshot.read", "attributes": _make_attributes(db_name, table_id=sd.TABLE, columns=sd.COLUMNS, x_goog_spanner_request_id=_build_request_id())},
719+
{
720+
"name": "CloudSpanner.Batch.commit",
721+
"attributes": _make_attributes(
722+
db_name,
723+
num_mutations=1,
724+
x_goog_spanner_request_id=_build_request_id(),
725+
),
726+
},
727+
{
728+
"name": "CloudSpanner.Transaction.read",
729+
"attributes": _make_attributes(
730+
db_name,
731+
table_id=sd.TABLE,
732+
columns=sd.COLUMNS,
733+
x_goog_spanner_request_id=_build_request_id(),
734+
),
735+
},
736+
{
737+
"name": "CloudSpanner.Transaction.read",
738+
"attributes": _make_attributes(
739+
db_name,
740+
table_id=sd.TABLE,
741+
columns=sd.COLUMNS,
742+
x_goog_spanner_request_id=_build_request_id(),
743+
),
744+
},
745+
{
746+
"name": "CloudSpanner.Transaction.rollback",
747+
"attributes": _make_attributes(
748+
db_name, x_goog_spanner_request_id=_build_request_id()
749+
),
750+
},
751+
{
752+
"name": "CloudSpanner.Session.run_in_transaction",
753+
"status": ot_helpers.StatusCode.ERROR,
754+
"attributes": _make_attributes(db_name),
755+
},
756+
{
757+
"name": "CloudSpanner.Database.run_in_transaction",
758+
"status": ot_helpers.StatusCode.ERROR,
759+
"attributes": _make_attributes(db_name),
760+
},
761+
{
762+
"name": "CloudSpanner.Snapshot.read",
763+
"attributes": _make_attributes(
764+
db_name,
765+
table_id=sd.TABLE,
766+
columns=sd.COLUMNS,
767+
x_goog_spanner_request_id=_build_request_id(),
768+
),
769+
},
726770
]
727771
else:
728772
# [A] Batch spans

0 commit comments

Comments
 (0)