Skip to content

Commit 787f55f

Browse files
mawilk90yec-akamai
andauthored
TPT-4462: Add integration tests for RDMA interfaces (#713)
* init * add unit test * lint * nit` * Add integration tests for RDMA VPC and Subnet * Update fixture and test assertions for RDMA VPC * Create fixture for subnet RDMA * Change rdma fixtures scope --------- Co-authored-by: Ye Chen <yechen@akamai.com>
1 parent 017b450 commit 787f55f

2 files changed

Lines changed: 68 additions & 0 deletions

File tree

test/integration/conftest.py

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
from requests.exceptions import ConnectionError, RequestException
1818

1919
from linode_api4 import (
20+
Capability,
2021
Instance,
2122
InterfaceGeneration,
2223
IPAddress,
@@ -483,6 +484,27 @@ def create_vpc(test_linode_client):
483484
vpc.delete()
484485

485486

487+
@pytest.fixture
488+
def create_vpc_with_rdma_type(test_linode_client):
489+
client = test_linode_client
490+
label = get_test_label(length=10)
491+
492+
vpc = client.vpcs.create(
493+
label=label,
494+
region=get_region(
495+
# GPUDirect RDMA capability not available for now
496+
# test_linode_client, {Capability.vpcs, Capability.gpudirect_rdma}
497+
test_linode_client,
498+
{Capability.vpcs},
499+
),
500+
description="test description",
501+
vpc_type="rdma",
502+
)
503+
yield vpc
504+
505+
vpc.delete()
506+
507+
486508
@pytest.fixture(scope="session")
487509
def create_vpc_with_subnet(test_linode_client, create_vpc):
488510
subnet = create_vpc.subnet_create(
@@ -518,6 +540,21 @@ def create_vpc_with_subnet_and_linode(
518540
instance.delete()
519541

520542

543+
@pytest.fixture
544+
def create_vpc_with_subnet_and_rdma_type(create_vpc_with_rdma_type):
545+
vpc_rdma = create_vpc_with_rdma_type
546+
label = get_test_label(length=10)
547+
548+
subnet_rdma = vpc_rdma.subnet_create(
549+
label=label,
550+
ipv4="10.0.0.0/24",
551+
)
552+
553+
yield vpc_rdma, subnet_rdma
554+
555+
subnet_rdma.delete()
556+
557+
521558
@pytest.fixture(scope="session")
522559
def create_multiple_vpcs(test_linode_client):
523560
client = test_linode_client

test/integration/models/vpc/test_vpc.py

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ def test_get_vpc(test_linode_client, create_vpc):
1111
test_linode_client.vpcs()
1212
assert vpc.id == create_vpc.id
1313
assert isinstance(vpc.ipv6[0].range, str)
14+
assert vpc.vpc_type == "regular"
1415

1516

1617
@pytest.mark.smoke
@@ -38,6 +39,8 @@ def test_get_subnet(test_linode_client, create_vpc_with_subnet):
3839
vpc.ipv6[0].range.split("::")[0]
3940
)
4041
assert loaded_subnet.id == subnet.id
42+
assert loaded_subnet.vpc_type == "regular"
43+
assert loaded_subnet.vpc_type == vpc.vpc_type
4144

4245

4346
@pytest.mark.smoke
@@ -139,3 +142,31 @@ def test_get_vpc_ipv6s(test_linode_client):
139142
assert "vpc_id" in ipv6
140143
assert isinstance(ipv6["ipv6_range"], str)
141144
assert isinstance(ipv6["ipv6_addresses"], list)
145+
146+
147+
def test_get_vpc_with_rdma_type(test_linode_client, create_vpc_with_rdma_type):
148+
vpc_rdma = create_vpc_with_rdma_type
149+
assert vpc_rdma.vpc_type == "rdma"
150+
assert vpc_rdma.ipv6 is None
151+
152+
vpc = test_linode_client.load(VPC, vpc_rdma.id)
153+
assert vpc.id == vpc_rdma.id
154+
assert vpc.vpc_type == vpc_rdma.vpc_type
155+
156+
vpcs = test_linode_client.vpcs(VPC.vpc_type == "rdma")
157+
assert vpc_rdma.id in [vpc.id for vpc in vpcs]
158+
assert all(vpc.vpc_type == "rdma" for vpc in vpcs)
159+
160+
161+
def test_get_subnet_with_rdma_type(
162+
test_linode_client, create_vpc_with_subnet_and_rdma_type
163+
):
164+
vpc_rdma, subnet_rdma = create_vpc_with_subnet_and_rdma_type
165+
166+
assert subnet_rdma.vpc_type == vpc_rdma.vpc_type
167+
assert subnet_rdma.ipv6 is None
168+
169+
subnet = test_linode_client.load(VPCSubnet, subnet_rdma.id, vpc_rdma.id)
170+
assert subnet.id == subnet_rdma.id
171+
assert subnet.vpc_type == vpc_rdma.vpc_type
172+
assert subnet.ipv6 is None

0 commit comments

Comments
 (0)