Skip to content

Commit

Permalink
Prevent Key Vault test failure due to operation timing (#11552)
Browse files Browse the repository at this point in the history
  • Loading branch information
chlowell authored May 20, 2020
1 parent 197c0c5 commit 1ff8249
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -208,13 +208,15 @@ def test_crud_operations(self, client, **kwargs):
cert = client.get_certificate(certificate_name=cert_name)
self._validate_certificate_bundle(cert=cert, cert_name=cert_name, cert_policy=cert_policy)

# update certificate
# update certificate, ensuring the new updated_on value is at least one second later than the original
if self.is_live:
time.sleep(1)
tags = {"tag1": "updated_value1"}
cert_bundle = client.update_certificate_properties(cert_name, tags=tags)
self._validate_certificate_bundle(cert=cert_bundle, cert_name=cert_name, cert_policy=cert_policy)
self.assertEqual(tags, cert_bundle.properties.tags)
self.assertEqual(cert.id, cert_bundle.id)
self.assertNotEqual(cert.properties.updated_on, cert_bundle.properties.updated_on)
updated_cert = client.update_certificate_properties(cert_name, tags=tags)
self._validate_certificate_bundle(cert=updated_cert, cert_name=cert_name, cert_policy=cert_policy)
self.assertEqual(tags, updated_cert.properties.tags)
self.assertEqual(cert.id, updated_cert.id)
self.assertNotEqual(cert.properties.updated_on, updated_cert.properties.updated_on)

# delete certificate
delete_cert_poller = client.begin_delete_certificate(cert_name)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -205,13 +205,15 @@ async def test_crud_operations(self, client, **kwargs):
cert = await client.get_certificate(certificate_name=cert_name)
self._validate_certificate_bundle(cert=cert, cert_name=cert_name, cert_policy=cert_policy)

# update certificate
# update certificate, ensuring the new updated_on value is at least one second later than the original
if self.is_live:
await asyncio.sleep(1)
tags = {"tag1": "updated_value1"}
cert_bundle = await client.update_certificate_properties(cert_name, tags=tags)
self._validate_certificate_bundle(cert=cert_bundle, cert_name=cert_name, cert_policy=cert_policy)
self.assertEqual(tags, cert_bundle.properties.tags)
self.assertEqual(cert.id, cert_bundle.id)
self.assertNotEqual(cert.properties.updated_on, cert_bundle.properties.updated_on)
updated_cert = await client.update_certificate_properties(cert_name, tags=tags)
self._validate_certificate_bundle(cert=updated_cert, cert_name=cert_name, cert_policy=cert_policy)
self.assertEqual(tags, updated_cert.properties.tags)
self.assertEqual(cert.id, updated_cert.id)
self.assertNotEqual(cert.properties.updated_on, updated_cert.properties.updated_on)

# delete certificate
deleted_cert_bundle = await client.delete_certificate(certificate_name=cert_name)
Expand Down

0 comments on commit 1ff8249

Please sign in to comment.