Skip to content

Commit 11cb13c

Browse files
Takashi Matsuorsamborski
Takashi Matsuo
authored andcommitted
[kms] fix: use unique ids for test [(#3563)](#3563)
fixes #3554 fixes #3555
1 parent 92666ae commit 11cb13c

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

kms/snippets/snippets_test.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515

1616
import time
1717
from os import environ
18+
import uuid
1819

1920
from google.api_core.exceptions import Aborted, GoogleAPICallError
2021
from google.cloud import kms_v1
@@ -63,7 +64,7 @@ def setup_module(module):
6364

6465
class TestKMSSnippets:
6566
project_id = environ['GCLOUD_PROJECT']
66-
keyring_id = 'kms-samples'
67+
keyring_id = 'kms-samples-{}'.format(uuid.uuid4().hex)
6768
location = 'global'
6869
parent = 'projects/{}/locations/{}'.format(project_id, location)
6970
keyring_path = '{}/keyRings/{}'.format(parent, keyring_id)
@@ -83,7 +84,7 @@ class TestKMSSnippets:
8384
@pytest.mark.skip(reason="There's currently no method to delete keyrings, \
8485
so we should avoid creating resources")
8586
def test_create_key_ring(self):
86-
ring_id = self.keyring_id + '-testcreate' + str(int(time.time()))
87+
ring_id = self.keyring_id + '-test-create-{}'.format(uuid.uuid4().hex)
8788
snippets.create_key_ring(self.project_id, self.location, ring_id)
8889
client = kms_v1.KeyManagementServiceClient()
8990
result = client.get_key_ring(client.key_ring_path(self.project_id,
@@ -94,7 +95,7 @@ def test_create_key_ring(self):
9495
@pytest.mark.skip(reason="Deleting keys isn't instant, so we should avoid \
9596
creating a large number of them in our tests")
9697
def test_create_crypto_key(self):
97-
key_id = self.sym_id + '-test' + str(int(time.time()))
98+
key_id = self.sym_id + '-test-{}'.format(uuid.uuid4().hex)
9899
snippets.create_crypto_key(self.project_id, self.location,
99100
self.keyring_id, key_id)
100101
c = kms_v1.KeyManagementServiceClient()

0 commit comments

Comments
 (0)