Skip to content

Commit 4279a94

Browse files
committed
Add some updates according to the comments of Copilot
1 parent ff7b2fe commit 4279a94

File tree

1 file changed

+19
-9
lines changed

1 file changed

+19
-9
lines changed

lisa/microsoft/testsuites/vm_extensions/generic_vm_extension.py

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
from lisa import (
77
Logger,
88
Node,
9+
SkippedException,
910
TestCaseMetadata,
1011
TestSuite,
1112
TestSuiteMetadata,
@@ -44,9 +45,18 @@ def verify_vm_extension_install_uninstall(
4445
node: Node,
4546
variables: Dict[str, Any],
4647
) -> None:
47-
publisher: str = variables["extension_publisher"]
48-
type_: str = variables["extension_type"]
49-
version: str = variables["extension_version"]
48+
publisher: str = variables.get("extension_publisher", "")
49+
type_: str = variables.get("extension_type", "")
50+
version: str = variables.get("extension_version", "")
51+
52+
if not publisher or not type_ or not version:
53+
raise SkippedException(
54+
"Required runbook variable(s) are missing or empty: "
55+
f"extension_publisher='{publisher}', "
56+
f"extension_type='{type_}', "
57+
f"extension_version='{version}'. "
58+
"Please set them in the runbook before running this test case."
59+
)
5060

5161
extension = node.features[AzureExtension]
5262
extension_name = f"{publisher}.{type_}-{version}"
@@ -61,29 +71,29 @@ def verify_vm_extension_install_uninstall(
6171
)
6272

6373
assert_that(extension_result["provisioning_state"]).described_as(
64-
"Found the extension provisioning state unexpectedly not Succeeded"
74+
"Expected extension provisioning state to be Succeeded"
6575
).is_equal_to("Succeeded")
6676

6777
assert_that(self._check_exist(extension, extension_name)).described_as(
68-
"Found the VM Extension unexpectedly not exists on the VM after"
69-
"installation"
78+
"Expected VM extension to exist after installation"
7079
).is_true()
7180

7281
# Verify the VM is still reachable after extension operations.
7382
assert_that(node.test_connection()).described_as(
74-
"Found the VM unexpectedly not reachable via SSH after extension install"
83+
"Expected VM to be reachable via SSH after extension installation"
7584
).is_true()
7685

7786
# if extension installed by test then delete the extension
7887
self._delete_extension(extension, extension_name)
7988

8089
assert_that(self._check_exist(extension, extension_name)).described_as(
81-
"Found the VM Extension still unexpectedly exists on the VM after deletion"
90+
"Expected VM extension to be removed after deletion"
8291
).is_false()
8392

8493
# Verify the VM is still reachable after extension operations.
8594
assert_that(node.test_connection()).described_as(
86-
"Found the VM unexpectedly not reachable via SSH after extension uninstall"
95+
"Expected VM to be reachable via SSH after extension"
96+
"uninstallation"
8797
).is_true()
8898

8999
@retry(tries=3, delay=10) # type: ignore

0 commit comments

Comments
 (0)