libcloud-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From to...@apache.org
Subject [10/44] git commit: Tests for Snapshots (plus fix for list_targetpools test)
Date Fri, 03 Jan 2014 14:59:22 GMT
Tests for Snapshots (plus fix for list_targetpools test)


Project: http://git-wip-us.apache.org/repos/asf/libcloud/repo
Commit: http://git-wip-us.apache.org/repos/asf/libcloud/commit/ea7662ac
Tree: http://git-wip-us.apache.org/repos/asf/libcloud/tree/ea7662ac
Diff: http://git-wip-us.apache.org/repos/asf/libcloud/diff/ea7662ac

Branch: refs/heads/trunk
Commit: ea7662ac4909b72a837ebbd54cd61baee770d2f0
Parents: a0aa455
Author: Rick Wright <rickw@google.com>
Authored: Mon Dec 16 13:28:33 2013 -0800
Committer: Rick Wright <rickw@google.com>
Committed: Mon Dec 16 13:28:33 2013 -0800

----------------------------------------------------------------------
 .../compute/fixtures/gce/global_snapshots.json  | 31 +++++++++
 .../gce/global_snapshots_lcsnapshot.json        | 12 ++++
 .../gce/global_snapshots_lcsnapshot_delete.json | 14 ++++
 ...tion_global_snapshots_lcsnapshot_delete.json | 15 +++++
 ...ral1-a_disks_lcdisk_createSnapshot_post.json | 16 +++++
 ...ral1-a_disks_lcdisk_createSnapshot_post.json | 15 +++++
 libcloud/test/compute/test_gce.py               | 70 ++++++++++++++++++--
 7 files changed, 167 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/libcloud/blob/ea7662ac/libcloud/test/compute/fixtures/gce/global_snapshots.json
----------------------------------------------------------------------
diff --git a/libcloud/test/compute/fixtures/gce/global_snapshots.json b/libcloud/test/compute/fixtures/gce/global_snapshots.json
new file mode 100644
index 0000000..d839107
--- /dev/null
+++ b/libcloud/test/compute/fixtures/gce/global_snapshots.json
@@ -0,0 +1,31 @@
+{
+  "id": "projects/project_name/global/snapshots",
+  "items": [
+    {
+      "creationTimestamp": "2013-12-16T13:03:51.345-08:00",
+      "description": "",
+      "diskSizeGb": "1",
+      "id": "17482266715940883688",
+      "kind": "compute#snapshot",
+      "name": "lcsnapshot",
+      "selfLink": "https://www.googleapis.com/compute/v1/projects/project_name/global/snapshots/lcsnapshot",
+      "sourceDisk": "https://www.googleapis.com/compute/v1/projects/project_name/zones/us-central1-a/disks/lcdisk",
+      "sourceDiskId": "-2511816066479461182",
+      "status": "READY"
+    },
+    {
+      "creationTimestamp": "2013-12-16T12:48:12.557-08:00",
+      "description": "",
+      "diskSizeGb": "10",
+      "id": "3341332334980930052",
+      "kind": "compute#snapshot",
+      "name": "libcloud-demo-snapshot",
+      "selfLink": "https://www.googleapis.com/compute/v1/projects/project_name/global/snapshots/libcloud-demo-snapshot",
+      "sourceDisk": "https://www.googleapis.com/compute/v1/projects/project_name/zones/us-central2-a/disks/libcloud-demo-snap-template",
+      "sourceDiskId": "-6245698478147030397",
+      "status": "READY"
+    }
+  ],
+  "kind": "compute#snapshotList",
+  "selfLink": "https://www.googleapis.com/compute/v1/projects/project_name/global/snapshots"
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/libcloud/blob/ea7662ac/libcloud/test/compute/fixtures/gce/global_snapshots_lcsnapshot.json
----------------------------------------------------------------------
diff --git a/libcloud/test/compute/fixtures/gce/global_snapshots_lcsnapshot.json b/libcloud/test/compute/fixtures/gce/global_snapshots_lcsnapshot.json
new file mode 100644
index 0000000..9b071a9
--- /dev/null
+++ b/libcloud/test/compute/fixtures/gce/global_snapshots_lcsnapshot.json
@@ -0,0 +1,12 @@
+{
+  "creationTimestamp": "2013-12-16T13:03:51.345-08:00",
+  "description": "",
+  "diskSizeGb": "1",
+  "id": "17482266715940883688",
+  "kind": "compute#snapshot",
+  "name": "lcsnapshot",
+  "selfLink": "https://www.googleapis.com/compute/v1/projects/project_name/global/snapshots/lcsnapshot",
+  "sourceDisk": "https://www.googleapis.com/compute/v1/projects/project_name/zones/us-central1-a/disks/lcdisk",
+  "sourceDiskId": "-2511816066479461182",
+  "status": "READY"
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/libcloud/blob/ea7662ac/libcloud/test/compute/fixtures/gce/global_snapshots_lcsnapshot_delete.json
----------------------------------------------------------------------
diff --git a/libcloud/test/compute/fixtures/gce/global_snapshots_lcsnapshot_delete.json b/libcloud/test/compute/fixtures/gce/global_snapshots_lcsnapshot_delete.json
new file mode 100644
index 0000000..59cd70c
--- /dev/null
+++ b/libcloud/test/compute/fixtures/gce/global_snapshots_lcsnapshot_delete.json
@@ -0,0 +1,14 @@
+{
+  "id": "5994251357251874363",
+  "insertTime": "2013-12-16T13:04:03.831-08:00",
+  "kind": "compute#operation",
+  "name": "operation-global_snapshots_lcsnapshot_delete",
+  "operationType": "delete",
+  "progress": 0,
+  "selfLink": "https://www.googleapis.com/compute/v1/projects/project_name/global/operations/operation-global_snapshots_lcsnapshot_delete",
+  "startTime": "2013-12-16T13:04:03.924-08:00",
+  "status": "PENDING",
+  "targetId": "17482266715940883688",
+  "targetLink": "https://www.googleapis.com/compute/v1/projects/project_name/global/snapshots/lcsnapshot",
+  "user": "487551519631-t6qvu2na6p4u9ptm46bsdujf0ohbdro7@developer.gserviceaccount.com"
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/libcloud/blob/ea7662ac/libcloud/test/compute/fixtures/gce/operations_operation_global_snapshots_lcsnapshot_delete.json
----------------------------------------------------------------------
diff --git a/libcloud/test/compute/fixtures/gce/operations_operation_global_snapshots_lcsnapshot_delete.json
b/libcloud/test/compute/fixtures/gce/operations_operation_global_snapshots_lcsnapshot_delete.json
new file mode 100644
index 0000000..e869f26
--- /dev/null
+++ b/libcloud/test/compute/fixtures/gce/operations_operation_global_snapshots_lcsnapshot_delete.json
@@ -0,0 +1,15 @@
+{
+  "endTime": "2013-12-16T13:04:11.565-08:00",
+  "id": "5994251357251874363",
+  "insertTime": "2013-12-16T13:04:03.831-08:00",
+  "kind": "compute#operation",
+  "name": "operation-global_snapshots_lcsnapshot_delete",
+  "operationType": "delete",
+  "progress": 100,
+  "selfLink": "https://www.googleapis.com/compute/v1/projects/project_name/global/operations/operation-global_snapshots_lcsnapshot_delete",
+  "startTime": "2013-12-16T13:04:03.924-08:00",
+  "status": "DONE",
+  "targetId": "17482266715940883688",
+  "targetLink": "https://www.googleapis.com/compute/v1/projects/project_name/global/snapshots/lcsnapshot",
+  "user": "487551519631-t6qvu2na6p4u9ptm46bsdujf0ohbdro7@developer.gserviceaccount.com"
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/libcloud/blob/ea7662ac/libcloud/test/compute/fixtures/gce/operations_operation_zones_us-central1-a_disks_lcdisk_createSnapshot_post.json
----------------------------------------------------------------------
diff --git a/libcloud/test/compute/fixtures/gce/operations_operation_zones_us-central1-a_disks_lcdisk_createSnapshot_post.json
b/libcloud/test/compute/fixtures/gce/operations_operation_zones_us-central1-a_disks_lcdisk_createSnapshot_post.json
new file mode 100644
index 0000000..f765ebf
--- /dev/null
+++ b/libcloud/test/compute/fixtures/gce/operations_operation_zones_us-central1-a_disks_lcdisk_createSnapshot_post.json
@@ -0,0 +1,16 @@
+{
+  "endTime": "2013-12-16T13:04:01.580-08:00",
+  "id": "0158330665043557584",
+  "insertTime": "2013-12-16T13:03:51.000-08:00",
+  "kind": "compute#operation",
+  "name": "operation-zones_us-central1-a_disks_lcdisk_createSnapshot_post",
+  "operationType": "createSnapshot",
+  "progress": 100,
+  "selfLink": "https://www.googleapis.com/compute/v1/projects/project_name/zones/us-central1-a/operations/operation-zones_us-central1-a_disks_lcdisk_createSnapshot_post",
+  "startTime": "2013-12-16T13:03:51.042-08:00",
+  "status": "DONE",
+  "targetId": "07494414044179227172",
+  "targetLink": "https://www.googleapis.com/compute/v1/projects/project_name/zones/us-central1-a/disks/lcdisk",
+  "user": "487551519631-t6qvu2na6p4u9ptm46bsdujf0ohbdro7@developer.gserviceaccount.com",
+  "zone": "https://www.googleapis.com/compute/v1/projects/project_name/zones/us-central1-a"
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/libcloud/blob/ea7662ac/libcloud/test/compute/fixtures/gce/zones_us-central1-a_disks_lcdisk_createSnapshot_post.json
----------------------------------------------------------------------
diff --git a/libcloud/test/compute/fixtures/gce/zones_us-central1-a_disks_lcdisk_createSnapshot_post.json
b/libcloud/test/compute/fixtures/gce/zones_us-central1-a_disks_lcdisk_createSnapshot_post.json
new file mode 100644
index 0000000..97be56a
--- /dev/null
+++ b/libcloud/test/compute/fixtures/gce/zones_us-central1-a_disks_lcdisk_createSnapshot_post.json
@@ -0,0 +1,15 @@
+{
+  "id": "0158330665043557584",
+  "insertTime": "2013-12-16T13:03:51.000-08:00",
+  "kind": "compute#operation",
+  "name": "operation-zones_us-central1-a_disks_lcdisk_createSnapshot_post",
+  "operationType": "createSnapshot",
+  "progress": 0,
+  "selfLink": "https://www.googleapis.com/compute/v1/projects/project_name/zones/us-central1-a/operations/operation-zones_us-central1-a_disks_lcdisk_createSnapshot_post",
+  "startTime": "2013-12-16T13:03:51.042-08:00",
+  "status": "PENDING",
+  "targetId": "07494414044179227172",
+  "targetLink": "https://www.googleapis.com/compute/v1/projects/project_name/zones/us-central1-a/disks/lcdisk",
+  "user": "487551519631-t6qvu2na6p4u9ptm46bsdujf0ohbdro7@developer.gserviceaccount.com",
+  "zone": "https://www.googleapis.com/compute/v1/projects/project_name/zones/us-central1-a"
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/libcloud/blob/ea7662ac/libcloud/test/compute/test_gce.py
----------------------------------------------------------------------
diff --git a/libcloud/test/compute/test_gce.py b/libcloud/test/compute/test_gce.py
index 3462f64..31f35bf 100644
--- a/libcloud/test/compute/test_gce.py
+++ b/libcloud/test/compute/test_gce.py
@@ -168,15 +168,20 @@ class GCENodeDriverTest(LibcloudTestCase, TestCaseMixin):
         self.assertEqual(len(regions), 3)
         self.assertEqual(regions[0].name, 'europe-west1')
 
-    def ex_list_targetpools(self):
+    def test_ex_list_snapshots(self):
+        snapshots = self.driver.ex_list_snapshots()
+        self.assertEqual(len(snapshots), 2)
+        self.assertEqual(snapshots[0].name, 'lcsnapshot')
+
+    def test_ex_list_targetpools(self):
         target_pools = self.driver.ex_list_targetpools()
         target_pools_all = self.driver.ex_list_targetpools('all')
         target_pools_uc1 = self.driver.ex_list_targetpools('us-central1')
-        self.assertEqual(len(target_pools), 3)
-        self.assertEqual(len(target_pools_all), 4)
-        self.assertEqual(len(target_pools_uc1), 3)
-        self.assertEqual(target_pools[0].name, 'www-pool')
-        self.assertEqual(target_pools_uc1[0].name, 'www-pool')
+        self.assertEqual(len(target_pools), 2)
+        self.assertEqual(len(target_pools_all), 3)
+        self.assertEqual(len(target_pools_uc1), 2)
+        self.assertEqual(target_pools[0].name, 'lctargetpool')
+        self.assertEqual(target_pools_uc1[0].name, 'lctargetpool')
         names = [t.name for t in target_pools_all]
         self.assertTrue('www-pool' in names)
 
@@ -319,6 +324,13 @@ class GCENodeDriverTest(LibcloudTestCase, TestCaseMixin):
         self.assertEqual(len(targetpool.nodes), len(nodes))
         self.assertEqual(targetpool.region.name, region)
 
+    def test_ex_create_volume_snapshot(self):
+        snapshot_name = 'lcsnapshot'
+        volume = self.driver.ex_get_volume('lcdisk')
+        snapshot = volume.snapshot(snapshot_name)
+        self.assertEqual(snapshot.name, snapshot_name)
+        self.assertEqual(snapshot.size, '1')
+
     def test_create_volume(self):
         volume_name = 'lcdisk'
         size = 1
@@ -442,6 +454,11 @@ class GCENodeDriverTest(LibcloudTestCase, TestCaseMixin):
         destroyed = disk.destroy()
         self.assertTrue(destroyed)
 
+    def test_destroy_volume_snapshot(self):
+        snapshot = self.driver.ex_get_snapshot('lcsnapshot')
+        destroyed = snapshot.destroy()
+        self.assertTrue(destroyed)
+
     def test_ex_get_address(self):
         address_name = 'lcaddress'
         address = self.driver.ex_get_address(address_name)
@@ -535,6 +552,13 @@ class GCENodeDriverTest(LibcloudTestCase, TestCaseMixin):
         self.assertEqual(len(targetpool.nodes), 2)
         self.assertEqual(targetpool.region.name, 'us-central1')
 
+    def test_ex_get_snapshot(self):
+        snapshot_name = 'lcsnapshot'
+        snapshot = self.driver.ex_get_snapshot(snapshot_name)
+        self.assertEqual(snapshot.name, snapshot_name)
+        self.assertEqual(snapshot.size, '1')
+        self.assertEqual(snapshot.status, 'READY')
+
     def test_ex_get_volume(self):
         volume_name = 'lcdisk'
         volume = self.driver.ex_get_volume(volume_name)
@@ -593,6 +617,10 @@ class GCEMockHttp(MockHttpTestCase):
         body = self.fixtures.load('aggregated_machineTypes.json')
         return (httplib.OK, body, self.json_hdr, httplib.responses[httplib.OK])
 
+    def _aggregated_targetPools(self, method, url, body, headers):
+        body = self.fixtures.load('aggregated_targetPools.json')
+        return (httplib.OK, body, self.json_hdr, httplib.responses[httplib.OK])
+
     def _global_httpHealthChecks(self, method, url, body, headers):
         if method == 'POST':
             body = self.fixtures.load('global_httpHealthChecks_post.json')
@@ -673,6 +701,18 @@ class GCEMockHttp(MockHttpTestCase):
             body = self.fixtures.load('global_networks_lcnetwork.json')
         return (httplib.OK, body, self.json_hdr, httplib.responses[httplib.OK])
 
+    def _global_snapshots(self, method, url, body, headers):
+        body = self.fixtures.load('global_snapshots.json')
+        return (httplib.OK, body, self.json_hdr, httplib.responses[httplib.OK])
+
+    def _global_snapshots_lcsnapshot(self, method, url, body, headers):
+        if method == 'DELETE':
+            body = self.fixtures.load(
+                'global_snapshots_lcsnapshot_delete.json')
+        else:
+            body = self.fixtures.load('global_snapshots_lcsnapshot.json')
+        return (httplib.OK, body, self.json_hdr, httplib.responses[httplib.OK])
+
     def _global_operations_operation_global_httpHealthChecks_lchealthcheck_delete(
             self, method, url, body, headers):
         body = self.fixtures.load(
@@ -721,6 +761,12 @@ class GCEMockHttp(MockHttpTestCase):
             'operations_operation_global_networks_post.json')
         return (httplib.OK, body, self.json_hdr, httplib.responses[httplib.OK])
 
+    def _global_operations_operation_global_snapshots_lcsnapshot_delete(
+            self, method, url, body, headers):
+        body = self.fixtures.load(
+            'operations_operation_global_snapshots_lcsnapshot_delete.json')
+        return (httplib.OK, body, self.json_hdr, httplib.responses[httplib.OK])
+
     def _regions_us_central1_operations_operation_regions_us_central1_addresses_lcaddress_delete(
             self, method, url, body, headers):
         body = self.fixtures.load(
@@ -787,6 +833,12 @@ class GCEMockHttp(MockHttpTestCase):
             'operations_operation_zones_us-central1-a_disks_lcdisk_delete.json')
         return (httplib.OK, body, self.json_hdr, httplib.responses[httplib.OK])
 
+    def _zones_us_central1_a_operations_operation_zones_us_central1_a_disks_lcdisk_createSnapshot_post(
+            self, method, url, body, headers):
+        body = self.fixtures.load(
+            'operations_operation_zones_us-central1-a_disks_lcdisk_createSnapshot_post.json')
+        return (httplib.OK, body, self.json_hdr, httplib.responses[httplib.OK])
+
     def _zones_us_central1_a_operations_operation_zones_us_central1_a_disks_post(
             self, method, url, body, headers):
         body = self.fixtures.load(
@@ -970,6 +1022,12 @@ class GCEMockHttp(MockHttpTestCase):
             body = self.fixtures.load('zones_us-central1-a_disks_lcdisk.json')
         return (httplib.OK, body, self.json_hdr, httplib.responses[httplib.OK])
 
+    def _zones_us_central1_a_disks_lcdisk_createSnapshot(self, method, url,
+                                                         body, headers):
+        body = self.fixtures.load(
+            'zones_us-central1-a_disks_lcdisk_createSnapshot_post.json')
+        return (httplib.OK, body, self.json_hdr, httplib.responses[httplib.OK])
+
     def _zones_us_central1_a_disks_node_name(self, method, url, body, headers):
         body = self.fixtures.load('generic_disk.json')
         return (httplib.OK, body, self.json_hdr, httplib.responses[httplib.OK])


Mime
View raw message