Skip to content

Commit 2320cbc

Browse files
committed
Add test for RDMA Linode instance creation
1 parent 787f55f commit 2320cbc

2 files changed

Lines changed: 114 additions & 9 deletions

File tree

test/integration/conftest.py

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@
4242
RUN_LONG_TESTS = "RUN_LONG_TESTS"
4343
SKIP_E2E_FIREWALL = "SKIP_E2E_FIREWALL"
4444

45+
TEST_VPC_REGION = None
46+
4547
ALL_ACCOUNT_AVAILABILITIES = {
4648
"Linodes",
4749
"NodeBalancers",
@@ -468,14 +470,16 @@ def test_oauth_client(test_linode_client):
468470
@pytest.fixture(scope="session")
469471
def create_vpc(test_linode_client):
470472
client = test_linode_client
471-
472473
label = get_test_label(length=10)
473474

475+
global TEST_VPC_REGION
476+
TEST_VPC_REGION = get_region(
477+
test_linode_client, {"VPCs", "VPC IPv6 Stack", "Linode Interfaces"}
478+
)
479+
474480
vpc = client.vpcs.create(
475481
label=label,
476-
region=get_region(
477-
test_linode_client, {"VPCs", "VPC IPv6 Stack", "Linode Interfaces"}
478-
),
482+
region=TEST_VPC_REGION,
479483
description="test description",
480484
ipv6=[{"range": "auto"}],
481485
)
@@ -489,14 +493,19 @@ def create_vpc_with_rdma_type(test_linode_client):
489493
client = test_linode_client
490494
label = get_test_label(length=10)
491495

492-
vpc = client.vpcs.create(
493-
label=label,
494-
region=get_region(
496+
if TEST_VPC_REGION:
497+
region = TEST_VPC_REGION
498+
else:
499+
region = get_region(
495500
# GPUDirect RDMA capability not available for now
496501
# test_linode_client, {Capability.vpcs, Capability.gpudirect_rdma}
497502
test_linode_client,
498503
{Capability.vpcs},
499-
),
504+
)
505+
506+
vpc = client.vpcs.create(
507+
label=label,
508+
region=region,
500509
description="test description",
501510
vpc_type="rdma",
502511
)

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

Lines changed: 97 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
import copy
22
import ipaddress
3-
from test.integration.helpers import get_test_label
3+
from test.integration.helpers import (
4+
get_test_label,
5+
wait_for_condition,
6+
)
47

58
import pytest
69

@@ -16,6 +19,9 @@
1619
LinodeInterfacePublicIPv6Options,
1720
LinodeInterfacePublicIPv6RangeOptions,
1821
LinodeInterfacePublicOptions,
22+
LinodeInterfaceRDMAVPCIPv4AddressOptions,
23+
LinodeInterfaceRDMAVPCIPv4Options,
24+
LinodeInterfaceRDMAVPCOptions,
1925
LinodeInterfaceVLANOptions,
2026
LinodeInterfaceVPCIPv4AddressOptions,
2127
LinodeInterfaceVPCIPv4Options,
@@ -43,6 +49,22 @@ def build_interface_public_ipv4(firewall, ip_address):
4349
)
4450

4551

52+
def build_interface_rdma_vpc_ipv4(subnet_id: int):
53+
return LinodeInterfaceOptions(
54+
firewall_id=-1,
55+
rdma_vpc=LinodeInterfaceRDMAVPCOptions(
56+
subnet_id=subnet_id,
57+
ipv4=LinodeInterfaceRDMAVPCIPv4Options(
58+
addresses=[
59+
LinodeInterfaceRDMAVPCIPv4AddressOptions(
60+
address="auto", primary=True
61+
)
62+
]
63+
),
64+
),
65+
)
66+
67+
4668
def create_linode_with_legacy_config(
4769
client, ip_address, label, firewall, authorized_key
4870
):
@@ -75,6 +97,22 @@ def create_linode_with_standard_interfaces(
7597
return linode
7698

7799

100+
def create_multiple_rdma_interfaces(amount: int, subnet_id: int):
101+
"""
102+
Creates multiple VPC RDMA interfaces that may be needed for RDMA Linode instance
103+
104+
Note:
105+
At least 8 separate VPC RDMA interfaces need to be created for a single RDMA linode instance
106+
"""
107+
interfaces = list()
108+
109+
for _ in range(amount):
110+
rdma_iface = build_interface_rdma_vpc_ipv4(subnet_id)
111+
interfaces.append(rdma_iface)
112+
113+
return interfaces
114+
115+
78116
def test_linode_create_with_linode_interfaces(
79117
create_vpc_with_subnet,
80118
linode_with_linode_interfaces,
@@ -458,3 +496,61 @@ def test_linode_interfaces_with_reserved_ips(
458496
assert reserved_ips_list[0].reserved == True
459497
assert reserved_ips_list[0].linode_id is None
460498
assert reserved_ips_list[0].assigned_entity is None
499+
500+
501+
@pytest.mark.skip(
502+
reason="Linode with RDMA interfaces requires manual infra changes at the moment"
503+
)
504+
def test_linode_interfaces_with_rdma_vpc_type(
505+
request,
506+
test_linode_client,
507+
create_vpc_with_subnet,
508+
create_vpc_with_subnet_and_rdma_type,
509+
):
510+
client = test_linode_client
511+
vpc, subnet = create_vpc_with_subnet
512+
vpc_rdma, subnet_rdma = create_vpc_with_subnet_and_rdma_type
513+
514+
# Include RDMA VPC interfaces
515+
multi_ifaces = create_multiple_rdma_interfaces(8, subnet_rdma.id)
516+
517+
# Include (at least one) regular interface
518+
multi_ifaces.append(
519+
LinodeInterfaceOptions(
520+
firewall_id=-1,
521+
default_route=LinodeInterfaceDefaultRouteOptions(
522+
ipv4=True,
523+
),
524+
vpc=LinodeInterfaceVPCOptions(
525+
subnet_id=subnet.id,
526+
ipv4=LinodeInterfaceVPCIPv4Options(
527+
addresses=[
528+
LinodeInterfaceVPCIPv4AddressOptions(
529+
address="auto",
530+
primary=True,
531+
)
532+
],
533+
),
534+
),
535+
),
536+
)
537+
538+
instance = client.linode.instance_create(
539+
label="go-test-rdma-" + get_test_label(),
540+
root_pass="aComplex@Password123",
541+
image="linode/ubuntu24.04",
542+
region=vpc.region,
543+
# ltype="TBD",
544+
# host_id="TBD",
545+
interface_generation=InterfaceGeneration.LINODE,
546+
interfaces=multi_ifaces,
547+
booted=False,
548+
)
549+
request.addfinalizer(instance.delete)
550+
551+
def get_linode_status():
552+
return instance.status == "offline"
553+
554+
wait_for_condition(5, 180, get_linode_status)
555+
556+
assert len(instance.linode_interfaces) == len(multi_ifaces)

0 commit comments

Comments
 (0)