Skip to content

Commit bda548e

Browse files
authored
Fix multiple integration test issues (#740)
* fix test * fix create vpc * fix plan * add timeout catch
1 parent 7e8b20c commit bda548e

2 files changed

Lines changed: 55 additions & 37 deletions

File tree

test/integration/conftest.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -479,6 +479,7 @@ def create_vpc(test_linode_client):
479479
"VPC IPv6 Stack",
480480
"Linode Interfaces",
481481
"Custom VPC IPv4 Ranges",
482+
"Linodes",
482483
},
483484
),
484485
description="test description",

test/integration/models/linode/test_linode.py

Lines changed: 54 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ def linode_and_vpc_for_legacy_interface_tests_offline(
102102
label = get_test_label(length=8)
103103

104104
instance = test_linode_client.linode.instance_create(
105-
"g6-standard-1",
105+
"g5-standard-1",
106106
vpc.region,
107107
booted=False,
108108
image="linode/debian11",
@@ -134,15 +134,21 @@ def linode_for_vpu_tests(test_linode_client, e2e_test_firewall):
134134
pytest.skip("No VPU capacity is currently available")
135135

136136
label = get_test_label(length=8)
137-
138-
linode_instance = client.linode.instance_create(
139-
vpu_type,
140-
region,
141-
image="linode/debian12",
142-
label=label,
143-
firewall=e2e_test_firewall,
144-
root_pass="aComplex@Password123",
145-
)
137+
try:
138+
linode_instance = client.linode.instance_create(
139+
vpu_type,
140+
region,
141+
image="linode/debian12",
142+
label=label,
143+
firewall=e2e_test_firewall,
144+
root_pass="aComplex@Password123",
145+
)
146+
except ApiError as e:
147+
reasons = e.errors or [str(e)]
148+
unavailable_msg = "not currently available in the selected region"
149+
if e.status == 400 and any(unavailable_msg in r for r in reasons):
150+
pytest.skip("No VPU capacity is currently available")
151+
raise
146152

147153
yield linode_instance
148154

@@ -1019,18 +1025,24 @@ def test_create_vpc(
10191025

10201026
# TODO:: Add `VPCIPAddress.filters.linode_id == linode.id` filter back
10211027

1022-
# Attempt to resolve the IP from /vpcs/ips
1023-
all_vpc_ips = test_linode_client.vpcs.ips()
1024-
matched_ip = next(
1025-
(
1026-
ip
1027-
for ip in all_vpc_ips
1028-
if ip.address == vpc_ip.address
1029-
and ip.vpc_id == vpc_ip.vpc_id
1030-
and ip.linode_id == vpc_ip.linode_id
1031-
),
1032-
None,
1033-
)
1028+
# Attempt to resolve the IP from /vpcs/ips. The account-wide listing
1029+
# may lag behind instance creation, so poll until the IP appears.
1030+
def resolve_vpc_ip():
1031+
return next(
1032+
(
1033+
ip
1034+
for ip in test_linode_client.vpcs.ips()
1035+
if ip.address == vpc_ip.address
1036+
and ip.vpc_id == vpc_ip.vpc_id
1037+
and ip.linode_id == vpc_ip.linode_id
1038+
),
1039+
None,
1040+
)
1041+
1042+
try:
1043+
matched_ip = wait_for_condition(5, 120, resolve_vpc_ip)
1044+
except TimeoutError:
1045+
matched_ip = None
10341046

10351047
assert (
10361048
matched_ip is not None
@@ -1045,21 +1057,26 @@ def test_create_vpc(
10451057
assert vpc_ips[0].linode_id == linode.id
10461058
assert vpc_ips[0].nat_1_1 == linode.ips.ipv4.public[0].address
10471059

1048-
# Validate VPC IPv6 IPs from /vpcs/ips
1049-
all_vpc_ipv6 = test_linode_client.get("/vpcs/ipv6s")["data"]
1050-
1051-
# Find matching VPC IPv6 entry
1052-
matched_ipv6 = next(
1053-
(
1054-
ip
1055-
for ip in all_vpc_ipv6
1056-
if ip["vpc_id"] == vpc.id
1057-
and ip["linode_id"] == linode.id
1058-
and ip["interface_id"] == interface.id
1059-
and ip["subnet_id"] == subnet.id
1060-
),
1061-
None,
1062-
)
1060+
# Validate VPC IPv6 IPs from /vpcs/ipv6s. The account-wide listing may
1061+
# lag behind instance creation, so poll until the entry appears.
1062+
def resolve_vpc_ipv6():
1063+
all_vpc_ipv6 = test_linode_client.get("/vpcs/ipv6s")["data"]
1064+
return next(
1065+
(
1066+
ip
1067+
for ip in all_vpc_ipv6
1068+
if ip["vpc_id"] == vpc.id
1069+
and ip["linode_id"] == linode.id
1070+
and ip["interface_id"] == interface.id
1071+
and ip["subnet_id"] == subnet.id
1072+
),
1073+
None,
1074+
)
1075+
1076+
try:
1077+
matched_ipv6 = wait_for_condition(5, 120, resolve_vpc_ipv6)
1078+
except TimeoutError:
1079+
matched_ipv6 = None
10631080

10641081
assert (
10651082
matched_ipv6

0 commit comments

Comments
 (0)