Skip to content

Commit b2ad81f

Browse files
progress
1 parent db08e53 commit b2ad81f

File tree

1 file changed

+67
-4
lines changed

1 file changed

+67
-4
lines changed

test/integration/models/linode/interfaces/test_interfaces.py

Lines changed: 67 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,21 +16,29 @@
1616
LinodeInterfacePublicIPv6RangeOptions,
1717
LinodeInterfacePublicOptions,
1818
LinodeInterfaceVLANOptions,
19-
LinodeInterfaceVPCOptions,
19+
LinodeInterfaceVPCOptions, LinodeInterfaceVPCIPv4Options, LinodeInterfaceVPCIPv4AddressOptions,
20+
LinodeInterfaceVPCIPv4Range,
21+
LinodeInterfaceVPCIPv4RangeOptions,
2022
)
2123

2224

23-
@pytest.fixture(scope="function")
25+
26+
@pytest.fixture
2427
def instance_with_interface_generation_linode(
25-
test_linode_client, e2e_test_firewall
28+
test_linode_client,
29+
e2e_test_firewall,
30+
31+
# We won't be using this all the time, but it's
32+
# necessary for certain consumers of this fixture
33+
create_vpc_with_subnet
2634
):
2735
client = test_linode_client
2836

2937
label = get_test_label()
3038

3139
instance = client.linode.instance_create(
3240
"g6-nanode-1",
33-
get_region(test_linode_client, {"Linode Interfaces"}, site_type="core"),
41+
create_vpc_with_subnet[0].region,
3442
label=label,
3543
interface_generation=InterfaceGeneration.LINODE,
3644
)
@@ -215,3 +223,58 @@ def test_linode_interface_create_public(
215223
assert iface.public.ipv6.slaac[0].address == instance.ipv6.split("/")[0]
216224
assert iface.public.ipv6.slaac[0].prefix == 64
217225
assert len(iface.public.ipv6.shared) == 0
226+
227+
def test_linode_interface_create_vpc(
228+
test_linode_client,
229+
e2e_test_firewall,
230+
create_vpc_with_subnet,
231+
instance_with_interface_generation_linode,
232+
):
233+
instance: Instance = instance_with_interface_generation_linode
234+
vpc, subnet = create_vpc_with_subnet
235+
subnet_network = ipaddress.ip_network(subnet.ipv4)
236+
237+
print(vars(subnet))
238+
239+
# + 10 is an arbitrary offset because the subnet fixture is session scoped.
240+
subnet_allocated_ip = next(v for i, v in enumerate(subnet_network.hosts()) if v == 10)
241+
242+
ipv6_range = test_linode_client.networking.ipv6_range_allocate(
243+
64, linode=instance.id
244+
)
245+
246+
iface = instance.interface_create(
247+
firewall_id=e2e_test_firewall.id,
248+
default_route=LinodeInterfaceDefaultRouteOptions(
249+
ipv4=True,
250+
),
251+
vpc=LinodeInterfaceVPCOptions(
252+
subnet_id=subnet.id,
253+
ipv4=LinodeInterfaceVPCIPv4Options(
254+
addresses=[
255+
LinodeInterfaceVPCIPv4AddressOptions(
256+
address=str(subnet_allocated_ip),
257+
primary=True,
258+
nat_1_1_address="any",
259+
)
260+
],
261+
ranges=[
262+
LinodeInterfaceVPCIPv4RangeOptions(
263+
range=str(subnet_allocated_ip) + "/32",
264+
)
265+
]
266+
)
267+
),
268+
)
269+
270+
assert iface.id is not None
271+
assert iface.linode_id == instance.id
272+
273+
assert iface.created is not None
274+
assert iface.updated is not None
275+
276+
assert isinstance(iface.mac_address, str)
277+
assert iface.version
278+
279+
assert iface.default_route.ipv4
280+
assert not iface.default_route.ipv6

0 commit comments

Comments
 (0)