diff --git a/microsoft/testsuites/vm_extensions/runtime_extensions/run_commandv1.py b/microsoft/testsuites/vm_extensions/runtime_extensions/run_commandv1.py index 925a8313ac..593bd423b7 100644 --- a/microsoft/testsuites/vm_extensions/runtime_extensions/run_commandv1.py +++ b/microsoft/testsuites/vm_extensions/runtime_extensions/run_commandv1.py @@ -9,6 +9,7 @@ from azure.core.exceptions import HttpResponseError from lisa import ( + LisaException, Logger, Node, TestCaseMetadata, @@ -37,10 +38,22 @@ def _create_and_verify_extension_run( assert_exception: Optional[Any] = None, ) -> None: extension = node.features[AzureExtension] + extension_name = "RunCommandv1" + try: + # Delete VM Extension if already present + extension.delete(extension_name) + except HttpResponseError as identifier: + if any(s in str(identifier) for s in ["was not found"]): + node.log.info(f"{extension_name} is not installed") + else: + raise LisaException( + f"unexpected exception happened {identifier} during delete" + f" extension {extension_name}" + ) from identifier def enable_extension() -> Any: result = extension.create_or_update( - name="RunCommandv1", + name=extension_name, publisher="Microsoft.CPlat.Core", type_="RunCommandLinux", type_handler_version="1.0",