From 3e7349242406f8f376cdb51baed143bb709edb95 Mon Sep 17 00:00:00 2001 From: Daniel Sanche Date: Thu, 14 Dec 2023 14:19:01 -0800 Subject: [PATCH 01/13] added config to run samples in separate projects --- samples/snippets/noxfile_config.py | 41 ++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 samples/snippets/noxfile_config.py diff --git a/samples/snippets/noxfile_config.py b/samples/snippets/noxfile_config.py new file mode 100644 index 000000000..cf88dcf8c --- /dev/null +++ b/samples/snippets/noxfile_config.py @@ -0,0 +1,41 @@ +# Copyright 2023 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Default TEST_CONFIG_OVERRIDE for python repos. + +# You can copy this file into your directory, then it will be imported from +# the noxfile.py. + +# The source of truth: +# https://github.com/GoogleCloudPlatform/python-docs-samples/blob/main/noxfile_config.py + +TEST_CONFIG_OVERRIDE = { + # You can opt out from the test for specific Python versions. + "ignored_versions": ["2.7"], + # Old samples are opted out of enforcing Python type hints + # All new samples should feature them + "enforce_type_hints": False, + # An envvar key for determining the project id to use. Change it + # to 'BUILD_SPECIFIC_GCLOUD_PROJECT' if you want to opt in using a + # build specific Cloud project. You can also use your own string + # to use your own Cloud project. + "gcloud_project_env": "BUILD_SPECIFIC_GCLOUD_PROJECT", + # If you need to use a specific version of pip, + # change pip_version_override to the string representation + # of the version number, for example, "20.2.4" + "pip_version_override": None, + # A dictionary you want to inject into your test. Don't put any + # secrets here. These values will override predefined values. + "envs": {}, +} From 105aea08657ce913d9b6d808f6b87532f89cae54 Mon Sep 17 00:00:00 2001 From: Daniel Sanche Date: Thu, 14 Dec 2023 14:36:23 -0800 Subject: [PATCH 02/13] added noxfile_comfig to each samples dir --- samples/beam/noxfile_config.py | 3 +- samples/{snippets => hello}/noxfile_config.py | 0 samples/hello_happybase/noxfile_config.py | 41 +++++++++++++++++++ samples/instanceadmin/noxfile_config.py | 41 +++++++++++++++++++ samples/quickstart/noxfile_config.py | 41 +++++++++++++++++++ .../quickstart_happybase/noxfile_config.py | 41 +++++++++++++++++++ samples/snippets/deletes/noxfile_config.py | 41 +++++++++++++++++++ samples/snippets/filters/noxfile_config.py | 41 +++++++++++++++++++ samples/snippets/reads/noxfile_config.py | 41 +++++++++++++++++++ samples/snippets/writes/noxfile_config.py | 41 +++++++++++++++++++ samples/tableadmin/noxfile_config.py | 41 +++++++++++++++++++ 11 files changed, 370 insertions(+), 2 deletions(-) rename samples/{snippets => hello}/noxfile_config.py (100%) create mode 100644 samples/hello_happybase/noxfile_config.py create mode 100644 samples/instanceadmin/noxfile_config.py create mode 100644 samples/quickstart/noxfile_config.py create mode 100644 samples/quickstart_happybase/noxfile_config.py create mode 100644 samples/snippets/deletes/noxfile_config.py create mode 100644 samples/snippets/filters/noxfile_config.py create mode 100644 samples/snippets/reads/noxfile_config.py create mode 100644 samples/snippets/writes/noxfile_config.py create mode 100644 samples/tableadmin/noxfile_config.py diff --git a/samples/beam/noxfile_config.py b/samples/beam/noxfile_config.py index eb01435a0..f9a23f566 100644 --- a/samples/beam/noxfile_config.py +++ b/samples/beam/noxfile_config.py @@ -33,8 +33,7 @@ # to 'BUILD_SPECIFIC_GCLOUD_PROJECT' if you want to opt in using a # build specific Cloud project. You can also use your own string # to use your own Cloud project. - "gcloud_project_env": "GOOGLE_CLOUD_PROJECT", - # 'gcloud_project_env': 'BUILD_SPECIFIC_GCLOUD_PROJECT', + "gcloud_project_env": "BUILD_SPECIFIC_GCLOUD_PROJECT", # If you need to use a specific version of pip, # change pip_version_override to the string representation # of the version number, for example, "20.2.4" diff --git a/samples/snippets/noxfile_config.py b/samples/hello/noxfile_config.py similarity index 100% rename from samples/snippets/noxfile_config.py rename to samples/hello/noxfile_config.py diff --git a/samples/hello_happybase/noxfile_config.py b/samples/hello_happybase/noxfile_config.py new file mode 100644 index 000000000..cf88dcf8c --- /dev/null +++ b/samples/hello_happybase/noxfile_config.py @@ -0,0 +1,41 @@ +# Copyright 2023 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Default TEST_CONFIG_OVERRIDE for python repos. + +# You can copy this file into your directory, then it will be imported from +# the noxfile.py. + +# The source of truth: +# https://github.com/GoogleCloudPlatform/python-docs-samples/blob/main/noxfile_config.py + +TEST_CONFIG_OVERRIDE = { + # You can opt out from the test for specific Python versions. + "ignored_versions": ["2.7"], + # Old samples are opted out of enforcing Python type hints + # All new samples should feature them + "enforce_type_hints": False, + # An envvar key for determining the project id to use. Change it + # to 'BUILD_SPECIFIC_GCLOUD_PROJECT' if you want to opt in using a + # build specific Cloud project. You can also use your own string + # to use your own Cloud project. + "gcloud_project_env": "BUILD_SPECIFIC_GCLOUD_PROJECT", + # If you need to use a specific version of pip, + # change pip_version_override to the string representation + # of the version number, for example, "20.2.4" + "pip_version_override": None, + # A dictionary you want to inject into your test. Don't put any + # secrets here. These values will override predefined values. + "envs": {}, +} diff --git a/samples/instanceadmin/noxfile_config.py b/samples/instanceadmin/noxfile_config.py new file mode 100644 index 000000000..cf88dcf8c --- /dev/null +++ b/samples/instanceadmin/noxfile_config.py @@ -0,0 +1,41 @@ +# Copyright 2023 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Default TEST_CONFIG_OVERRIDE for python repos. + +# You can copy this file into your directory, then it will be imported from +# the noxfile.py. + +# The source of truth: +# https://github.com/GoogleCloudPlatform/python-docs-samples/blob/main/noxfile_config.py + +TEST_CONFIG_OVERRIDE = { + # You can opt out from the test for specific Python versions. + "ignored_versions": ["2.7"], + # Old samples are opted out of enforcing Python type hints + # All new samples should feature them + "enforce_type_hints": False, + # An envvar key for determining the project id to use. Change it + # to 'BUILD_SPECIFIC_GCLOUD_PROJECT' if you want to opt in using a + # build specific Cloud project. You can also use your own string + # to use your own Cloud project. + "gcloud_project_env": "BUILD_SPECIFIC_GCLOUD_PROJECT", + # If you need to use a specific version of pip, + # change pip_version_override to the string representation + # of the version number, for example, "20.2.4" + "pip_version_override": None, + # A dictionary you want to inject into your test. Don't put any + # secrets here. These values will override predefined values. + "envs": {}, +} diff --git a/samples/quickstart/noxfile_config.py b/samples/quickstart/noxfile_config.py new file mode 100644 index 000000000..cf88dcf8c --- /dev/null +++ b/samples/quickstart/noxfile_config.py @@ -0,0 +1,41 @@ +# Copyright 2023 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Default TEST_CONFIG_OVERRIDE for python repos. + +# You can copy this file into your directory, then it will be imported from +# the noxfile.py. + +# The source of truth: +# https://github.com/GoogleCloudPlatform/python-docs-samples/blob/main/noxfile_config.py + +TEST_CONFIG_OVERRIDE = { + # You can opt out from the test for specific Python versions. + "ignored_versions": ["2.7"], + # Old samples are opted out of enforcing Python type hints + # All new samples should feature them + "enforce_type_hints": False, + # An envvar key for determining the project id to use. Change it + # to 'BUILD_SPECIFIC_GCLOUD_PROJECT' if you want to opt in using a + # build specific Cloud project. You can also use your own string + # to use your own Cloud project. + "gcloud_project_env": "BUILD_SPECIFIC_GCLOUD_PROJECT", + # If you need to use a specific version of pip, + # change pip_version_override to the string representation + # of the version number, for example, "20.2.4" + "pip_version_override": None, + # A dictionary you want to inject into your test. Don't put any + # secrets here. These values will override predefined values. + "envs": {}, +} diff --git a/samples/quickstart_happybase/noxfile_config.py b/samples/quickstart_happybase/noxfile_config.py new file mode 100644 index 000000000..cf88dcf8c --- /dev/null +++ b/samples/quickstart_happybase/noxfile_config.py @@ -0,0 +1,41 @@ +# Copyright 2023 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Default TEST_CONFIG_OVERRIDE for python repos. + +# You can copy this file into your directory, then it will be imported from +# the noxfile.py. + +# The source of truth: +# https://github.com/GoogleCloudPlatform/python-docs-samples/blob/main/noxfile_config.py + +TEST_CONFIG_OVERRIDE = { + # You can opt out from the test for specific Python versions. + "ignored_versions": ["2.7"], + # Old samples are opted out of enforcing Python type hints + # All new samples should feature them + "enforce_type_hints": False, + # An envvar key for determining the project id to use. Change it + # to 'BUILD_SPECIFIC_GCLOUD_PROJECT' if you want to opt in using a + # build specific Cloud project. You can also use your own string + # to use your own Cloud project. + "gcloud_project_env": "BUILD_SPECIFIC_GCLOUD_PROJECT", + # If you need to use a specific version of pip, + # change pip_version_override to the string representation + # of the version number, for example, "20.2.4" + "pip_version_override": None, + # A dictionary you want to inject into your test. Don't put any + # secrets here. These values will override predefined values. + "envs": {}, +} diff --git a/samples/snippets/deletes/noxfile_config.py b/samples/snippets/deletes/noxfile_config.py new file mode 100644 index 000000000..cf88dcf8c --- /dev/null +++ b/samples/snippets/deletes/noxfile_config.py @@ -0,0 +1,41 @@ +# Copyright 2023 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Default TEST_CONFIG_OVERRIDE for python repos. + +# You can copy this file into your directory, then it will be imported from +# the noxfile.py. + +# The source of truth: +# https://github.com/GoogleCloudPlatform/python-docs-samples/blob/main/noxfile_config.py + +TEST_CONFIG_OVERRIDE = { + # You can opt out from the test for specific Python versions. + "ignored_versions": ["2.7"], + # Old samples are opted out of enforcing Python type hints + # All new samples should feature them + "enforce_type_hints": False, + # An envvar key for determining the project id to use. Change it + # to 'BUILD_SPECIFIC_GCLOUD_PROJECT' if you want to opt in using a + # build specific Cloud project. You can also use your own string + # to use your own Cloud project. + "gcloud_project_env": "BUILD_SPECIFIC_GCLOUD_PROJECT", + # If you need to use a specific version of pip, + # change pip_version_override to the string representation + # of the version number, for example, "20.2.4" + "pip_version_override": None, + # A dictionary you want to inject into your test. Don't put any + # secrets here. These values will override predefined values. + "envs": {}, +} diff --git a/samples/snippets/filters/noxfile_config.py b/samples/snippets/filters/noxfile_config.py new file mode 100644 index 000000000..cf88dcf8c --- /dev/null +++ b/samples/snippets/filters/noxfile_config.py @@ -0,0 +1,41 @@ +# Copyright 2023 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Default TEST_CONFIG_OVERRIDE for python repos. + +# You can copy this file into your directory, then it will be imported from +# the noxfile.py. + +# The source of truth: +# https://github.com/GoogleCloudPlatform/python-docs-samples/blob/main/noxfile_config.py + +TEST_CONFIG_OVERRIDE = { + # You can opt out from the test for specific Python versions. + "ignored_versions": ["2.7"], + # Old samples are opted out of enforcing Python type hints + # All new samples should feature them + "enforce_type_hints": False, + # An envvar key for determining the project id to use. Change it + # to 'BUILD_SPECIFIC_GCLOUD_PROJECT' if you want to opt in using a + # build specific Cloud project. You can also use your own string + # to use your own Cloud project. + "gcloud_project_env": "BUILD_SPECIFIC_GCLOUD_PROJECT", + # If you need to use a specific version of pip, + # change pip_version_override to the string representation + # of the version number, for example, "20.2.4" + "pip_version_override": None, + # A dictionary you want to inject into your test. Don't put any + # secrets here. These values will override predefined values. + "envs": {}, +} diff --git a/samples/snippets/reads/noxfile_config.py b/samples/snippets/reads/noxfile_config.py new file mode 100644 index 000000000..cf88dcf8c --- /dev/null +++ b/samples/snippets/reads/noxfile_config.py @@ -0,0 +1,41 @@ +# Copyright 2023 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Default TEST_CONFIG_OVERRIDE for python repos. + +# You can copy this file into your directory, then it will be imported from +# the noxfile.py. + +# The source of truth: +# https://github.com/GoogleCloudPlatform/python-docs-samples/blob/main/noxfile_config.py + +TEST_CONFIG_OVERRIDE = { + # You can opt out from the test for specific Python versions. + "ignored_versions": ["2.7"], + # Old samples are opted out of enforcing Python type hints + # All new samples should feature them + "enforce_type_hints": False, + # An envvar key for determining the project id to use. Change it + # to 'BUILD_SPECIFIC_GCLOUD_PROJECT' if you want to opt in using a + # build specific Cloud project. You can also use your own string + # to use your own Cloud project. + "gcloud_project_env": "BUILD_SPECIFIC_GCLOUD_PROJECT", + # If you need to use a specific version of pip, + # change pip_version_override to the string representation + # of the version number, for example, "20.2.4" + "pip_version_override": None, + # A dictionary you want to inject into your test. Don't put any + # secrets here. These values will override predefined values. + "envs": {}, +} diff --git a/samples/snippets/writes/noxfile_config.py b/samples/snippets/writes/noxfile_config.py new file mode 100644 index 000000000..cf88dcf8c --- /dev/null +++ b/samples/snippets/writes/noxfile_config.py @@ -0,0 +1,41 @@ +# Copyright 2023 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Default TEST_CONFIG_OVERRIDE for python repos. + +# You can copy this file into your directory, then it will be imported from +# the noxfile.py. + +# The source of truth: +# https://github.com/GoogleCloudPlatform/python-docs-samples/blob/main/noxfile_config.py + +TEST_CONFIG_OVERRIDE = { + # You can opt out from the test for specific Python versions. + "ignored_versions": ["2.7"], + # Old samples are opted out of enforcing Python type hints + # All new samples should feature them + "enforce_type_hints": False, + # An envvar key for determining the project id to use. Change it + # to 'BUILD_SPECIFIC_GCLOUD_PROJECT' if you want to opt in using a + # build specific Cloud project. You can also use your own string + # to use your own Cloud project. + "gcloud_project_env": "BUILD_SPECIFIC_GCLOUD_PROJECT", + # If you need to use a specific version of pip, + # change pip_version_override to the string representation + # of the version number, for example, "20.2.4" + "pip_version_override": None, + # A dictionary you want to inject into your test. Don't put any + # secrets here. These values will override predefined values. + "envs": {}, +} diff --git a/samples/tableadmin/noxfile_config.py b/samples/tableadmin/noxfile_config.py new file mode 100644 index 000000000..cf88dcf8c --- /dev/null +++ b/samples/tableadmin/noxfile_config.py @@ -0,0 +1,41 @@ +# Copyright 2023 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Default TEST_CONFIG_OVERRIDE for python repos. + +# You can copy this file into your directory, then it will be imported from +# the noxfile.py. + +# The source of truth: +# https://github.com/GoogleCloudPlatform/python-docs-samples/blob/main/noxfile_config.py + +TEST_CONFIG_OVERRIDE = { + # You can opt out from the test for specific Python versions. + "ignored_versions": ["2.7"], + # Old samples are opted out of enforcing Python type hints + # All new samples should feature them + "enforce_type_hints": False, + # An envvar key for determining the project id to use. Change it + # to 'BUILD_SPECIFIC_GCLOUD_PROJECT' if you want to opt in using a + # build specific Cloud project. You can also use your own string + # to use your own Cloud project. + "gcloud_project_env": "BUILD_SPECIFIC_GCLOUD_PROJECT", + # If you need to use a specific version of pip, + # change pip_version_override to the string representation + # of the version number, for example, "20.2.4" + "pip_version_override": None, + # A dictionary you want to inject into your test. Don't put any + # secrets here. These values will override predefined values. + "envs": {}, +} From 9162eaf9e51859e18e2312003458c3d2dd5ebc3f Mon Sep 17 00:00:00 2001 From: Daniel Sanche Date: Thu, 14 Dec 2023 14:37:08 -0800 Subject: [PATCH 03/13] added missing cover test --- tests/unit/test_row_data.py | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/tests/unit/test_row_data.py b/tests/unit/test_row_data.py index 9f2c40a54..7c2987b56 100644 --- a/tests/unit/test_row_data.py +++ b/tests/unit/test_row_data.py @@ -362,6 +362,30 @@ def test__retry_read_rows_exception_deadline_exceeded_wrapped_in_grpc(): assert _retry_read_rows_exception(exception) +def test_partial_cell_data(): + from google.cloud.bigtable.row_data import PartialCellData + + expected_key = b"row-key" + expected_family_name = b"family-name" + expected_qualifier = b"qualifier" + expected_timestamp = 1234 + instance = PartialCellData( + expected_key, expected_family_name, expected_qualifier, expected_timestamp + ) + assert instance.row_key == expected_key + assert instance.family_name == expected_family_name + assert instance.qualifier == expected_qualifier + assert instance.timestamp_micros == expected_timestamp + assert instance.value == b"" + assert instance.labels == () + # test updating value + added_value = b"added-value" + instance.append_value(added_value) + assert instance.value == added_value + instance.append_value(added_value) + assert instance.value == added_value + added_value + + def _make_partial_rows_data(*args, **kwargs): from google.cloud.bigtable.row_data import PartialRowsData From d29721305f4cb93ae5659df9ba2a2d1378242386 Mon Sep 17 00:00:00 2001 From: Daniel Sanche Date: Thu, 14 Dec 2023 14:56:15 -0800 Subject: [PATCH 04/13] Revert "added noxfile_comfig to each samples dir" This reverts commit 105aea08657ce913d9b6d808f6b87532f89cae54. --- samples/beam/noxfile_config.py | 3 +- samples/hello_happybase/noxfile_config.py | 41 ------------------- samples/instanceadmin/noxfile_config.py | 41 ------------------- samples/quickstart/noxfile_config.py | 41 ------------------- .../quickstart_happybase/noxfile_config.py | 41 ------------------- samples/snippets/deletes/noxfile_config.py | 41 ------------------- samples/snippets/filters/noxfile_config.py | 41 ------------------- samples/{hello => snippets}/noxfile_config.py | 0 samples/snippets/reads/noxfile_config.py | 41 ------------------- samples/snippets/writes/noxfile_config.py | 41 ------------------- samples/tableadmin/noxfile_config.py | 41 ------------------- 11 files changed, 2 insertions(+), 370 deletions(-) delete mode 100644 samples/hello_happybase/noxfile_config.py delete mode 100644 samples/instanceadmin/noxfile_config.py delete mode 100644 samples/quickstart/noxfile_config.py delete mode 100644 samples/quickstart_happybase/noxfile_config.py delete mode 100644 samples/snippets/deletes/noxfile_config.py delete mode 100644 samples/snippets/filters/noxfile_config.py rename samples/{hello => snippets}/noxfile_config.py (100%) delete mode 100644 samples/snippets/reads/noxfile_config.py delete mode 100644 samples/snippets/writes/noxfile_config.py delete mode 100644 samples/tableadmin/noxfile_config.py diff --git a/samples/beam/noxfile_config.py b/samples/beam/noxfile_config.py index f9a23f566..eb01435a0 100644 --- a/samples/beam/noxfile_config.py +++ b/samples/beam/noxfile_config.py @@ -33,7 +33,8 @@ # to 'BUILD_SPECIFIC_GCLOUD_PROJECT' if you want to opt in using a # build specific Cloud project. You can also use your own string # to use your own Cloud project. - "gcloud_project_env": "BUILD_SPECIFIC_GCLOUD_PROJECT", + "gcloud_project_env": "GOOGLE_CLOUD_PROJECT", + # 'gcloud_project_env': 'BUILD_SPECIFIC_GCLOUD_PROJECT', # If you need to use a specific version of pip, # change pip_version_override to the string representation # of the version number, for example, "20.2.4" diff --git a/samples/hello_happybase/noxfile_config.py b/samples/hello_happybase/noxfile_config.py deleted file mode 100644 index cf88dcf8c..000000000 --- a/samples/hello_happybase/noxfile_config.py +++ /dev/null @@ -1,41 +0,0 @@ -# Copyright 2023 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -# Default TEST_CONFIG_OVERRIDE for python repos. - -# You can copy this file into your directory, then it will be imported from -# the noxfile.py. - -# The source of truth: -# https://github.com/GoogleCloudPlatform/python-docs-samples/blob/main/noxfile_config.py - -TEST_CONFIG_OVERRIDE = { - # You can opt out from the test for specific Python versions. - "ignored_versions": ["2.7"], - # Old samples are opted out of enforcing Python type hints - # All new samples should feature them - "enforce_type_hints": False, - # An envvar key for determining the project id to use. Change it - # to 'BUILD_SPECIFIC_GCLOUD_PROJECT' if you want to opt in using a - # build specific Cloud project. You can also use your own string - # to use your own Cloud project. - "gcloud_project_env": "BUILD_SPECIFIC_GCLOUD_PROJECT", - # If you need to use a specific version of pip, - # change pip_version_override to the string representation - # of the version number, for example, "20.2.4" - "pip_version_override": None, - # A dictionary you want to inject into your test. Don't put any - # secrets here. These values will override predefined values. - "envs": {}, -} diff --git a/samples/instanceadmin/noxfile_config.py b/samples/instanceadmin/noxfile_config.py deleted file mode 100644 index cf88dcf8c..000000000 --- a/samples/instanceadmin/noxfile_config.py +++ /dev/null @@ -1,41 +0,0 @@ -# Copyright 2023 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -# Default TEST_CONFIG_OVERRIDE for python repos. - -# You can copy this file into your directory, then it will be imported from -# the noxfile.py. - -# The source of truth: -# https://github.com/GoogleCloudPlatform/python-docs-samples/blob/main/noxfile_config.py - -TEST_CONFIG_OVERRIDE = { - # You can opt out from the test for specific Python versions. - "ignored_versions": ["2.7"], - # Old samples are opted out of enforcing Python type hints - # All new samples should feature them - "enforce_type_hints": False, - # An envvar key for determining the project id to use. Change it - # to 'BUILD_SPECIFIC_GCLOUD_PROJECT' if you want to opt in using a - # build specific Cloud project. You can also use your own string - # to use your own Cloud project. - "gcloud_project_env": "BUILD_SPECIFIC_GCLOUD_PROJECT", - # If you need to use a specific version of pip, - # change pip_version_override to the string representation - # of the version number, for example, "20.2.4" - "pip_version_override": None, - # A dictionary you want to inject into your test. Don't put any - # secrets here. These values will override predefined values. - "envs": {}, -} diff --git a/samples/quickstart/noxfile_config.py b/samples/quickstart/noxfile_config.py deleted file mode 100644 index cf88dcf8c..000000000 --- a/samples/quickstart/noxfile_config.py +++ /dev/null @@ -1,41 +0,0 @@ -# Copyright 2023 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -# Default TEST_CONFIG_OVERRIDE for python repos. - -# You can copy this file into your directory, then it will be imported from -# the noxfile.py. - -# The source of truth: -# https://github.com/GoogleCloudPlatform/python-docs-samples/blob/main/noxfile_config.py - -TEST_CONFIG_OVERRIDE = { - # You can opt out from the test for specific Python versions. - "ignored_versions": ["2.7"], - # Old samples are opted out of enforcing Python type hints - # All new samples should feature them - "enforce_type_hints": False, - # An envvar key for determining the project id to use. Change it - # to 'BUILD_SPECIFIC_GCLOUD_PROJECT' if you want to opt in using a - # build specific Cloud project. You can also use your own string - # to use your own Cloud project. - "gcloud_project_env": "BUILD_SPECIFIC_GCLOUD_PROJECT", - # If you need to use a specific version of pip, - # change pip_version_override to the string representation - # of the version number, for example, "20.2.4" - "pip_version_override": None, - # A dictionary you want to inject into your test. Don't put any - # secrets here. These values will override predefined values. - "envs": {}, -} diff --git a/samples/quickstart_happybase/noxfile_config.py b/samples/quickstart_happybase/noxfile_config.py deleted file mode 100644 index cf88dcf8c..000000000 --- a/samples/quickstart_happybase/noxfile_config.py +++ /dev/null @@ -1,41 +0,0 @@ -# Copyright 2023 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -# Default TEST_CONFIG_OVERRIDE for python repos. - -# You can copy this file into your directory, then it will be imported from -# the noxfile.py. - -# The source of truth: -# https://github.com/GoogleCloudPlatform/python-docs-samples/blob/main/noxfile_config.py - -TEST_CONFIG_OVERRIDE = { - # You can opt out from the test for specific Python versions. - "ignored_versions": ["2.7"], - # Old samples are opted out of enforcing Python type hints - # All new samples should feature them - "enforce_type_hints": False, - # An envvar key for determining the project id to use. Change it - # to 'BUILD_SPECIFIC_GCLOUD_PROJECT' if you want to opt in using a - # build specific Cloud project. You can also use your own string - # to use your own Cloud project. - "gcloud_project_env": "BUILD_SPECIFIC_GCLOUD_PROJECT", - # If you need to use a specific version of pip, - # change pip_version_override to the string representation - # of the version number, for example, "20.2.4" - "pip_version_override": None, - # A dictionary you want to inject into your test. Don't put any - # secrets here. These values will override predefined values. - "envs": {}, -} diff --git a/samples/snippets/deletes/noxfile_config.py b/samples/snippets/deletes/noxfile_config.py deleted file mode 100644 index cf88dcf8c..000000000 --- a/samples/snippets/deletes/noxfile_config.py +++ /dev/null @@ -1,41 +0,0 @@ -# Copyright 2023 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -# Default TEST_CONFIG_OVERRIDE for python repos. - -# You can copy this file into your directory, then it will be imported from -# the noxfile.py. - -# The source of truth: -# https://github.com/GoogleCloudPlatform/python-docs-samples/blob/main/noxfile_config.py - -TEST_CONFIG_OVERRIDE = { - # You can opt out from the test for specific Python versions. - "ignored_versions": ["2.7"], - # Old samples are opted out of enforcing Python type hints - # All new samples should feature them - "enforce_type_hints": False, - # An envvar key for determining the project id to use. Change it - # to 'BUILD_SPECIFIC_GCLOUD_PROJECT' if you want to opt in using a - # build specific Cloud project. You can also use your own string - # to use your own Cloud project. - "gcloud_project_env": "BUILD_SPECIFIC_GCLOUD_PROJECT", - # If you need to use a specific version of pip, - # change pip_version_override to the string representation - # of the version number, for example, "20.2.4" - "pip_version_override": None, - # A dictionary you want to inject into your test. Don't put any - # secrets here. These values will override predefined values. - "envs": {}, -} diff --git a/samples/snippets/filters/noxfile_config.py b/samples/snippets/filters/noxfile_config.py deleted file mode 100644 index cf88dcf8c..000000000 --- a/samples/snippets/filters/noxfile_config.py +++ /dev/null @@ -1,41 +0,0 @@ -# Copyright 2023 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -# Default TEST_CONFIG_OVERRIDE for python repos. - -# You can copy this file into your directory, then it will be imported from -# the noxfile.py. - -# The source of truth: -# https://github.com/GoogleCloudPlatform/python-docs-samples/blob/main/noxfile_config.py - -TEST_CONFIG_OVERRIDE = { - # You can opt out from the test for specific Python versions. - "ignored_versions": ["2.7"], - # Old samples are opted out of enforcing Python type hints - # All new samples should feature them - "enforce_type_hints": False, - # An envvar key for determining the project id to use. Change it - # to 'BUILD_SPECIFIC_GCLOUD_PROJECT' if you want to opt in using a - # build specific Cloud project. You can also use your own string - # to use your own Cloud project. - "gcloud_project_env": "BUILD_SPECIFIC_GCLOUD_PROJECT", - # If you need to use a specific version of pip, - # change pip_version_override to the string representation - # of the version number, for example, "20.2.4" - "pip_version_override": None, - # A dictionary you want to inject into your test. Don't put any - # secrets here. These values will override predefined values. - "envs": {}, -} diff --git a/samples/hello/noxfile_config.py b/samples/snippets/noxfile_config.py similarity index 100% rename from samples/hello/noxfile_config.py rename to samples/snippets/noxfile_config.py diff --git a/samples/snippets/reads/noxfile_config.py b/samples/snippets/reads/noxfile_config.py deleted file mode 100644 index cf88dcf8c..000000000 --- a/samples/snippets/reads/noxfile_config.py +++ /dev/null @@ -1,41 +0,0 @@ -# Copyright 2023 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -# Default TEST_CONFIG_OVERRIDE for python repos. - -# You can copy this file into your directory, then it will be imported from -# the noxfile.py. - -# The source of truth: -# https://github.com/GoogleCloudPlatform/python-docs-samples/blob/main/noxfile_config.py - -TEST_CONFIG_OVERRIDE = { - # You can opt out from the test for specific Python versions. - "ignored_versions": ["2.7"], - # Old samples are opted out of enforcing Python type hints - # All new samples should feature them - "enforce_type_hints": False, - # An envvar key for determining the project id to use. Change it - # to 'BUILD_SPECIFIC_GCLOUD_PROJECT' if you want to opt in using a - # build specific Cloud project. You can also use your own string - # to use your own Cloud project. - "gcloud_project_env": "BUILD_SPECIFIC_GCLOUD_PROJECT", - # If you need to use a specific version of pip, - # change pip_version_override to the string representation - # of the version number, for example, "20.2.4" - "pip_version_override": None, - # A dictionary you want to inject into your test. Don't put any - # secrets here. These values will override predefined values. - "envs": {}, -} diff --git a/samples/snippets/writes/noxfile_config.py b/samples/snippets/writes/noxfile_config.py deleted file mode 100644 index cf88dcf8c..000000000 --- a/samples/snippets/writes/noxfile_config.py +++ /dev/null @@ -1,41 +0,0 @@ -# Copyright 2023 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -# Default TEST_CONFIG_OVERRIDE for python repos. - -# You can copy this file into your directory, then it will be imported from -# the noxfile.py. - -# The source of truth: -# https://github.com/GoogleCloudPlatform/python-docs-samples/blob/main/noxfile_config.py - -TEST_CONFIG_OVERRIDE = { - # You can opt out from the test for specific Python versions. - "ignored_versions": ["2.7"], - # Old samples are opted out of enforcing Python type hints - # All new samples should feature them - "enforce_type_hints": False, - # An envvar key for determining the project id to use. Change it - # to 'BUILD_SPECIFIC_GCLOUD_PROJECT' if you want to opt in using a - # build specific Cloud project. You can also use your own string - # to use your own Cloud project. - "gcloud_project_env": "BUILD_SPECIFIC_GCLOUD_PROJECT", - # If you need to use a specific version of pip, - # change pip_version_override to the string representation - # of the version number, for example, "20.2.4" - "pip_version_override": None, - # A dictionary you want to inject into your test. Don't put any - # secrets here. These values will override predefined values. - "envs": {}, -} diff --git a/samples/tableadmin/noxfile_config.py b/samples/tableadmin/noxfile_config.py deleted file mode 100644 index cf88dcf8c..000000000 --- a/samples/tableadmin/noxfile_config.py +++ /dev/null @@ -1,41 +0,0 @@ -# Copyright 2023 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -# Default TEST_CONFIG_OVERRIDE for python repos. - -# You can copy this file into your directory, then it will be imported from -# the noxfile.py. - -# The source of truth: -# https://github.com/GoogleCloudPlatform/python-docs-samples/blob/main/noxfile_config.py - -TEST_CONFIG_OVERRIDE = { - # You can opt out from the test for specific Python versions. - "ignored_versions": ["2.7"], - # Old samples are opted out of enforcing Python type hints - # All new samples should feature them - "enforce_type_hints": False, - # An envvar key for determining the project id to use. Change it - # to 'BUILD_SPECIFIC_GCLOUD_PROJECT' if you want to opt in using a - # build specific Cloud project. You can also use your own string - # to use your own Cloud project. - "gcloud_project_env": "BUILD_SPECIFIC_GCLOUD_PROJECT", - # If you need to use a specific version of pip, - # change pip_version_override to the string representation - # of the version number, for example, "20.2.4" - "pip_version_override": None, - # A dictionary you want to inject into your test. Don't put any - # secrets here. These values will override predefined values. - "envs": {}, -} From c206b772db5812840e7c7f982917ee563ca856aa Mon Sep 17 00:00:00 2001 From: Daniel Sanche Date: Thu, 14 Dec 2023 14:57:14 -0800 Subject: [PATCH 05/13] moved noxfile config to instanceadmin only --- samples/{snippets => instanceadmin}/noxfile_config.py | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename samples/{snippets => instanceadmin}/noxfile_config.py (100%) diff --git a/samples/snippets/noxfile_config.py b/samples/instanceadmin/noxfile_config.py similarity index 100% rename from samples/snippets/noxfile_config.py rename to samples/instanceadmin/noxfile_config.py From 6b7404a8ec29741b297b132748f5c9cd5330ded5 Mon Sep 17 00:00:00 2001 From: Daniel Sanche Date: Thu, 14 Dec 2023 14:57:30 -0800 Subject: [PATCH 06/13] added line to make sure tables are removed --- samples/hello_happybase/main.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/samples/hello_happybase/main.py b/samples/hello_happybase/main.py index 7999fd006..698541617 100644 --- a/samples/hello_happybase/main.py +++ b/samples/hello_happybase/main.py @@ -97,7 +97,12 @@ def main(project_id, instance_id, table_name): finally: connection.close() - + # make sure table is deleted + try: + table = instance.table(table_id) + table.delete() + except Exception: + pass if __name__ == "__main__": parser = argparse.ArgumentParser( From 41b5135d634e74ee61d8c0a80b38520285a17db8 Mon Sep 17 00:00:00 2001 From: Daniel Sanche Date: Thu, 14 Dec 2023 15:04:38 -0800 Subject: [PATCH 07/13] fixed sample lint --- samples/hello_happybase/main.py | 1 + 1 file changed, 1 insertion(+) diff --git a/samples/hello_happybase/main.py b/samples/hello_happybase/main.py index 698541617..60e7ec3cd 100644 --- a/samples/hello_happybase/main.py +++ b/samples/hello_happybase/main.py @@ -104,6 +104,7 @@ def main(project_id, instance_id, table_name): except Exception: pass + if __name__ == "__main__": parser = argparse.ArgumentParser( description=__doc__, formatter_class=argparse.ArgumentDefaultsHelpFormatter From 8a28e75d6886f8448b789252a41c0932a8a805df Mon Sep 17 00:00:00 2001 From: Daniel Sanche Date: Thu, 14 Dec 2023 15:14:49 -0800 Subject: [PATCH 08/13] try to use BUILD_SPECIFIC_GCLOUD_PROJECT in instance test --- samples/instanceadmin/test_instanceadmin.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/samples/instanceadmin/test_instanceadmin.py b/samples/instanceadmin/test_instanceadmin.py index b0041294b..51c5c9680 100644 --- a/samples/instanceadmin/test_instanceadmin.py +++ b/samples/instanceadmin/test_instanceadmin.py @@ -25,7 +25,7 @@ import instanceadmin -PROJECT = os.environ["GOOGLE_CLOUD_PROJECT"] +PROJECT = os.getenv('BUILD_SPECIFIC_GCLOUD_PROJECT', os.environ["GOOGLE_CLOUD_PROJECT"]) INSTANCE_ID_FORMAT = "instanceadmin-{:03}-{}" CLUSTER_ID_FORMAT = "instanceadmin-{:03}" ID_RANGE = 1000 From 717aa2847babf6780f6458c090ce2f94754e3f9e Mon Sep 17 00:00:00 2001 From: Daniel Sanche Date: Thu, 14 Dec 2023 15:35:55 -0800 Subject: [PATCH 09/13] fixed lint --- samples/hello_happybase/main.py | 2 +- samples/instanceadmin/test_instanceadmin.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/samples/hello_happybase/main.py b/samples/hello_happybase/main.py index 60e7ec3cd..ffe520abd 100644 --- a/samples/hello_happybase/main.py +++ b/samples/hello_happybase/main.py @@ -99,7 +99,7 @@ def main(project_id, instance_id, table_name): connection.close() # make sure table is deleted try: - table = instance.table(table_id) + table = instance.table(table_name) table.delete() except Exception: pass diff --git a/samples/instanceadmin/test_instanceadmin.py b/samples/instanceadmin/test_instanceadmin.py index 51c5c9680..b0041294b 100644 --- a/samples/instanceadmin/test_instanceadmin.py +++ b/samples/instanceadmin/test_instanceadmin.py @@ -25,7 +25,7 @@ import instanceadmin -PROJECT = os.getenv('BUILD_SPECIFIC_GCLOUD_PROJECT', os.environ["GOOGLE_CLOUD_PROJECT"]) +PROJECT = os.environ["GOOGLE_CLOUD_PROJECT"] INSTANCE_ID_FORMAT = "instanceadmin-{:03}-{}" CLUSTER_ID_FORMAT = "instanceadmin-{:03}" ID_RANGE = 1000 From 72fe36d55b38b8ae3b895cc8df901edf25ec07cc Mon Sep 17 00:00:00 2001 From: Daniel Sanche Date: Thu, 14 Dec 2023 15:40:28 -0800 Subject: [PATCH 10/13] added print statements --- samples/instanceadmin/instanceadmin.py | 1 + 1 file changed, 1 insertion(+) diff --git a/samples/instanceadmin/instanceadmin.py b/samples/instanceadmin/instanceadmin.py index 7341bfc46..9afd82039 100644 --- a/samples/instanceadmin/instanceadmin.py +++ b/samples/instanceadmin/instanceadmin.py @@ -48,6 +48,7 @@ def run_instance_operations(project_id, instance_id, cluster_id): :type instance_id: str :param instance_id: Instance of the client. """ + print(f"Running instance operations on {project_id} and {instance_id}") client = bigtable.Client(project=project_id, admin=True) location_id = "us-central1-f" serve_nodes = 1 From 7a031fcc42f50f1b0d7a3e18a5454001de79f122 Mon Sep 17 00:00:00 2001 From: Daniel Sanche Date: Thu, 14 Dec 2023 15:44:08 -0800 Subject: [PATCH 11/13] added preclean to metricscaler --- samples/metricscaler/metricscaler_test.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/samples/metricscaler/metricscaler_test.py b/samples/metricscaler/metricscaler_test.py index 47be38187..d5e09e305 100644 --- a/samples/metricscaler/metricscaler_test.py +++ b/samples/metricscaler/metricscaler_test.py @@ -39,6 +39,27 @@ BIGTABLE_DEV_INSTANCE = INSTANCE_ID_FORMAT.format(str(uuid.uuid4())[:10]) +@pytest.fixture(scope="module", autouse=True) +def preclean(): + """In case any test instances weren't cleared out in a previous run. + + Deletes any test instances that were created over an hour ago. Newer instances may + be being used by a concurrent test run. + """ + import time + import warnings + prefix = INSTANCE_ID_FORMAT.format("") + client = bigtable.Client(project=PROJECT, admin=True) + for instance in client.list_instances()[0]: + if instance.instance_id.startswith(prefix): + timestamp = instance.instance_id.split("-")[-1] + timestamp = int(timestamp) + if time.time() - timestamp > 3600: + warnings.warn( + f"Deleting leftover test instance: {instance.instance_id}" + ) + instance.delete() + # System tests to verify API calls succeed From ab34f99b2078844d20973d2bb183e937a4d3269e Mon Sep 17 00:00:00 2001 From: Daniel Sanche Date: Thu, 14 Dec 2023 16:19:28 -0800 Subject: [PATCH 12/13] changed to instance name --- samples/metricscaler/metricscaler_test.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/samples/metricscaler/metricscaler_test.py b/samples/metricscaler/metricscaler_test.py index d5e09e305..fb51f3b1f 100644 --- a/samples/metricscaler/metricscaler_test.py +++ b/samples/metricscaler/metricscaler_test.py @@ -56,7 +56,7 @@ def preclean(): timestamp = int(timestamp) if time.time() - timestamp > 3600: warnings.warn( - f"Deleting leftover test instance: {instance.instance_id}" + f"Deleting leftover test instance: {instance.name}" ) instance.delete() From 26bc30b10be430d4cf0682eeb6a3b6f7276c278b Mon Sep 17 00:00:00 2001 From: Daniel Sanche Date: Thu, 14 Dec 2023 16:20:33 -0800 Subject: [PATCH 13/13] removed extra backoff --- samples/instanceadmin/test_instanceadmin.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/samples/instanceadmin/test_instanceadmin.py b/samples/instanceadmin/test_instanceadmin.py index b0041294b..017961dfa 100644 --- a/samples/instanceadmin/test_instanceadmin.py +++ b/samples/instanceadmin/test_instanceadmin.py @@ -99,7 +99,6 @@ def test_run_instance_operations(capsys, dispose_of): def test_delete_instance(capsys, dispose_of): from concurrent.futures import TimeoutError - @backoff.on_exception(backoff.expo, TimeoutError) def _set_up_instance(): dispose_of(INSTANCE) @@ -125,7 +124,6 @@ def _set_up_instance(): def test_add_and_delete_cluster(capsys, dispose_of): from concurrent.futures import TimeoutError - @backoff.on_exception(backoff.expo, TimeoutError) def _set_up_instance(): dispose_of(INSTANCE)