diff --git a/test/integration/conftest.py b/test/integration/conftest.py index dc851f87a..7748a9780 100644 --- a/test/integration/conftest.py +++ b/test/integration/conftest.py @@ -17,6 +17,7 @@ from requests.exceptions import ConnectionError, RequestException from linode_api4 import ( + Capability, Instance, InterfaceGeneration, IPAddress, @@ -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( @@ -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 diff --git a/test/integration/models/vpc/test_vpc.py b/test/integration/models/vpc/test_vpc.py index d5533ed82..dd43e0b51 100644 --- a/test/integration/models/vpc/test_vpc.py +++ b/test/integration/models/vpc/test_vpc.py @@ -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 @@ -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 @@ -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