Skip to content

Commit 115e057

Browse files
Fixed test_disk_resize_clone_and_create failure (#866)
1 parent 88d9f54 commit 115e057

2 files changed

Lines changed: 60 additions & 12 deletions

File tree

tests/integration/linodes/fixtures.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,9 @@ def linode_instance_disk_tests(linode_cloud_firewall):
259259
)
260260

261261
retry_exec_test_command_with_delay(
262-
BASE_CMDS["linodes"] + ["shutdown", linode_id]
262+
BASE_CMDS["linodes"] + ["shutdown", linode_id],
263+
retries=10,
264+
delay=15,
263265
)
264266

265267
wait_until(linode_id=linode_id, timeout=240, status="offline")

tests/integration/linodes/test_disk.py

Lines changed: 57 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import json
2+
13
from tests.integration.helpers import (
24
BASE_CMDS,
35
assert_headers_in_lines,
@@ -14,10 +16,51 @@
1416
)
1517

1618

19+
def _get_smallest_disk_id(linode_id):
20+
"""Return the disk ID of the smallest disk (e.g. swap) on the Linode."""
21+
disks_json = exec_test_command(
22+
BASE_CMDS["linodes"]
23+
+ [
24+
"disks-list",
25+
linode_id,
26+
"--json",
27+
]
28+
)
29+
disks = json.loads(disks_json)
30+
smallest = min(disks, key=lambda d: d["size"])
31+
return str(smallest["id"])
32+
33+
1734
def test_disk_resize_clone_and_create(linode_instance_disk_tests):
1835
linode_id = linode_instance_disk_tests
1936

20-
disk_id = get_disk_ids(linode_id=linode_id)[0]
37+
# Ensure disks are available
38+
def disks_ready():
39+
return len(get_disk_ids(linode_id=linode_id)) >= 2
40+
41+
wait_for_condition(10, 120, disks_ready)
42+
43+
# Use the smallest disk (swap) for resize/clone — the main OS disk
44+
# is too large to shrink to 50 MB because it contains filesystem data.
45+
disk_id = _get_smallest_disk_id(linode_id)
46+
47+
def disk_poll_func():
48+
status = exec_test_command(
49+
BASE_CMDS["linodes"]
50+
+ [
51+
"disk-view",
52+
linode_id,
53+
disk_id,
54+
"--text",
55+
"--no-headers",
56+
"--format=status",
57+
]
58+
)
59+
60+
return status.strip() == "ready"
61+
62+
# Make sure the disk is ready before resizing
63+
wait_for_condition(15, 300, disk_poll_func)
2164

2265
# resize disk
2366
retry_exec_test_command_with_delay(
@@ -29,27 +72,30 @@ def test_disk_resize_clone_and_create(linode_instance_disk_tests):
2972
"--size",
3073
"50",
3174
],
32-
retries=3,
33-
delay=10,
75+
retries=10,
76+
delay=15,
3477
)
3578

36-
def disk_poll_func():
37-
status = exec_test_command(
79+
# Wait for the disk to be ready after resize
80+
wait_for_condition(15, 300, disk_poll_func)
81+
82+
def disk_size_poll_func():
83+
size = exec_test_command(
3884
BASE_CMDS["linodes"]
3985
+ [
4086
"disk-view",
4187
linode_id,
4288
disk_id,
4389
"--text",
4490
"--no-headers",
45-
"--format=status",
91+
"--format=size",
4692
]
4793
)
4894

49-
return status == "ready"
95+
return size.strip() == "50"
5096

51-
# Wait for the instance to be ready
52-
wait_for_condition(15, 150, disk_poll_func)
97+
# Verify the resize actually took effect
98+
wait_for_condition(15, 300, disk_size_poll_func)
5399

54100
# clone disk
55101
res = retry_exec_test_command_with_delay(
@@ -60,8 +106,8 @@ def disk_poll_func():
60106
disk_id,
61107
"--text",
62108
],
63-
retries=3,
64-
delay=10,
109+
retries=10,
110+
delay=15,
65111
)
66112

67113
headers = ["id", "label", "status", "size", "filesystem", "disk_encryption"]

0 commit comments

Comments
 (0)