diff --git a/tests/system/conftest.py b/tests/system/conftest.py index 778cf8c94..b48e7a62a 100644 --- a/tests/system/conftest.py +++ b/tests/system/conftest.py @@ -41,7 +41,7 @@ def with_kms_key_name(kms_key_name): @pytest.fixture(scope="session") -def not_in_emulator(in_emulator): +def skip_on_emulator(in_emulator): if in_emulator: pytest.skip("Emulator does not support this feature") @@ -146,13 +146,13 @@ def data_instance_populated( serve_nodes, in_emulator, ): + instance = admin_client.instance(data_instance_id, labels=instance_labels) + cluster = instance.cluster( + data_cluster_id, location_id=location_id, serve_nodes=serve_nodes, + ) # Emulator does not support instance admin operations (create / delete). # See: https://cloud.google.com/bigtable/docs/emulator if not in_emulator: - instance = admin_client.instance(data_instance_id, labels=instance_labels) - cluster = instance.cluster( - data_cluster_id, location_id=location_id, serve_nodes=serve_nodes, - ) operation = instance.create(clusters=[cluster]) operation.result(timeout=30) diff --git a/tests/system/test_data_api.py b/tests/system/test_data_api.py index 2137aa2e4..2ca7e1504 100644 --- a/tests/system/test_data_api.py +++ b/tests/system/test_data_api.py @@ -210,7 +210,7 @@ def test_rowset_add_row_range_w_pfx(data_table, rows_to_delete): assert found_row_keys == expected_row_keys -def test_table_read_row_large_cell(data_table, rows_to_delete, not_in_emulator): +def test_table_read_row_large_cell(data_table, rows_to_delete, skip_on_emulator): # Maximum gRPC received message size for emulator is 4194304 bytes. row = data_table.direct_row(ROW_KEY) rows_to_delete.append(row) @@ -325,7 +325,7 @@ def test_table_read_rows(data_table, rows_to_delete): assert rows_data.rows == expected_rows -def test_read_with_label_applied(data_table, rows_to_delete, not_in_emulator): +def test_read_with_label_applied(data_table, rows_to_delete, skip_on_emulator): from google.cloud.bigtable.row_filters import ApplyLabelFilter from google.cloud.bigtable.row_filters import ColumnQualifierRegexFilter from google.cloud.bigtable.row_filters import RowFilterChain diff --git a/tests/system/test_instance_admin.py b/tests/system/test_instance_admin.py index c5f7b525e..c3e419a11 100644 --- a/tests/system/test_instance_admin.py +++ b/tests/system/test_instance_admin.py @@ -96,7 +96,9 @@ def _delete_app_profile_helper(app_profile): assert not app_profile.exists() -def test_client_list_instances(admin_client, admin_instance_populated, not_in_emulator): +def test_client_list_instances( + admin_client, admin_instance_populated, skip_on_emulator +): instances, failed_locations = admin_client.list_instances() assert failed_locations == [] @@ -105,20 +107,20 @@ def test_client_list_instances(admin_client, admin_instance_populated, not_in_em assert admin_instance_populated.name in found -def test_instance_exists_hit(admin_instance_populated): +def test_instance_exists_hit(admin_instance_populated, skip_on_emulator): # Emulator does not support instance admin operations (create / delete). # It allows connecting with *any* project / instance name. # See: https://cloud.google.com/bigtable/docs/emulator assert admin_instance_populated.exists() -def test_instance_exists_miss(admin_client): +def test_instance_exists_miss(admin_client, skip_on_emulator): alt_instance = admin_client.instance("nonesuch-instance") assert not alt_instance.exists() def test_instance_reload( - admin_client, admin_instance_id, admin_instance_populated, not_in_emulator + admin_client, admin_instance_id, admin_instance_populated, skip_on_emulator ): # Use same arguments as 'admin_instance_populated' # so we can use reload() on a fresh instance. @@ -139,7 +141,7 @@ def test_instance_create_prod( location_id, instance_labels, instances_to_delete, - not_in_emulator, + skip_on_emulator, ): from google.cloud.bigtable import enums @@ -171,7 +173,7 @@ def test_instance_create_development( location_id, instance_labels, instances_to_delete, - not_in_emulator, + skip_on_emulator, ): alt_instance_id = f"new{unique_suffix}" instance = admin_client.instance( @@ -205,7 +207,7 @@ def test_instance_create_w_two_clusters( location_id, instance_labels, instances_to_delete, - not_in_emulator, + skip_on_emulator, ): alt_instance_id = f"dif{unique_suffix}" instance = admin_client.instance( @@ -400,7 +402,7 @@ def test_instance_create_w_two_clusters_cmek( instance_labels, instances_to_delete, with_kms_key_name, - not_in_emulator, + skip_on_emulator, ): alt_instance_id = f"dif-cmek{unique_suffix}" instance = admin_client.instance( @@ -484,7 +486,7 @@ def test_instance_update_display_name_and_labels( admin_instance_populated, label_key, instance_labels, - not_in_emulator, + skip_on_emulator, ): old_display_name = admin_instance_populated.display_name new_display_name = "Foo Bar Baz" @@ -521,7 +523,7 @@ def test_instance_update_w_type( location_id, instance_labels, instances_to_delete, - not_in_emulator, + skip_on_emulator, ): alt_instance_id = f"ndif{unique_suffix}" instance = admin_client.instance( @@ -548,17 +550,17 @@ def test_instance_update_w_type( assert instance_alt.type_ == enums.Instance.Type.PRODUCTION -def test_cluster_exists_hit(admin_cluster, not_in_emulator): +def test_cluster_exists_hit(admin_cluster, skip_on_emulator): assert admin_cluster.exists() -def test_cluster_exists_miss(admin_instance_populated, not_in_emulator): +def test_cluster_exists_miss(admin_instance_populated, skip_on_emulator): alt_cluster = admin_instance_populated.cluster("nonesuch-cluster") assert not alt_cluster.exists() def test_cluster_create( - admin_instance_populated, admin_instance_id, + admin_instance_populated, admin_instance_id, skip_on_emulator, ): alt_cluster_id = f"{admin_instance_id}-c2" alt_location_id = "us-central1-f" @@ -594,7 +596,7 @@ def test_cluster_update( admin_cluster_id, admin_cluster, serve_nodes, - not_in_emulator, + skip_on_emulator, ): new_serve_nodes = 4 diff --git a/tests/system/test_table_admin.py b/tests/system/test_table_admin.py index 232c6d0fc..1ed540d63 100644 --- a/tests/system/test_table_admin.py +++ b/tests/system/test_table_admin.py @@ -57,7 +57,7 @@ def backups_to_delete(): backup.delete() -def test_instance_list_tables(data_instance_populated, shared_table): +def test_instance_list_tables(data_instance_populated, shared_table, skip_on_emulator): # Since `data_instance_populated` is newly created, the # table created in `shared_table` here will be the only one. tables = data_instance_populated.list_tables() @@ -115,7 +115,7 @@ def test_table_create_w_families( def test_table_create_w_split_keys( - data_instance_populated, tables_to_delete, not_in_emulator, + data_instance_populated, tables_to_delete, skip_on_emulator ): temp_table_id = "foo-bar-baz-split-table" initial_split_keys = [b"split_key_1", b"split_key_10", b"split_key_20"] @@ -203,7 +203,7 @@ def test_column_family_delete(data_instance_populated, tables_to_delete): def test_table_get_iam_policy( - data_instance_populated, tables_to_delete, not_in_emulator, + data_instance_populated, tables_to_delete, skip_on_emulator ): temp_table_id = "test-get-iam-policy-table" temp_table = data_instance_populated.table(temp_table_id) @@ -216,7 +216,7 @@ def test_table_get_iam_policy( def test_table_set_iam_policy( - service_account, data_instance_populated, tables_to_delete, not_in_emulator, + service_account, data_instance_populated, tables_to_delete, skip_on_emulator ): from google.cloud.bigtable.policy import BIGTABLE_ADMIN_ROLE from google.cloud.bigtable.policy import Policy @@ -236,7 +236,7 @@ def test_table_set_iam_policy( def test_table_test_iam_permissions( - data_instance_populated, tables_to_delete, not_in_emulator, + data_instance_populated, tables_to_delete, skip_on_emulator, ): temp_table_id = "test-test-iam-policy-table" temp_table = data_instance_populated.table(temp_table_id) @@ -258,7 +258,7 @@ def test_table_backup( instances_to_delete, tables_to_delete, backups_to_delete, - not_in_emulator, + skip_on_emulator, ): from google.cloud._helpers import _datetime_to_pb_timestamp from google.cloud.bigtable import enums