From bcaf992e4f4f58fd97f02e57a7f4a6a1a440ff39 Mon Sep 17 00:00:00 2001 From: Maddie Ford Date: Wed, 31 Jan 2024 17:19:42 -0800 Subject: [PATCH 1/2] Retry get instance view if incomplete during assertions --- tests_e2e/tests/lib/virtual_machine_extension_client.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/tests_e2e/tests/lib/virtual_machine_extension_client.py b/tests_e2e/tests/lib/virtual_machine_extension_client.py index d54f881d05..00be102286 100644 --- a/tests_e2e/tests/lib/virtual_machine_extension_client.py +++ b/tests_e2e/tests/lib/virtual_machine_extension_client.py @@ -134,7 +134,14 @@ def assert_instance_view( If 'assert_function' is provided, it is invoked passing as parameter the instance view. This function can be used to perform additional validations. """ + # Sometimes we get incomplete instance view with only 'name' property which causes issues during assertions. + # Retry attempt to get instance view if only 'name' property is populated. + attempt = 1 instance_view = self.get_instance_view() + while instance_view.name is not None and instance_view.type_handler_version is None and instance_view.statuses is None and attempt < 3: + log.info("Instance view is incomplete: %s\nRetrying attempt to get instance view...", instance_view.serialize()) + instance_view = self.get_instance_view() + attempt += 1 log.info("Instance view:\n%s", instance_view.serialize()) with soft_assertions(): From 99c9963c1dc38690bb3f460ba30879cb03b762b7 Mon Sep 17 00:00:00 2001 From: Maddie Ford Date: Fri, 2 Feb 2024 17:22:40 -0800 Subject: [PATCH 2/2] Retry getting instance view if only name property is present --- tests_e2e/tests/lib/virtual_machine_extension_client.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests_e2e/tests/lib/virtual_machine_extension_client.py b/tests_e2e/tests/lib/virtual_machine_extension_client.py index 00be102286..d1f3e61a15 100644 --- a/tests_e2e/tests/lib/virtual_machine_extension_client.py +++ b/tests_e2e/tests/lib/virtual_machine_extension_client.py @@ -18,7 +18,7 @@ # # This module includes facilities to execute VM extension operations (enable, remove, etc). # - +import json import uuid from assertpy import assert_that, soft_assertions @@ -142,7 +142,7 @@ def assert_instance_view( log.info("Instance view is incomplete: %s\nRetrying attempt to get instance view...", instance_view.serialize()) instance_view = self.get_instance_view() attempt += 1 - log.info("Instance view:\n%s", instance_view.serialize()) + log.info("Instance view:\n%s", json.dumps(instance_view.serialize(), indent=4)) with soft_assertions(): if expected_version is not None: