You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@beam.apache.org by yh...@apache.org on 2023/11/02 19:13:47 UTC
(beam) 01/01: Setup Bigtable instance cleaner
This is an automated email from the ASF dual-hosted git repository.
yhu pushed a commit to branch setupcbtcleanser
in repository https://gitbox.apache.org/repos/asf/beam.git
commit 29c0008172ef768f7b7632905ddf5d01f7a4d34d
Author: Yi Hu <ya...@google.com>
AuthorDate: Thu Nov 2 15:09:24 2023 -0400
Setup Bigtable instance cleaner
---
sdks/python/apache_beam/io/gcp/bigtableio_it_test.py | 14 +++++++++-----
1 file changed, 9 insertions(+), 5 deletions(-)
diff --git a/sdks/python/apache_beam/io/gcp/bigtableio_it_test.py b/sdks/python/apache_beam/io/gcp/bigtableio_it_test.py
index fdf049bba94..867dca9a5e7 100644
--- a/sdks/python/apache_beam/io/gcp/bigtableio_it_test.py
+++ b/sdks/python/apache_beam/io/gcp/bigtableio_it_test.py
@@ -49,6 +49,13 @@ except ImportError as e:
HttpError = None
+def instance_prefix(instance):
+ datestr = "".join(filter(str.isdigit, str(datetime.utcnow().date())))
+ instance_id = '%s-%s-%s' % (instance, datestr, secrets.token_hex(4))
+ assert len(instance_id) < 34, "instance id length needs to be within [6, 33]"
+ return instance_id
+
+
@pytest.mark.uses_gcp_java_expansion_service
@pytest.mark.uses_transform_service
@unittest.skipUnless(
@@ -65,8 +72,7 @@ class TestReadFromBigTableIT(unittest.TestCase):
self.project = self.test_pipeline.get_option('project')
self.expansion_service = ('localhost:%s' % os.environ.get('EXPANSION_PORT'))
- instance_id = '%s-%s-%s' % (
- self.INSTANCE, str(int(time.time())), secrets.token_hex(3))
+ instance_id = instance_prefix(self.INSTANCE)
self.client = client.Client(admin=True, project=self.project)
# create cluster and instance
@@ -160,9 +166,7 @@ class TestWriteToBigtableXlangIT(unittest.TestCase):
cls.args = cls.test_pipeline.get_full_options_as_args()
cls.expansion_service = ('localhost:%s' % os.environ.get('EXPANSION_PORT'))
- timestr = "".join(filter(str.isdigit, str(datetime.utcnow().date())))
- # instance id length needs to be within [6, 33]
- instance_id = '%s-%s-%s' % (cls.INSTANCE, timestr, secrets.token_hex(4))
+ instance_id = instance_prefix(cls.INSTANCE)
cls.client = client.Client(admin=True, project=cls.project)
# create cluster and instance