1- from test . integration . conftest import get_region
1+ import ipaddress
22from test .integration .helpers import get_test_label
33
44import pytest
1010 LinodeInterfaceDefaultRouteOptions ,
1111 LinodeInterfaceOptions ,
1212 LinodeInterfacePublicOptions ,
13+ LinodeInterfaceVLANOptions ,
1314 LinodeInterfaceVPCOptions ,
1415)
1516
@@ -21,11 +22,8 @@ def linode_create_with_interfaces(
2122 client = test_linode_client
2223 vpc , subnet = create_vpc_with_subnet
2324
24- region = get_region (
25- client ,
26- {"Linodes" , "Cloud Firewall" , "Linode Interfaces" },
27- site_type = "core" ,
28- )
25+ # Are there regions where VPCs are supported but Linode Interfaces aren't
26+ region = vpc .region
2927 label = get_test_label ()
3028
3129 instance , _ = client .linode .instance_create (
@@ -44,14 +42,15 @@ def linode_create_with_interfaces(
4442 public = LinodeInterfacePublicOptions (),
4543 ),
4644 LinodeInterfaceOptions (
47- firewall_id = e2e_test_firewall .id ,
48- default_route = LinodeInterfaceDefaultRouteOptions (
49- ipv4 = True ,
50- ),
5145 vpc = LinodeInterfaceVPCOptions (
5246 subnet_id = subnet .id ,
5347 ),
5448 ),
49+ LinodeInterfaceOptions (
50+ vlan = LinodeInterfaceVLANOptions (
51+ vlan_label = "test-vlan" , ipam_address = "10.0.0.5/32"
52+ ),
53+ ),
5554 ],
5655 )
5756
@@ -60,8 +59,12 @@ def linode_create_with_interfaces(
6059 instance .delete ()
6160
6261
63- def test_linode_create_with_linode_interfaces (linode_create_with_interfaces ):
62+ def test_linode_create_with_linode_interfaces (
63+ create_vpc_with_subnet ,
64+ linode_create_with_interfaces ,
65+ ):
6466 instance : Instance = linode_create_with_interfaces
67+ vpc , subnet = create_vpc_with_subnet
6568
6669 def __assert_base (iface : LinodeInterface ):
6770 assert iface .id is not None
@@ -88,8 +91,38 @@ def __assert_public(iface: LinodeInterface):
8891 assert len (iface .public .ipv6 .shared ) == 0
8992 assert len (iface .public .ipv6 .ranges ) == 0
9093
94+ def __assert_vpc (iface : LinodeInterface ):
95+ __assert_base (iface )
96+
97+ assert not iface .default_route .ipv4
98+ assert not iface .default_route .ipv6
99+
100+ assert iface .vpc .vpc_id == vpc .id
101+ assert iface .vpc .subnet_id == subnet .id
102+
103+ assert ipaddress .ip_address (
104+ iface .vpc .ipv4 .addresses [0 ].address
105+ ) in ipaddress .ip_network (subnet .ipv4 )
106+ assert iface .vpc .ipv4 .addresses [0 ].primary
107+ assert iface .vpc .ipv4 .addresses [0 ].nat_1_1_address is None
108+
109+ assert len (iface .vpc .ipv4 .ranges ) == 0
110+
111+ def __assert_vlan (iface : LinodeInterface ):
112+ __assert_base (iface )
113+
114+ assert not iface .default_route .ipv4
115+ assert not iface .default_route .ipv6
116+
117+ assert iface .vlan .vlan_label == "test-vlan"
118+ assert iface .vlan .ipam_address == "10.0.0.5/32"
119+
91120 __assert_public (instance .interfaces [0 ])
121+ __assert_vpc (instance .interfaces [1 ])
122+ __assert_vlan (instance .interfaces [2 ])
92123
93124 instance .invalidate ()
94125
95126 __assert_public (instance .interfaces [0 ])
127+ __assert_vpc (instance .interfaces [1 ])
128+ __assert_vlan (instance .interfaces [2 ])
0 commit comments