Skip to content

Commit 049d772

Browse files
authored
Regression fixes (#856)
1 parent 20af396 commit 049d772

8 files changed

Lines changed: 117 additions & 5 deletions

File tree

tests/integration/conftest.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,12 @@
1818

1919
from linodecli import ENV_TOKEN_NAME
2020
from tests.integration.helpers import (
21+
check_attribute_value,
2122
delete_target_id,
2223
exec_test_command,
2324
get_random_region_with_caps,
2425
get_random_text,
26+
wait_for_condition,
2527
)
2628

2729

@@ -96,6 +98,17 @@ def create_inbound_rule(ipv4_address, ipv6_address):
9698
command.extend(["--rules.inbound", inbound_rule])
9799

98100
firewall_id = exec_test_command(command)
101+
# Verify firewall status is reachable before proceeding with tests
102+
wait_for_condition(
103+
5,
104+
60,
105+
check_attribute_value,
106+
"firewalls",
107+
"view",
108+
firewall_id,
109+
"status",
110+
"enabled",
111+
)
99112

100113
yield firewall_id
101114

tests/integration/domains/fixtures.py

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,11 @@
22

33
from tests.integration.helpers import (
44
BASE_CMDS,
5+
check_attribute_value,
56
delete_target_id,
67
exec_test_command,
78
get_random_text,
9+
wait_for_condition,
810
)
911

1012

@@ -27,6 +29,18 @@ def master_domain():
2729
]
2830
)
2931

32+
# Verify domain status becomes active before proceeding with tests
33+
wait_for_condition(
34+
5,
35+
60,
36+
check_attribute_value,
37+
"domains",
38+
"view",
39+
domain_id,
40+
"status",
41+
"active",
42+
)
43+
3044
yield domain_id
3145

3246
delete_target_id("domains", id=domain_id)
@@ -52,6 +66,18 @@ def slave_domain():
5266
]
5367
)
5468

69+
# Verify domain status becomes active before proceeding with tests
70+
wait_for_condition(
71+
5,
72+
60,
73+
check_attribute_value,
74+
"domains",
75+
"view",
76+
domain_id,
77+
"status",
78+
"active",
79+
)
80+
5581
yield domain_id
5682

5783
delete_target_id("domains", domain_id)
@@ -75,6 +101,18 @@ def domain_and_record():
75101
]
76102
)
77103

104+
# Verify domain status becomes active before proceeding with tests
105+
wait_for_condition(
106+
5,
107+
60,
108+
check_attribute_value,
109+
"domains",
110+
"view",
111+
domain_id,
112+
"status",
113+
"active",
114+
)
115+
78116
# Create record
79117
record_id = exec_test_command(
80118
BASE_CMDS["domains"]

tests/integration/domains/test_domain_records.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
from tests.integration.helpers import (
1212
BASE_CMDS,
1313
contains_at_least_one_of,
14+
delete_target_id,
1415
exec_test_command,
1516
)
1617

@@ -53,6 +54,9 @@ def test_create_a_domain(master_domain):
5354
)
5455
assert another_domain in domain_list_after
5556

57+
# clean-up
58+
delete_target_id("domains", id=another_domain)
59+
5660

5761
@pytest.mark.smoke
5862
def test_create_domain_srv_record(domain_and_record):

tests/integration/events/fixtures.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,11 @@
22

33
from tests.integration.helpers import (
44
BASE_CMDS,
5+
check_attribute_value,
56
delete_target_id,
67
exec_test_command,
78
get_random_text,
9+
wait_for_condition,
810
)
911

1012

@@ -27,6 +29,18 @@ def events_create_domain():
2729
]
2830
)
2931

32+
# Verify domain status becomes active before proceeding with tests
33+
wait_for_condition(
34+
5,
35+
60,
36+
check_attribute_value,
37+
"domains",
38+
"view",
39+
domain_id,
40+
"status",
41+
"active",
42+
)
43+
3044
yield domain_id
3145

3246
delete_target_id(target="domains", id=domain_id)

tests/integration/helpers.py

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,13 +58,15 @@
5858

5959

6060
def get_random_text(length: int = 10):
61-
return "".join(random.choice(ascii_lowercase) for i in range(length))
61+
return "".join(random.choice(ascii_lowercase) for _ in range(length))
6262

6363

64-
def wait_for_condition(interval: int, timeout: int, condition: Callable):
64+
def wait_for_condition(interval: int, timeout: int, condition: Callable, *args):
6565
start_time = time.time()
6666
while True:
67-
if condition():
67+
result = condition(*args)
68+
69+
if result:
6870
break
6971

7072
if time.time() - start_time > timeout:
@@ -213,3 +215,26 @@ def assert_help_actions_list(expected_actions, help_output):
213215
output_actions = re.findall(r"│\s(\S+(?:,\s)?\S+)\s*│", help_output)
214216
for expected_action in expected_actions:
215217
assert expected_action in output_actions
218+
219+
220+
def view_command_attribute(
221+
command: str, action: str, item_id: str, attribute: str
222+
) -> str:
223+
return exec_test_command(
224+
BASE_CMDS[command]
225+
+ [
226+
action,
227+
item_id,
228+
"--text",
229+
"--no-header",
230+
"--format",
231+
attribute,
232+
]
233+
)
234+
235+
236+
def check_attribute_value(
237+
command: str, action: str, item_id: str, attribute: str, expected_val: str
238+
) -> bool:
239+
result = view_command_attribute(command, action, item_id, attribute)
240+
return expected_val in result

tests/integration/nodebalancers/fixtures.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,10 @@
22

33
from tests.integration.helpers import (
44
BASE_CMDS,
5+
check_attribute_value,
56
delete_target_id,
67
exec_test_command,
8+
wait_for_condition,
79
)
810
from tests.integration.linodes.helpers import DEFAULT_TEST_IMAGE
911

@@ -216,6 +218,17 @@ def nodebalancer_with_udp_config_and_node(linode_cloud_firewall):
216218
"id",
217219
]
218220
)
221+
# Verify configs-list contains just created confid id
222+
wait_for_condition(
223+
5,
224+
60,
225+
check_attribute_value,
226+
"nodebalancers",
227+
"configs-list",
228+
nodebalancer_id,
229+
"id",
230+
config_id,
231+
)
219232

220233
linode_create = exec_test_command(
221234
BASE_CMDS["linodes"]

tests/integration/obj/test_object_storage.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,12 @@ def test_clusters_list():
3434

3535
assert cluster["id"]
3636
assert cluster["region"]
37-
assert cluster["status"] in {"available", "unavailable"}
37+
assert cluster["status"] in {
38+
"available",
39+
"unavailable",
40+
"hidden",
41+
"limited",
42+
}
3843
assert cluster["domain"].endswith(".linodeobjects.com")
3944
assert cluster["static_site_domain"].startswith("website-")
4045

tests/integration/ssh/test_plugin_ssh.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424

2525

2626
INSTANCE_WAIT_TIMEOUT_SECONDS = 120
27-
SSH_WAIT_TIMEOUT_SECONDS = 80
27+
SSH_WAIT_TIMEOUT_SECONDS = 120
2828
POLL_INTERVAL = 5
2929

3030

0 commit comments

Comments
 (0)