Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions test/integration/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
from requests.exceptions import ConnectionError, RequestException

from linode_api4 import (
Capability,
Instance,
InterfaceGeneration,
IPAddress,
Expand Down Expand Up @@ -483,6 +484,27 @@ def create_vpc(test_linode_client):
vpc.delete()


@pytest.fixture(scope="session")
def create_vpc_with_rdma_type(test_linode_client):
client = test_linode_client
label = get_test_label(length=10)

vpc = client.vpcs.create(
label=label,
region=get_region(
# GPUDirect RDMA capability not available for now
# test_linode_client, {Capability.vpcs, Capability.gpudirect_rdma}
test_linode_client,
{Capability.vpcs},
),
description="test description",
vpc_type="rdma",
)
yield vpc

vpc.delete()


@pytest.fixture(scope="session")
def create_vpc_with_subnet(test_linode_client, create_vpc):
subnet = create_vpc.subnet_create(
Expand Down Expand Up @@ -518,6 +540,21 @@ def create_vpc_with_subnet_and_linode(
instance.delete()


@pytest.fixture(scope="session")
def create_vpc_with_subnet_and_rdma_type(create_vpc_with_rdma_type):
vpc_rdma = create_vpc_with_rdma_type
label = get_test_label(length=10)

subnet_rdma = create_vpc_with_rdma_type.subnet_create(
label=label,
ipv4="10.0.0.0/24",
)

yield vpc_rdma, subnet_rdma

subnet_rdma.delete()


@pytest.fixture(scope="session")
def create_multiple_vpcs(test_linode_client):
client = test_linode_client
Expand Down
31 changes: 31 additions & 0 deletions test/integration/models/vpc/test_vpc.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ def test_get_vpc(test_linode_client, create_vpc):
test_linode_client.vpcs()
assert vpc.id == create_vpc.id
assert isinstance(vpc.ipv6[0].range, str)
assert vpc.vpc_type == "regular"


@pytest.mark.smoke
Expand Down Expand Up @@ -38,6 +39,8 @@ def test_get_subnet(test_linode_client, create_vpc_with_subnet):
vpc.ipv6[0].range.split("::")[0]
)
assert loaded_subnet.id == subnet.id
assert loaded_subnet.vpc_type == "regular"
assert loaded_subnet.vpc_type == vpc.vpc_type


@pytest.mark.smoke
Expand Down Expand Up @@ -139,3 +142,31 @@ def test_get_vpc_ipv6s(test_linode_client):
assert "vpc_id" in ipv6
assert isinstance(ipv6["ipv6_range"], str)
assert isinstance(ipv6["ipv6_addresses"], list)


def test_get_vpc_with_rdma_type(test_linode_client, create_vpc_with_rdma_type):
vpc_rdma = create_vpc_with_rdma_type
assert vpc_rdma.vpc_type == "rdma"
assert vpc_rdma.ipv6 is None

vpc = test_linode_client.load(VPC, vpc_rdma.id)
assert vpc.id == vpc_rdma.id
assert vpc.vpc_type == vpc_rdma.vpc_type

vpcs = test_linode_client.vpcs(VPC.vpc_type == "rdma")
assert vpc_rdma.id in [vpc.id for vpc in vpcs]
assert all(vpc.vpc_type == "rdma" for vpc in vpcs)


def test_get_subnet_with_rdma_type(
test_linode_client, create_vpc_with_subnet_and_rdma_type
):
vpc_rdma, subnet_rdma = create_vpc_with_subnet_and_rdma_type

assert subnet_rdma.vpc_type == vpc_rdma.vpc_type
assert subnet_rdma.ipv6 is None

subnet = test_linode_client.load(VPCSubnet, subnet_rdma.id, vpc_rdma.id)
assert subnet.id == subnet_rdma.id
assert subnet.vpc_type == vpc_rdma.vpc_type
assert subnet.ipv6 is None