Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[kms] fix: use unique ids for test #3563

Merged
merged 1 commit into from
Apr 28, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions kms/api-client/snippets_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

import time
from os import environ
import uuid

from google.api_core.exceptions import Aborted, GoogleAPICallError
from google.cloud import kms_v1
Expand Down Expand Up @@ -63,7 +64,7 @@ def setup_module(module):

class TestKMSSnippets:
project_id = environ['GCLOUD_PROJECT']
keyring_id = 'kms-samples'
keyring_id = 'kms-samples-{}'.format(uuid.uuid4().hex)
location = 'global'
parent = 'projects/{}/locations/{}'.format(project_id, location)
keyring_path = '{}/keyRings/{}'.format(parent, keyring_id)
Expand All @@ -83,7 +84,7 @@ class TestKMSSnippets:
@pytest.mark.skip(reason="There's currently no method to delete keyrings, \
so we should avoid creating resources")
def test_create_key_ring(self):
ring_id = self.keyring_id + '-testcreate' + str(int(time.time()))
ring_id = self.keyring_id + '-test-create-{}'.format(uuid.uuid4().hex)
snippets.create_key_ring(self.project_id, self.location, ring_id)
client = kms_v1.KeyManagementServiceClient()
result = client.get_key_ring(client.key_ring_path(self.project_id,
Expand All @@ -94,7 +95,7 @@ def test_create_key_ring(self):
@pytest.mark.skip(reason="Deleting keys isn't instant, so we should avoid \
creating a large number of them in our tests")
def test_create_crypto_key(self):
key_id = self.sym_id + '-test' + str(int(time.time()))
key_id = self.sym_id + '-test-{}'.format(uuid.uuid4().hex)
snippets.create_crypto_key(self.project_id, self.location,
self.keyring_id, key_id)
c = kms_v1.KeyManagementServiceClient()
Expand Down