From 6f8e55508afbdcb856d24580520feda7e94bf9ba Mon Sep 17 00:00:00 2001 From: ezilber-akamai Date: Thu, 12 Dec 2024 14:55:31 -0500 Subject: [PATCH 1/3] Implemented changes for VPU --- linode_api4/objects/linode.py | 1 + test/fixtures/linode_types.json | 33 ++++++++++- test/integration/models/linode/test_linode.py | 59 +++++++++++++++---- test/unit/objects/linode_test.py | 3 +- 4 files changed, 81 insertions(+), 15 deletions(-) diff --git a/linode_api4/objects/linode.py b/linode_api4/objects/linode.py index cb5c9d9af..dc5472837 100644 --- a/linode_api4/objects/linode.py +++ b/linode_api4/objects/linode.py @@ -264,6 +264,7 @@ class Type(Base): "vcpus": Property(), "gpus": Property(), "successor": Property(), + "accelerated_devices": Property(), # type_class is populated from the 'class' attribute of the returned JSON } diff --git a/test/fixtures/linode_types.json b/test/fixtures/linode_types.json index 819867b79..dee3209ee 100644 --- a/test/fixtures/linode_types.json +++ b/test/fixtures/linode_types.json @@ -1,9 +1,10 @@ { - "results": 4, + "results": 5, "pages": 1, "page": 1, "data": [ { + "accelerated_devices": 0, "disk": 20480, "memory": 1024, "transfer": 1000, @@ -52,6 +53,7 @@ "successor": null }, { + "accelerated_devices": 0, "disk": 20480, "memory": 16384, "transfer": 5000, @@ -100,6 +102,7 @@ "successor": null }, { + "accelerated_devices": 0, "disk": 30720, "memory": 2048, "transfer": 2000, @@ -148,6 +151,7 @@ "successor": null }, { + "accelerated_devices": 0, "disk": 49152, "memory": 4096, "transfer": 3000, @@ -194,6 +198,33 @@ } ], "successor": null + }, + { + "id": "g1-accelerated-netint-vpu-t1u1-m", + "label": "Netint Quadra T1U x1 Medium", + "price": { + "hourly": 0.0, + "monthly": 0.0 + }, + "region_prices": [], + "addons": { + "backups": { + "price": { + "hourly": 0.0, + "monthly": 0.0 + }, + "region_prices": [] + } + }, + "memory": 24576, + "disk": 307200, + "transfer": 0, + "vcpus": 12, + "gpus": 0, + "network_out": 16000, + "class": "accelerated", + "successor": null, + "accelerated_devices": 1 } ] } \ No newline at end of file diff --git a/test/integration/models/linode/test_linode.py b/test/integration/models/linode/test_linode.py index a8ba2b21e..b6253470d 100644 --- a/test/integration/models/linode/test_linode.py +++ b/test/integration/models/linode/test_linode.py @@ -86,6 +86,26 @@ def linode_for_network_interface_tests(test_linode_client, e2e_test_firewall): linode_instance.delete() +@pytest.fixture(scope="session") +def linode_for_vpu_tests(test_linode_client, e2e_test_firewall): + client = test_linode_client + region = "us-lax" + + label = get_test_label(length=8) + + linode_instance, password = client.linode.instance_create( + "g1-accelerated-netint-vpu-t1u1-s", + region, + image="linode/debian10", + label=label, + firewall=e2e_test_firewall, + ) + + yield linode_instance + + linode_instance.delete() + + @pytest.fixture def linode_for_disk_tests(test_linode_client, e2e_test_firewall): client = test_linode_client @@ -196,6 +216,13 @@ def test_get_linode(test_linode_client, linode_with_volume_firewall): assert linode.id == linode_with_volume_firewall.id +def test_get_vpu(test_linode_client, linode_for_vpu_tests): + linode = test_linode_client.load(Instance, linode_for_vpu_tests.id) + + assert linode.label == linode_for_vpu_tests.label + assert hasattr(linode.specs, "accelerated_devices") + + def test_linode_transfer(test_linode_client, linode_with_volume_firewall): linode = test_linode_client.load(Instance, linode_with_volume_firewall.id) @@ -339,7 +366,7 @@ def test_linode_resize(create_linode_for_long_running_tests): def test_linode_resize_with_class( - test_linode_client, create_linode_for_long_running_tests + test_linode_client, create_linode_for_long_running_tests ): linode = create_linode_for_long_running_tests ltype = Type(test_linode_client, "g6-standard-6") @@ -363,8 +390,8 @@ def test_linode_resize_with_class( @pytest.mark.flaky(reruns=3, reruns_delay=2) def test_linode_resize_with_migration_type( - test_linode_client, - create_linode_for_long_running_tests, + test_linode_client, + create_linode_for_long_running_tests, ): linode = create_linode_for_long_running_tests m_type = MigrationType.WARM @@ -443,12 +470,12 @@ def test_linode_with_disk_encryption_disabled(linode_with_disk_encryption): assert linode.disk_encryption == InstanceDiskEncryptionType.disabled assert ( - linode.disks[0].disk_encryption == InstanceDiskEncryptionType.disabled + linode.disks[0].disk_encryption == InstanceDiskEncryptionType.disabled ) def test_linode_with_block_storage_encryption( - linode_with_block_storage_encryption, + linode_with_block_storage_encryption, ): linode = linode_with_block_storage_encryption assert "Block Storage Encryption" in linode.capabilities @@ -591,6 +618,9 @@ def test_get_linode_types(test_linode_client): assert len(types) > 0 assert "g6-nanode-1" in ids + for linode_type in types: + assert hasattr(linode_type, "accelerated_devices") + def test_get_linode_types_overrides(test_linode_client): types = test_linode_client.linode.types() @@ -691,11 +721,14 @@ def test_create_vlan(self, linode_for_network_interface_tests): assert interface.label == "testvlan" assert interface.ipam_address == "10.0.0.2/32" + def test_create_vpu(self, test_linode_client, linode_for_vpu_tests): + assert hasattr(linode_for_vpu_tests.specs, "accelerated_devices") + def test_create_vpc( - self, - test_linode_client, - linode_for_network_interface_tests, - create_vpc_with_subnet_and_linode, + self, + test_linode_client, + linode_for_network_interface_tests, + create_vpc_with_subnet_and_linode, ): vpc, subnet, linode, _ = create_vpc_with_subnet_and_linode @@ -749,9 +782,9 @@ def test_create_vpc( assert vpc_ips[0].nat_1_1 == linode.ips.ipv4.public[0].address def test_update_vpc( - self, - linode_for_network_interface_tests, - create_vpc_with_subnet_and_linode, + self, + linode_for_network_interface_tests, + create_vpc_with_subnet_and_linode, ): vpc, subnet, linode, _ = create_vpc_with_subnet_and_linode @@ -812,7 +845,7 @@ def test_reorder(self, linode_for_network_interface_tests): ] def test_delete_interface_containing_vpc( - self, create_vpc_with_subnet_and_linode + self, create_vpc_with_subnet_and_linode ): vpc, subnet, linode, _ = create_vpc_with_subnet_and_linode diff --git a/test/unit/objects/linode_test.py b/test/unit/objects/linode_test.py index 700e5d0db..5f95e8d3c 100644 --- a/test/unit/objects/linode_test.py +++ b/test/unit/objects/linode_test.py @@ -656,7 +656,7 @@ def test_get_types(self): """ types = self.client.linode.types() - self.assertEqual(len(types), 4) + self.assertEqual(len(types), 5) for t in types: self.assertTrue(t._populated) self.assertIsNotNone(t.id) @@ -667,6 +667,7 @@ def test_get_types(self): self.assertIsNone(t.successor) self.assertIsNotNone(t.region_prices) self.assertIsNotNone(t.addons.backups.region_prices) + self.assertIsNotNone(t.accelerated_devices) def test_get_type_by_id(self): """ From ba7a0e745c05f2310cb1041f921bc4a20b189107 Mon Sep 17 00:00:00 2001 From: ezilber-akamai Date: Thu, 12 Dec 2024 15:34:05 -0500 Subject: [PATCH 2/3] Fix lint --- test/integration/models/linode/test_linode.py | 26 +++++++++---------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/test/integration/models/linode/test_linode.py b/test/integration/models/linode/test_linode.py index b6253470d..8da32dc96 100644 --- a/test/integration/models/linode/test_linode.py +++ b/test/integration/models/linode/test_linode.py @@ -366,7 +366,7 @@ def test_linode_resize(create_linode_for_long_running_tests): def test_linode_resize_with_class( - test_linode_client, create_linode_for_long_running_tests + test_linode_client, create_linode_for_long_running_tests ): linode = create_linode_for_long_running_tests ltype = Type(test_linode_client, "g6-standard-6") @@ -390,8 +390,8 @@ def test_linode_resize_with_class( @pytest.mark.flaky(reruns=3, reruns_delay=2) def test_linode_resize_with_migration_type( - test_linode_client, - create_linode_for_long_running_tests, + test_linode_client, + create_linode_for_long_running_tests, ): linode = create_linode_for_long_running_tests m_type = MigrationType.WARM @@ -470,12 +470,12 @@ def test_linode_with_disk_encryption_disabled(linode_with_disk_encryption): assert linode.disk_encryption == InstanceDiskEncryptionType.disabled assert ( - linode.disks[0].disk_encryption == InstanceDiskEncryptionType.disabled + linode.disks[0].disk_encryption == InstanceDiskEncryptionType.disabled ) def test_linode_with_block_storage_encryption( - linode_with_block_storage_encryption, + linode_with_block_storage_encryption, ): linode = linode_with_block_storage_encryption assert "Block Storage Encryption" in linode.capabilities @@ -725,10 +725,10 @@ def test_create_vpu(self, test_linode_client, linode_for_vpu_tests): assert hasattr(linode_for_vpu_tests.specs, "accelerated_devices") def test_create_vpc( - self, - test_linode_client, - linode_for_network_interface_tests, - create_vpc_with_subnet_and_linode, + self, + test_linode_client, + linode_for_network_interface_tests, + create_vpc_with_subnet_and_linode, ): vpc, subnet, linode, _ = create_vpc_with_subnet_and_linode @@ -782,9 +782,9 @@ def test_create_vpc( assert vpc_ips[0].nat_1_1 == linode.ips.ipv4.public[0].address def test_update_vpc( - self, - linode_for_network_interface_tests, - create_vpc_with_subnet_and_linode, + self, + linode_for_network_interface_tests, + create_vpc_with_subnet_and_linode, ): vpc, subnet, linode, _ = create_vpc_with_subnet_and_linode @@ -845,7 +845,7 @@ def test_reorder(self, linode_for_network_interface_tests): ] def test_delete_interface_containing_vpc( - self, create_vpc_with_subnet_and_linode + self, create_vpc_with_subnet_and_linode ): vpc, subnet, linode, _ = create_vpc_with_subnet_and_linode From 03c8f3bbfe822bc3dcd227c12d756c0c72e8c9c0 Mon Sep 17 00:00:00 2001 From: ezilber-akamai Date: Mon, 13 Jan 2025 09:07:26 -0500 Subject: [PATCH 3/3] Updated debian version --- test/integration/models/linode/test_linode.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/test/integration/models/linode/test_linode.py b/test/integration/models/linode/test_linode.py index 8da32dc96..2ec1fed63 100644 --- a/test/integration/models/linode/test_linode.py +++ b/test/integration/models/linode/test_linode.py @@ -38,7 +38,7 @@ def linode_with_volume_firewall(test_linode_client): linode_instance, password = client.linode.instance_create( "g6-nanode-1", region, - image="linode/debian10", + image="linode/debian12", label=label + "_modlinode", ) @@ -76,7 +76,7 @@ def linode_for_network_interface_tests(test_linode_client, e2e_test_firewall): linode_instance, password = client.linode.instance_create( "g6-nanode-1", region, - image="linode/debian10", + image="linode/debian12", label=label, firewall=e2e_test_firewall, ) @@ -96,7 +96,7 @@ def linode_for_vpu_tests(test_linode_client, e2e_test_firewall): linode_instance, password = client.linode.instance_create( "g1-accelerated-netint-vpu-t1u1-s", region, - image="linode/debian10", + image="linode/debian12", label=label, firewall=e2e_test_firewall, ) @@ -167,7 +167,7 @@ def create_linode_for_long_running_tests(test_linode_client, e2e_test_firewall): linode_instance, password = client.linode.instance_create( "g6-nanode-1", region, - image="linode/debian10", + image="linode/debian12", label=label + "_long_tests", firewall=e2e_test_firewall, ) @@ -241,7 +241,7 @@ def test_linode_rebuild(test_linode_client): label = get_test_label() + "_rebuild" linode, password = client.linode.instance_create( - "g6-nanode-1", region, image="linode/debian10", label=label + "g6-nanode-1", region, image="linode/debian12", label=label ) wait_for_condition(10, 100, get_status, linode, "running") @@ -249,14 +249,14 @@ def test_linode_rebuild(test_linode_client): retry_sending_request( 3, linode.rebuild, - "linode/debian10", + "linode/debian12", disk_encryption=InstanceDiskEncryptionType.disabled, ) wait_for_condition(10, 100, get_status, linode, "rebuilding") assert linode.status == "rebuilding" - assert linode.image.id == "linode/debian10" + assert linode.image.id == "linode/debian12" assert linode.disk_encryption == InstanceDiskEncryptionType.disabled @@ -299,7 +299,7 @@ def test_delete_linode(test_linode_client): linode_instance, password = client.linode.instance_create( "g6-nanode-1", region, - image="linode/debian10", + image="linode/debian12", label=label + "_linode", )