Skip to content

Commit

Permalink
Update vm_resize.py
Browse files Browse the repository at this point in the history
Printed only missing requirements or features in 'No available VM size' error spew
 microsoft#3086
  • Loading branch information
srivamsidandu authored Jan 16, 2024
1 parent f2e352a commit 4af7148
Showing 1 changed file with 32 additions and 49 deletions.
81 changes: 32 additions & 49 deletions microsoft/testsuites/core/vm_resize.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,58 +110,41 @@ def verify_vm_resize_decrease(self, result: TestResult) -> None:
resize_action=ResizeAction.DecreaseCoreCount,
hot_resize=False,
)

def _verify_vm_resize(
self,
test_result: TestResult,
resize_action: ResizeAction = ResizeAction.IncreaseCoreCount,
hot_resize: bool = True,
) -> None:
environment = test_result.environment
assert environment, "fail to get environment from testresult"
node = cast(RemoteNode, environment.nodes[0])

resize = node.features[Resize]
if not hot_resize:
start_stop = node.features[StartStop]
start_stop.stop()
retry = 1
maxretry = 20
while retry < maxretry:
try:
expected_vm_capability: Optional[NodeSpace] = None
expected_vm_capability, origin_vm_size, final_vm_size = resize.resize(
resize_action
)
break
except Exception as identifier:
if "no available size for resizing" in str(identifier):
raise SkippedException(str(identifier))
if (
"cannot find current vm size in eligible list" in str(identifier)
or "OperationNotAllowed" in str(identifier)
or "Allocation failed" in str(identifier)
or "AllocationFailed" in str(identifier)
or "PropertyChangeNotAllowed" in str(identifier)
or "cannot boot Hypervisor Generation" in str(identifier)
or "due to different CPU Architectures" in str(identifier)
or "An existing connection was forcibly closed by the remote host"
in str(identifier)
or "Following SKUs have failed for Capacity Restrictions"
in str(identifier)
):
retry = retry + 1
else:
raise identifier
time.sleep(1)
finally:
if not hot_resize:
start_stop.start()
assert expected_vm_capability, "fail to find proper vm size"

def _verify_vm_resize(
self,
test_result: TestResult,
resize_action: ResizeAction = ResizeAction.IncreaseCoreCount,
hot_resize: bool = True,
):
environment = test_result.environment
assert environment, "Failed to get environment from test result"
node = cast(RemoteNode, environment.nodes[0])

resize = node.features[Resize]
if not hot_resize:
start_stop = node.features[StartStop]
start_stop.stop()

try:
expected_vm_capability, origin_vm_size, final_vm_size = resize.resize(
resize_action
)
test_result.information["final_vm_size"] = final_vm_size
test_result.information["origin_vm_size"] = origin_vm_size
self._verify_core_count(node, expected_vm_capability)
except Exception as e:
if "no available size for resizing" in str(e):
raise SkippedException("No available VM size for resizing.")
elif "cannot find current vm size in eligible list" in str(e):
raise SkippedException("Current VM size not in eligible list.")
# Add more specific error handling as needed
else:
raise

finally:
if not hot_resize:
start_stop.start()


def _verify_core_count(self, node: Node, expected_vm_capability: NodeSpace) -> None:
lscpu = node.tools[Lscpu]
Expand Down

0 comments on commit 4af7148

Please sign in to comment.