Add a test for gce MIG with shared network Signed-off-by: Quentin Pradet <[email protected]>
Project: http://git-wip-us.apache.org/repos/asf/libcloud/repo Commit: http://git-wip-us.apache.org/repos/asf/libcloud/commit/fa2b484d Tree: http://git-wip-us.apache.org/repos/asf/libcloud/tree/fa2b484d Diff: http://git-wip-us.apache.org/repos/asf/libcloud/diff/fa2b484d Branch: refs/heads/trunk Commit: fa2b484db337bde0b839228ebe91965279422b56 Parents: 51cd3e5 Author: Boris Chazalet <[email protected]> Authored: Thu Mar 8 14:22:07 2018 +0100 Committer: Quentin Pradet <[email protected]> Committed: Sat Mar 10 08:27:06 2018 +0400 ---------------------------------------------------------------------- ...tes_my_instance_template_shared_network.json | 61 ++++++++++++++++++++ libcloud/test/compute/test_gce.py | 19 ++++++ 2 files changed, 80 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/libcloud/blob/fa2b484d/libcloud/test/compute/fixtures/gce/global_instanceTemplates_my_instance_template_shared_network.json ---------------------------------------------------------------------- diff --git a/libcloud/test/compute/fixtures/gce/global_instanceTemplates_my_instance_template_shared_network.json b/libcloud/test/compute/fixtures/gce/global_instanceTemplates_my_instance_template_shared_network.json new file mode 100644 index 0000000..e2a97cd --- /dev/null +++ b/libcloud/test/compute/fixtures/gce/global_instanceTemplates_my_instance_template_shared_network.json @@ -0,0 +1,61 @@ +{ + "creationTimestamp": "2016-07-18T09:53:22.323-07:00", + "description": "", + "id": "8161922600535111533", + "kind": "compute#instanceTemplate", + "name": "my-instance-template_shared_network", + "properties": { + "canIpForward": false, + "disks": [ + { + "autoDelete": true, + "boot": true, + "deviceName": "my-instance-template_shared_network", + "initializeParams": { + "diskSizeGb": "10", + "diskType": "pd-standard", + "sourceImage": "projects/project_name/global/images/my-new-image1" + }, + "kind": "compute#attachedDisk", + "mode": "READ_WRITE", + "type": "PERSISTENT" + } + ], + "machineType": "n1-standard-1", + "metadata": { + "fingerprint": "Jt9ALJ07B8Q=", + "kind": "compute#metadata" + }, + "networkInterfaces": [ + { + "accessConfigs": [ + { + "kind": "compute#accessConfig", + "name": "External NAT", + "type": "ONE_TO_ONE_NAT" + } + ], + "network": "https://www.googleapis.com/compute/v1/projects/other_name/global/networks/cf", + "subnetwork": "https://www.googleapis.com/compute/v1/projects/other_name/regions/us-central1/subnetworks/cf-972cf02e6ad49112" + } + ], + "scheduling": { + "automaticRestart": true, + "onHostMaintenance": "MIGRATE", + "preemptible": false + }, + "serviceAccounts": [ + { + "email": "default", + "scopes": [ + "https://www.googleapis.com/auth/devstorage.read_only", + "https://www.googleapis.com/auth/logging.write", + "https://www.googleapis.com/auth/monitoring.write", + "https://www.googleapis.com/auth/servicecontrol", + "https://www.googleapis.com/auth/service.management" + ] + } + ] + }, + "selfLink": "https://content.googleapis.com/compute/v1/projects/project_name/global/instanceTemplates/my-instance-template_shared_network" +} http://git-wip-us.apache.org/repos/asf/libcloud/blob/fa2b484d/libcloud/test/compute/test_gce.py ---------------------------------------------------------------------- diff --git a/libcloud/test/compute/test_gce.py b/libcloud/test/compute/test_gce.py index a0e87b9..657c5cc 100644 --- a/libcloud/test/compute/test_gce.py +++ b/libcloud/test/compute/test_gce.py @@ -461,6 +461,19 @@ class GCENodeDriverTest(GoogleTestCase, TestCaseMixin): self.assertEqual(mig.size, size) self.assertEqual(mig.zone.name, zone) + def test_ex_create_instancegroupmanager_shared_network(self): + name = 'myinstancegroup' + zone = 'us-central1-a' + size = 4 + template_name = 'my-instance-template-shared-network' + template = self.driver.ex_get_instancetemplate(template_name) + mig = self.driver.ex_create_instancegroupmanager( + name, zone, template, size, base_instance_name='base-foo') + + self.assertEqual(mig.name, name) + self.assertEqual(mig.size, size) + self.assertEqual(mig.zone.name, zone) + def test_ex_create_instancetemplate(self): name = 'my-instance-template1' actual = self.driver.ex_create_instancetemplate( @@ -3548,6 +3561,12 @@ class GCEMockHttp(MockHttp): 'global_instanceTemplates_my_instance_template1.json') return (httplib.OK, body, self.json_hdr, httplib.responses[httplib.OK]) + def _global_instanceTemplates_my_instance_template_shared_network(self, method, url, + body, headers): + body = self.fixtures.load( + 'global_instanceTemplates_my_instance_template_shared_network.json') + return (httplib.OK, body, self.json_hdr, httplib.responses[httplib.OK]) + def _aggregated_autoscalers(self, method, url, body, headers): body = self.fixtures.load('aggregated_autoscalers.json') return (httplib.OK, body, self.json_hdr, httplib.responses[httplib.OK])
