This is an automated email from the ASF dual-hosted git repository. tomaz pushed a commit to branch trunk in repository https://gitbox.apache.org/repos/asf/libcloud.git
commit 59286b46ca1b4b25caaa445d015ebeae52787d02 Author: Tomaz Muraus <to...@tomaz.me> AuthorDate: Sun Dec 3 11:07:51 2023 +0100 Add tests for handling of size.ram attribute when TB is returned by the server. --- .../test/compute/fixtures/equinixmetal/plans.json | 17 ++++++++ libcloud/test/compute/test_equinixmetal.py | 46 +++++++++++++++++++++- 2 files changed, 62 insertions(+), 1 deletion(-) diff --git a/libcloud/test/compute/fixtures/equinixmetal/plans.json b/libcloud/test/compute/fixtures/equinixmetal/plans.json index af9544603..5dc812276 100644 --- a/libcloud/test/compute/fixtures/equinixmetal/plans.json +++ b/libcloud/test/compute/fixtures/equinixmetal/plans.json @@ -16,6 +16,23 @@ "pricing": { "hourly":0.4,"monthly":250.0 } + }, + { + "id": "6d1f1ffa-7912-4b78-b50d-88cc7c8ab40e", + "slug": "baremetal_2", + "name": "Type 2", + "description": "Our Type 2 configuration is a zippy general use server", + "line": "baremetal", + "specs": { + "cpus":[{"count":2,"type":"Intel E3-1240 v3"}], + "memory":{"total":"2TB"}, + "drives":[{"count":2,"size":"120GB","type":"SSD"}], + "nics":[{"count":2,"type":"gigabit"}], + "features":{"raid":true,"txt":true} + }, + "pricing": { + "hourly":0.4,"monthly":250.0 + } } ] } diff --git a/libcloud/test/compute/test_equinixmetal.py b/libcloud/test/compute/test_equinixmetal.py index de1294203..9c7f3b928 100644 --- a/libcloud/test/compute/test_equinixmetal.py +++ b/libcloud/test/compute/test_equinixmetal.py @@ -70,6 +70,7 @@ class EquinixMetalTest(unittest.TestCase, TestCaseMixin): def test_list_nodes_response(self): nodes = self.driver.list_nodes("project-id") self.assertTrue(isinstance(nodes, list)) + for node in nodes: self.assertTrue(isinstance(node, Node)) @@ -83,7 +84,9 @@ class EquinixMetalTest(unittest.TestCase, TestCaseMixin): def test_list_sizes(self): sizes = self.driver.list_sizes() - self.assertEqual(len(sizes), 1) + self.assertEqual(len(sizes), 2) + self.assertEqual(sizes[0].ram, 16 * 1024) + self.assertEqual(sizes[1].ram, 2 * 1024 * 1024) def test_create_node(self): node = self.driver.create_node( @@ -241,9 +244,11 @@ g5ZW2BiJzvqz5PebGS70y/ySCNW1qQmJURK/Wc1bt9en root@libcloud", def test_ex_disassociate_address_with_node(self): node = self.driver.list_nodes("project-id")[0] assignments = self.driver.ex_list_ip_assignments_for_node(node) + for ip_assignment in assignments["ip_addresses"]: if ip_assignment["gateway"] == "147.75.40.2": self.driver.ex_disassociate_address(ip_assignment["id"]) + break def test_list_volumes(self): @@ -271,9 +276,11 @@ g5ZW2BiJzvqz5PebGS70y/ySCNW1qQmJURK/Wc1bt9en root@libcloud", node = self.driver.ex_list_nodes_for_project( ex_project_id="3d27fd13-0466-4878-be22-9a4b5595a3df" )[0] + for vol in volumes: if len(vol.extra["attachments"]) == 0: attached = self.driver.attach_volume(node, vol) + break assert attached @@ -282,9 +289,11 @@ g5ZW2BiJzvqz5PebGS70y/ySCNW1qQmJURK/Wc1bt9en root@libcloud", volumes = self.driver.ex_list_volumes_for_project( ex_project_id="3d27fd13-0466-4878-be22-9a4b5595a3df" ) + for vol in volumes: if len(vol.extra["attachments"]) > 0: detached = self.driver.detach_volume(vol) + break assert detached @@ -293,9 +302,11 @@ g5ZW2BiJzvqz5PebGS70y/ySCNW1qQmJURK/Wc1bt9en root@libcloud", volumes = self.driver.ex_list_volumes_for_project( ex_project_id="3d27fd13-0466-4878-be22-9a4b5595a3df" ) + for vol in volumes: if len(vol.extra["attachments"]) == 0: destroyed = self.driver.destroy_volume(vol) + break assert destroyed @@ -305,44 +316,52 @@ class EquinixMetalMockHttp(MockHttp): def _metal_v1_facilities(self, method, url, body, headers): body = self.fixtures.load("facilities.json") + return (httplib.OK, body, {}, httplib.responses[httplib.OK]) def _metal_v1_plans(self, method, url, body, headers): body = self.fixtures.load("plans.json") + return (httplib.OK, body, {}, httplib.responses[httplib.OK]) def _metal_v1_projects_3d27fd13_0466_4878_be22_9a4b5595a3df_plans( self, method, url, body, headers ): body = self.fixtures.load("plans.json") + return (httplib.OK, body, {}, httplib.responses[httplib.OK]) def _metal_v1_projects(self, method, url, body, headers): body = self.fixtures.load("projects.json") + return (httplib.OK, body, {}, httplib.responses[httplib.OK]) def _metal_v1_projects_4b653fce_6405_4300_9f7d_c587b7888fe5_devices( self, method, url, body, headers ): body = self.fixtures.load("devices_for_project.json") + return (httplib.OK, body, {}, httplib.responses[httplib.OK]) def _metal_v1_projects_4a4bce6b_d2ef_41f8_95cf_0e2f32996440_devices( self, method, url, body, headers ): body = self.fixtures.load("devices_for_project.json") + return (httplib.OK, body, {}, httplib.responses[httplib.OK]) def _metal_v1_projects_3d27fd13_0466_4878_be22_9a4b5595a3df_devices( self, method, url, body, headers ): body = self.fixtures.load("devices_for_project.json") + return (httplib.OK, body, {}, httplib.responses[httplib.OK]) def _metal_v1_projects_4b653fce_6405_4300_9f7d_c587b7888fe5_ips( self, method, url, body, headers ): body = self.fixtures.load("project_ips.json") + return (httplib.OK, body, {}, httplib.responses[httplib.OK]) def _metal_v1_projects_3d27fd13_0466_4878_be22_9a4b5595a3df_ips( @@ -350,36 +369,44 @@ class EquinixMetalMockHttp(MockHttp): ): if method == "POST": body = self.fixtures.load("reserve_ip.json") + return (httplib.OK, body, {}, httplib.responses[httplib.OK]) def _metal_v1_projects_4b653fce_6405_4300_9f7d_c587b7888fe5_bgp_config( self, method, url, body, headers ): body = self.fixtures.load("bgp_config_project_1.json") + return (httplib.OK, body, {}, httplib.responses[httplib.OK]) def _metal_v1_projects_3d27fd13_0466_4878_be22_9a4b5595a3df_bgp_config( self, method, url, body, headers ): body = self.fixtures.load("bgp_config_project_1.json") + return (httplib.OK, body, {}, httplib.responses[httplib.OK]) def _metal_v1_projects_4a4bce6b_d2ef_41f8_95cf_0e2f32996440_bgp_config( self, method, url, body, headers ): body = self.fixtures.load("bgp_config_project_3.json") + return (httplib.OK, body, {}, httplib.responses[httplib.OK]) def _metal_v1_operating_systems(self, method, url, body, headers): body = self.fixtures.load("operatingsystems.json") + return (httplib.OK, body, {}, httplib.responses[httplib.OK]) def _metal_v1_ssh_keys(self, method, url, body, headers): if method == "GET": body = self.fixtures.load("sshkeys.json") + return (httplib.OK, body, {}, httplib.responses[httplib.OK]) + if method == "POST": body = self.fixtures.load("sshkey_create.json") + return (httplib.OK, body, {}, httplib.responses[httplib.OK]) def _metal_v1_ssh_keys_2c1a7f23_1dc6_4a37_948e_d9857d9f607c(self, method, url, body, headers): @@ -389,9 +416,11 @@ class EquinixMetalMockHttp(MockHttp): def _metal_v1_projects_project_id_devices(self, method, url, body, headers): if method == "POST": body = self.fixtures.load("device_create.json") + return (httplib.OK, body, {}, httplib.responses[httplib.OK]) elif method == "GET": body = self.fixtures.load("devices.json") + return (httplib.OK, body, {}, httplib.responses[httplib.OK]) def _metal_v1_devices_1e52437e_bbbb_cccc_dddd_74a9dfd3d3bb(self, method, url, body, headers): @@ -408,12 +437,14 @@ class EquinixMetalMockHttp(MockHttp): ): if method == "POST": body = self.fixtures.load("bgp_session_create.json") + return (httplib.OK, body, {}, httplib.responses[httplib.OK]) def _metal_v1_bgp_sessions_08f6b756_758b_4f1f_bfaf_b9b5479822d7( self, method, url, body, headers ): body = self.fixtures.load("bgp_session_get.json") + return (httplib.OK, body, {}, httplib.responses[httplib.OK]) def _metal_v1_projects_4b653fce_6405_4300_9f7d_c587b7888fe5_bgp_sessions( @@ -421,6 +452,7 @@ class EquinixMetalMockHttp(MockHttp): ): if method == "GET": body = self.fixtures.load("bgp_sessions.json") + return (httplib.OK, body, {}, httplib.responses[httplib.OK]) def _metal_v1_devices_905037a4_967c_4e81_b364_3a0603aa071b_bgp_sessions( @@ -428,6 +460,7 @@ class EquinixMetalMockHttp(MockHttp): ): if method == "GET": body = self.fixtures.load("bgp_sessions.json") + return (httplib.OK, body, {}, httplib.responses[httplib.OK]) def _metal_v1_projects_4a4bce6b_d2ef_41f8_95cf_0e2f32996440_bgp_sessions( @@ -435,6 +468,7 @@ class EquinixMetalMockHttp(MockHttp): ): if method == "GET": body = self.fixtures.load("bgp_sessions.json") + return (httplib.OK, body, {}, httplib.responses[httplib.OK]) def _metal_v1_projects_3d27fd13_0466_4878_be22_9a4b5595a3df_bgp_sessions( @@ -442,6 +476,7 @@ class EquinixMetalMockHttp(MockHttp): ): if method == "GET": body = self.fixtures.load("bgp_sessions.json") + return (httplib.OK, body, {}, httplib.responses[httplib.OK]) def _metal_v1_projects_3d27fd13_0466_4878_be22_9a4b5595a3df_events( @@ -449,6 +484,7 @@ class EquinixMetalMockHttp(MockHttp): ): if method == "GET": body = self.fixtures.load("project_events.json") + return (httplib.OK, body, {}, httplib.responses[httplib.OK]) def _metal_v1_devices_905037a4_967c_4e81_b364_3a0603aa071b_events( @@ -456,6 +492,7 @@ class EquinixMetalMockHttp(MockHttp): ): if method == "GET": body = self.fixtures.load("device_events.json") + return (httplib.OK, body, {}, httplib.responses[httplib.OK]) def _metal_v1_devices_1e52437e_bbbb_cccc_dddd_74a9dfd3d3bb_bandwidth( @@ -463,10 +500,12 @@ class EquinixMetalMockHttp(MockHttp): ): if method == "GET": body = self.fixtures.load("node_bandwidth.json") + return (httplib.OK, body, {}, httplib.responses[httplib.OK]) def _metal_v1_ips_01c184f5_1413_4b0b_9f6d_ac993f6c9241(self, method, url, body, headers): body = self.fixtures.load("ip_address.json") + return (httplib.OK, body, {}, httplib.responses[httplib.OK]) def _metal_v1_devices_1e52437e_bbbb_cccc_dddd_74a9dfd3d3bb_ips( @@ -476,6 +515,7 @@ class EquinixMetalMockHttp(MockHttp): body = self.fixtures.load("ip_assignments.json") elif method == "POST": body = self.fixtures.load("associate_ip.json") + return (httplib.OK, body, {}, httplib.responses[httplib.OK]) def _metal_v1_ips_aea4ee0c_675f_4b77_8337_8e13b868dd9c(self, method, url, body, headers): @@ -489,6 +529,7 @@ class EquinixMetalMockHttp(MockHttp): body = self.fixtures.load("volumes.json") elif method == "POST": body = self.fixtures.load("create_volume.json") + return (httplib.OK, body, {}, httplib.responses[httplib.OK]) def _metal_v1_projects_4a4bce6b_d2ef_41f8_95cf_0e2f32996440_storage( @@ -496,6 +537,7 @@ class EquinixMetalMockHttp(MockHttp): ): if method == "GET": body = json.dumps({"volumes": []}) + return (httplib.OK, body, {}, httplib.responses[httplib.OK]) def _metal_v1_projects_4b653fce_6405_4300_9f7d_c587b7888fe5_storage( @@ -503,6 +545,7 @@ class EquinixMetalMockHttp(MockHttp): ): if method == "GET": body = json.dumps({"volumes": []}) + return (httplib.OK, body, {}, httplib.responses[httplib.OK]) def _metal_v1_storage_74f11291_fde8_4abf_8150_e51cda7308c3(self, method, url, body, headers): @@ -514,6 +557,7 @@ class EquinixMetalMockHttp(MockHttp): ): if method == "POST": body = self.fixtures.load("attach_volume.json") + return (httplib.OK, body, {}, httplib.responses[httplib.OK]) def _metal_v1_storage_a08aaf76_e0ce_43aa_b9cd_cce0d4ae4f4c(self, method, url, body, headers):