Skip to content
This repository was archived by the owner on Apr 1, 2026. It is now read-only.

Commit 65f15de

Browse files
committed
updated system test
1 parent 3306ad7 commit 65f15de

2 files changed

Lines changed: 30 additions & 23 deletions

File tree

tests/system/data/test_system_async.py

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -285,23 +285,28 @@ async def test_channel_refresh(self, table_id, instance_id, temp_rows):
285285
async with client.get_table(instance_id, table_id) as table:
286286
rows = await table.read_rows({})
287287
channel_wrapper = client.transport.grpc_channel
288-
first_channel = client.transport.grpc_channel._channel
288+
first_channel = channel_wrapper._channel
289289
assert len(rows) == 2
290290
await CrossSync.sleep(2)
291291
rows_after_refresh = await table.read_rows({})
292292
assert len(rows_after_refresh) == 2
293293
assert client.transport.grpc_channel is channel_wrapper
294-
assert client.transport.grpc_channel._channel is not first_channel
295-
# ensure gapic's logging interceptor is still active
294+
updated_channel = channel_wrapper._channel
295+
assert updated_channel is not first_channel
296+
# ensure interceptors are kept (gapic's logging interceptor, and metric interceptor)
296297
if CrossSync.is_async:
297-
interceptors = (
298-
client.transport.grpc_channel._channel._unary_unary_interceptors
299-
)
300-
assert GapicInterceptor in [type(i) for i in interceptors]
298+
unary_interceptors = updated_channel._unary_unary_interceptors
299+
assert len(unary_interceptors) == 2
300+
assert GapicInterceptor in [type(i) for i in unary_interceptors]
301+
assert client._metrics_interceptor in unary_interceptors
302+
stream_interceptors = updated_channel._unary_stream_interceptors
303+
assert len(stream_interceptors) == 1
304+
assert client._metrics_interceptor in stream_interceptors
301305
else:
302306
assert isinstance(
303307
client.transport._logged_channel._interceptor, GapicInterceptor
304308
)
309+
assert updated_channel._interceptor == client._metrics_interceptor
305310
finally:
306311
await client.close()
307312

tests/system/data/test_system_autogen.py

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -237,16 +237,18 @@ def test_channel_refresh(self, table_id, instance_id, temp_rows):
237237
with client.get_table(instance_id, table_id) as table:
238238
rows = table.read_rows({})
239239
channel_wrapper = client.transport.grpc_channel
240-
first_channel = client.transport.grpc_channel._channel
240+
first_channel = channel_wrapper._channel
241241
assert len(rows) == 2
242242
CrossSync._Sync_Impl.sleep(2)
243243
rows_after_refresh = table.read_rows({})
244244
assert len(rows_after_refresh) == 2
245245
assert client.transport.grpc_channel is channel_wrapper
246-
assert client.transport.grpc_channel._channel is not first_channel
246+
updated_channel = channel_wrapper._channel
247+
assert updated_channel is not first_channel
247248
assert isinstance(
248249
client.transport._logged_channel._interceptor, GapicInterceptor
249250
)
251+
assert updated_channel._interceptor == client._metrics_interceptor
250252
finally:
251253
client.close()
252254

@@ -258,7 +260,7 @@ def test_mutation_set_cell(self, target, temp_rows):
258260
"""Ensure cells can be set properly"""
259261
row_key = b"bulk_mutate"
260262
new_value = uuid.uuid4().hex.encode()
261-
row_key, mutation = self._create_row_and_mutation(
263+
(row_key, mutation) = self._create_row_and_mutation(
262264
target, temp_rows, new_value=new_value
263265
)
264266
target.mutate_row(row_key, mutation)
@@ -312,7 +314,7 @@ def test_bulk_mutations_set_cell(self, client, target, temp_rows):
312314
from google.cloud.bigtable.data.mutations import RowMutationEntry
313315

314316
new_value = uuid.uuid4().hex.encode()
315-
row_key, mutation = self._create_row_and_mutation(
317+
(row_key, mutation) = self._create_row_and_mutation(
316318
target, temp_rows, new_value=new_value
317319
)
318320
bulk_mutation = RowMutationEntry(row_key, [mutation])
@@ -347,11 +349,11 @@ def test_mutations_batcher_context_manager(self, client, target, temp_rows):
347349
"""test batcher with context manager. Should flush on exit"""
348350
from google.cloud.bigtable.data.mutations import RowMutationEntry
349351

350-
new_value, new_value2 = [uuid.uuid4().hex.encode() for _ in range(2)]
351-
row_key, mutation = self._create_row_and_mutation(
352+
(new_value, new_value2) = [uuid.uuid4().hex.encode() for _ in range(2)]
353+
(row_key, mutation) = self._create_row_and_mutation(
352354
target, temp_rows, new_value=new_value
353355
)
354-
row_key2, mutation2 = self._create_row_and_mutation(
356+
(row_key2, mutation2) = self._create_row_and_mutation(
355357
target, temp_rows, new_value=new_value2
356358
)
357359
bulk_mutation = RowMutationEntry(row_key, [mutation])
@@ -372,7 +374,7 @@ def test_mutations_batcher_timer_flush(self, client, target, temp_rows):
372374
from google.cloud.bigtable.data.mutations import RowMutationEntry
373375

374376
new_value = uuid.uuid4().hex.encode()
375-
row_key, mutation = self._create_row_and_mutation(
377+
(row_key, mutation) = self._create_row_and_mutation(
376378
target, temp_rows, new_value=new_value
377379
)
378380
bulk_mutation = RowMutationEntry(row_key, [mutation])
@@ -394,12 +396,12 @@ def test_mutations_batcher_count_flush(self, client, target, temp_rows):
394396
"""batch should flush after flush_limit_mutation_count mutations"""
395397
from google.cloud.bigtable.data.mutations import RowMutationEntry
396398

397-
new_value, new_value2 = [uuid.uuid4().hex.encode() for _ in range(2)]
398-
row_key, mutation = self._create_row_and_mutation(
399+
(new_value, new_value2) = [uuid.uuid4().hex.encode() for _ in range(2)]
400+
(row_key, mutation) = self._create_row_and_mutation(
399401
target, temp_rows, new_value=new_value
400402
)
401403
bulk_mutation = RowMutationEntry(row_key, [mutation])
402-
row_key2, mutation2 = self._create_row_and_mutation(
404+
(row_key2, mutation2) = self._create_row_and_mutation(
403405
target, temp_rows, new_value=new_value2
404406
)
405407
bulk_mutation2 = RowMutationEntry(row_key2, [mutation2])
@@ -426,12 +428,12 @@ def test_mutations_batcher_bytes_flush(self, client, target, temp_rows):
426428
"""batch should flush after flush_limit_bytes bytes"""
427429
from google.cloud.bigtable.data.mutations import RowMutationEntry
428430

429-
new_value, new_value2 = [uuid.uuid4().hex.encode() for _ in range(2)]
430-
row_key, mutation = self._create_row_and_mutation(
431+
(new_value, new_value2) = [uuid.uuid4().hex.encode() for _ in range(2)]
432+
(row_key, mutation) = self._create_row_and_mutation(
431433
target, temp_rows, new_value=new_value
432434
)
433435
bulk_mutation = RowMutationEntry(row_key, [mutation])
434-
row_key2, mutation2 = self._create_row_and_mutation(
436+
(row_key2, mutation2) = self._create_row_and_mutation(
435437
target, temp_rows, new_value=new_value2
436438
)
437439
bulk_mutation2 = RowMutationEntry(row_key2, [mutation2])
@@ -457,11 +459,11 @@ def test_mutations_batcher_no_flush(self, client, target, temp_rows):
457459

458460
new_value = uuid.uuid4().hex.encode()
459461
start_value = b"unchanged"
460-
row_key, mutation = self._create_row_and_mutation(
462+
(row_key, mutation) = self._create_row_and_mutation(
461463
target, temp_rows, start_value=start_value, new_value=new_value
462464
)
463465
bulk_mutation = RowMutationEntry(row_key, [mutation])
464-
row_key2, mutation2 = self._create_row_and_mutation(
466+
(row_key2, mutation2) = self._create_row_and_mutation(
465467
target, temp_rows, start_value=start_value, new_value=new_value
466468
)
467469
bulk_mutation2 = RowMutationEntry(row_key2, [mutation2])

0 commit comments

Comments
 (0)