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

Commit d6dc201

Browse files
authored
chore(tests): system tests for autogen API (#1151)
* tests: system tests for autogen API * Fixed async system tests * addressed review feedback * Fixed system test failure at the end of a test run * Linting * more linting
1 parent 927f026 commit d6dc201

14 files changed

Lines changed: 743 additions & 28 deletions

File tree

google/cloud/bigtable/admin_v2/overlay/__init__.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,9 @@
3030
# client class under overlay/services.
3131

3232
from .types import (
33+
AsyncRestoreTableOperation,
3334
RestoreTableOperation,
35+
WaitForConsistencyRequest,
3436
)
3537

3638
from .services.bigtable_table_admin import (
@@ -39,7 +41,9 @@
3941
)
4042

4143
__all__ = (
44+
"AsyncRestoreTableOperation",
4245
"RestoreTableOperation",
4346
"BigtableTableAdminAsyncClient",
4447
"BigtableTableAdminClient",
48+
"WaitForConsistencyRequest",
4549
)

google/cloud/bigtable/admin_v2/overlay/types/__init__.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15+
from .async_restore_table import (
16+
AsyncRestoreTableOperation,
17+
)
18+
1519
from .restore_table import (
1620
RestoreTableOperation,
1721
)
@@ -21,6 +25,7 @@
2125
)
2226

2327
__all__ = (
28+
"AsyncRestoreTableOperation",
2429
"RestoreTableOperation",
2530
"WaitForConsistencyRequest",
2631
)

google/cloud/bigtable/admin_v2/overlay/types/async_consistency.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@
2525
OptionalRetry = Union[retries.Retry, object, None] # type: ignore
2626

2727

28+
# The consistency check could take a very long time, so we wait indefinitely.
29+
DEFAULT_RETRY = async_future.DEFAULT_RETRY.with_timeout(None)
30+
31+
2832
class _AsyncCheckConsistencyPollingFuture(async_future.AsyncFuture):
2933
"""A Future that polls an underlying `check_consistency` operation until it returns True.
3034
@@ -48,7 +52,7 @@ class _AsyncCheckConsistencyPollingFuture(async_future.AsyncFuture):
4852
<google.cloud.bigtable.admin_v2.overlay.services.bigtable_table_admin.BigtableTableAdminClient.wait_for_consistency>`
4953
or :meth:`wait_for_replication
5054
<google.cloud.bigtable.admin_v2.overlay.services.bigtable_table_admin.BigtableTableAdminClient.wait_for_replication>`
51-
retry (google.api_core.retry.Retry): The retry configuration used
55+
retry (google.api_core.retry.AsyncRetry): The retry configuration used
5256
when polling. This can be used to control how often :meth:`done`
5357
is polled. Regardless of the retry's ``deadline``, it will be
5458
overridden by the ``timeout`` argument to :meth:`result`.
@@ -59,7 +63,7 @@ def __init__(
5963
check_consistency_call: Callable[
6064
[OptionalRetry], Awaitable[bigtable_table_admin.CheckConsistencyResponse]
6165
],
62-
retry: retries.Retry = async_future.DEFAULT_RETRY,
66+
retry: retries.AsyncRetry = DEFAULT_RETRY,
6367
**kwargs
6468
):
6569
super(_AsyncCheckConsistencyPollingFuture, self).__init__(retry=retry, **kwargs)

google/cloud/bigtable/admin_v2/overlay/types/consistency.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@
2525
OptionalRetry = Union[retries.Retry, object, None] # type: ignore
2626

2727

28+
# The consistency check could take a very long time, so we wait indefinitely.
29+
DEFAULT_RETRY = polling.DEFAULT_POLLING.with_timeout(None)
30+
31+
2832
class _CheckConsistencyPollingFuture(polling.PollingFuture):
2933
"""A Future that polls an underlying `check_consistency` operation until it returns True.
3034
@@ -55,7 +59,7 @@ def __init__(
5559
check_consistency_call: Callable[
5660
[OptionalRetry], bigtable_table_admin.CheckConsistencyResponse
5761
],
58-
polling: retries.Retry = polling.DEFAULT_POLLING,
62+
polling: retries.Retry = DEFAULT_RETRY,
5963
**kwargs
6064
):
6165
super(_CheckConsistencyPollingFuture, self).__init__(polling=polling, **kwargs)

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
# 'Development Status :: 5 - Production/Stable'
3838
release_status = "Development Status :: 5 - Production/Stable"
3939
dependencies = [
40-
"google-api-core[grpc] >= 2.16.0, <3.0.0",
40+
"google-api-core[grpc] >= 2.17.0, <3.0.0",
4141
"google-cloud-core >= 1.4.4, <3.0.0",
4242
"google-auth >= 2.14.1, <3.0.0,!=2.24.0,!=2.25.0",
4343
"grpc-google-iam-v1 >= 0.12.4, <1.0.0",

testing/constraints-3.7.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
#
66
# e.g., if setup.py has "foo >= 1.14.0, < 2.0.0dev",
77
# Then this file should have foo==1.14.0
8-
google-api-core==2.16.0
8+
google-api-core==2.17.0
99
google-auth==2.14.1
1010
google-cloud-core==2.0.0
1111
grpc-google-iam-v1==0.12.4

testing/constraints-3.8.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
#
66
# e.g., if setup.py has "foo >= 1.14.0, < 2.0.0dev",
77
# Then this file should have foo==1.14.0
8-
google-api-core==2.16.0
8+
google-api-core==2.17.0
99
google-auth==2.14.1
1010
google-cloud-core==2.0.0
1111
grpc-google-iam-v1==0.12.4

tests/system/admin_overlay/__init__.py

Whitespace-only changes.
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
import google.auth
2+
3+
import os
4+
import pytest
5+
import uuid
6+
7+
8+
INSTANCE_PREFIX = "admin-overlay-instance"
9+
BACKUP_PREFIX = "admin-overlay-backup"
10+
ROW_PREFIX = "test-row"
11+
12+
DEFAULT_CLUSTER_LOCATIONS = ["us-east1-b"]
13+
REPLICATION_CLUSTER_LOCATIONS = ["us-east1-b", "us-west1-b"]
14+
TEST_TABLE_NAME = "system-test-table"
15+
TEST_BACKUP_TABLE_NAME = "system-test-backup-table"
16+
TEST_COLUMMN_FAMILY_NAME = "test-column"
17+
TEST_COLUMN_NAME = "value"
18+
NUM_ROWS = 500
19+
INITIAL_CELL_VALUE = "Hello"
20+
NEW_CELL_VALUE = "World"
21+
22+
23+
@pytest.fixture(scope="session")
24+
def admin_overlay_project_id():
25+
_, default_project = google.auth.default()
26+
yield os.getenv("GOOGLE_CLOUD_PROJECT") or default_project
27+
28+
29+
def generate_unique_suffix(name):
30+
"""
31+
Generates a unique suffix for the name.
32+
33+
Uses UUID4 because using time.time doesn't guarantee
34+
uniqueness when the time is frozen in containers.
35+
"""
36+
return f"{name}-{uuid.uuid4().hex[:7]}"

0 commit comments

Comments
 (0)