From 2e4b7fc2505814f06676d4fcad5e7f20aa057b32 Mon Sep 17 00:00:00 2001 From: Ernest Hill Date: Mon, 25 Nov 2024 15:33:33 +0300 Subject: [PATCH 1/2] Add method to wait for custom metadata type def to complete --- tests/integration/custom_metadata_test.py | 9 +++++---- tests/integration/data_mesh_test.py | 4 ++-- tests/integration/utils.py | 11 ++++++++++- 3 files changed, 17 insertions(+), 7 deletions(-) diff --git a/tests/integration/custom_metadata_test.py b/tests/integration/custom_metadata_test.py index 0b2084879..0aefb88ee 100644 --- a/tests/integration/custom_metadata_test.py +++ b/tests/integration/custom_metadata_test.py @@ -33,6 +33,7 @@ from tests.integration.admin_test import create_group, delete_group from tests.integration.client import TestId, delete_asset from tests.integration.glossary_test import create_glossary, create_term +from tests.integration.utils import wait_for_successful_custometadatadef_purge MODULE_NAME = TestId.make_unique("CM") @@ -162,7 +163,7 @@ def cm_ipr( client, name=CM_IPR, attribute_defs=attribute_defs, logo="⚖️", locked=True ) yield cm - client.typedef.purge(CM_IPR, CustomMetadataDef) + wait_for_successful_custometadatadef_purge(CM_IPR, client=client) def test_cm_ipr(cm_ipr: CustomMetadataDef, limit_attribute_applicability_kwargs): @@ -254,7 +255,7 @@ def cm_raci( locked=False, ) yield cm - client.typedef.purge(CM_RACI, CustomMetadataDef) + wait_for_successful_custometadatadef_purge(CM_RACI, client=client) def test_cm_raci( @@ -309,7 +310,7 @@ def cm_enum( ) -> Generator[EnumDef, None, None]: enum_def = create_enum(client, name=DQ_ENUM, values=DQ_TYPE_LIST) yield enum_def - client.typedef.purge(DQ_ENUM, EnumDef) + wait_for_successful_custometadatadef_purge(DQ_ENUM, client=client) def test_cm_enum( @@ -402,7 +403,7 @@ def cm_dq( locked=True, ) yield cm - client.typedef.purge(CM_QUALITY, CustomMetadataDef) + wait_for_successful_custometadatadef_purge(CM_QUALITY, client=client) def test_cm_dq( diff --git a/tests/integration/data_mesh_test.py b/tests/integration/data_mesh_test.py index 2fdcf5eec..268e836c0 100644 --- a/tests/integration/data_mesh_test.py +++ b/tests/integration/data_mesh_test.py @@ -29,7 +29,7 @@ from pyatlan.model.typedef import AttributeDef, CustomMetadataDef from tests.integration.client import TestId, delete_asset from tests.integration.custom_metadata_test import create_custom_metadata -from tests.integration.utils import block +from tests.integration.utils import block, wait_for_successful_custometadatadef_purge DATA_PRODUCT_ASSETS_PLAYBOOK_FILTER = ( '{"condition":"AND","isGroupLocked":false,"rules":[]}' @@ -230,7 +230,7 @@ def data_domain_cm( client, name=DD_CM, attribute_defs=attribute_defs, logo="📦", locked=True ) yield dd_cm - client.typedef.purge(DD_CM, CustomMetadataDef) + wait_for_successful_custometadatadef_purge(DD_CM, client=client) def test_data_domain_cm(data_domain_cm: CustomMetadataDef): diff --git a/tests/integration/utils.py b/tests/integration/utils.py index 5ed6f6c3b..12f208655 100644 --- a/tests/integration/utils.py +++ b/tests/integration/utils.py @@ -13,7 +13,7 @@ from pyatlan.model.assets import Asset from pyatlan.model.enums import EntityStatus from pyatlan.model.response import AssetMutationResponse -from pyatlan.model.typedef import AtlanTagDef +from pyatlan.model.typedef import AtlanTagDef, CustomMetadataDef def block( @@ -56,3 +56,12 @@ def retrieve_and_check_assets( ) def wait_for_successful_tagdef_purge(name: str, client: AtlanClient): client.typedef.purge(name, typedef_type=AtlanTagDef) + + +@retry( + retry=retry_if_exception_type(AtlanError), + wait=wait_random_exponential(multiplier=1, max=5), + stop=stop_after_attempt(3), +) +def wait_for_successful_custometadatadef_purge(name: str, client: AtlanClient): + client.typedef.purge(name, typedef_type=CustomMetadataDef) From 8f44bb9acc72657e3b45b75a9dfdd8ade416ec44 Mon Sep 17 00:00:00 2001 From: Ernest Hill Date: Mon, 25 Nov 2024 16:29:44 +0300 Subject: [PATCH 2/2] Fix failing test. --- tests/integration/custom_metadata_test.py | 7 +++++-- tests/integration/utils.py | 11 ++++++++++- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/tests/integration/custom_metadata_test.py b/tests/integration/custom_metadata_test.py index 0aefb88ee..cfe91d255 100644 --- a/tests/integration/custom_metadata_test.py +++ b/tests/integration/custom_metadata_test.py @@ -33,7 +33,10 @@ from tests.integration.admin_test import create_group, delete_group from tests.integration.client import TestId, delete_asset from tests.integration.glossary_test import create_glossary, create_term -from tests.integration.utils import wait_for_successful_custometadatadef_purge +from tests.integration.utils import ( + wait_for_successful_custometadatadef_purge, + wait_for_successful_enumadef_purge, +) MODULE_NAME = TestId.make_unique("CM") @@ -310,7 +313,7 @@ def cm_enum( ) -> Generator[EnumDef, None, None]: enum_def = create_enum(client, name=DQ_ENUM, values=DQ_TYPE_LIST) yield enum_def - wait_for_successful_custometadatadef_purge(DQ_ENUM, client=client) + wait_for_successful_enumadef_purge(DQ_ENUM, client=client) def test_cm_enum( diff --git a/tests/integration/utils.py b/tests/integration/utils.py index 12f208655..1780403b6 100644 --- a/tests/integration/utils.py +++ b/tests/integration/utils.py @@ -13,7 +13,7 @@ from pyatlan.model.assets import Asset from pyatlan.model.enums import EntityStatus from pyatlan.model.response import AssetMutationResponse -from pyatlan.model.typedef import AtlanTagDef, CustomMetadataDef +from pyatlan.model.typedef import AtlanTagDef, CustomMetadataDef, EnumDef def block( @@ -65,3 +65,12 @@ def wait_for_successful_tagdef_purge(name: str, client: AtlanClient): ) def wait_for_successful_custometadatadef_purge(name: str, client: AtlanClient): client.typedef.purge(name, typedef_type=CustomMetadataDef) + + +@retry( + retry=retry_if_exception_type(AtlanError), + wait=wait_random_exponential(multiplier=1, max=5), + stop=stop_after_attempt(3), +) +def wait_for_successful_enumadef_purge(name: str, client: AtlanClient): + client.typedef.purge(name, typedef_type=EnumDef)