Skip to content

Commit

Permalink
Tests for with_request_id
Browse files Browse the repository at this point in the history
  • Loading branch information
odeke-em committed Dec 19, 2024
1 parent 1f52008 commit 10036f3
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
1 change: 1 addition & 0 deletions google/cloud/spanner_v1/_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
from google.cloud.spanner_v1 import TypeCode
from google.cloud.spanner_v1 import ExecuteSqlRequest
from google.cloud.spanner_v1 import JsonObject
from google.cloud.spanner_v1.request_id_header import with_request_id

# Validation error messages
NUMERIC_MAX_SCALE_ERR_MSG = (
Expand Down
6 changes: 3 additions & 3 deletions google/cloud/spanner_v1/request_id_header.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
# limitations under the License.

import os
import threading

REQ_ID_VERSION = 1 # The version of the x-goog-spanner-request-id spec.
REQ_ID_HEADER_KEY = "x-goog-spanner-request-id"
Expand All @@ -38,5 +37,6 @@ def generate_rand_uint64():

def with_request_id(client_id, channel_id, nth_request, attempt, other_metadata=[]):
req_id = f"{REQ_ID_VERSION}.{REQ_RAND_PROCESS_ID}.{client_id}.{channel_id}.{nth_request}.{attempt}"
other_metadata.append((REQ_ID_HEADER_KEY, req_id))
return other_metadata
all_metadata = other_metadata.copy()
all_metadata.append((REQ_ID_HEADER_KEY, req_id))
return all_metadata
2 changes: 1 addition & 1 deletion tests/unit/test_atomic_counter.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ def do_work():
random.shuffle(threads)
for th in threads:
th.join()
assert th.is_alive() == False
assert not th.is_alive()

# Finally the result should be n*m
assert ac.value == n * m

0 comments on commit 10036f3

Please sign in to comment.