You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@libcloud.apache.org by to...@apache.org on 2011/03/16 23:13:14 UTC
svn commit: r1082319 - in /incubator/libcloud/trunk/test/compute:
fixtures/voxel/create_node.xml fixtures/voxel/failure.xml
fixtures/voxel/success.xml test_voxel.py
Author: tomaz
Date: Wed Mar 16 22:13:13 2011
New Revision: 1082319
URL: http://svn.apache.org/viewvc?rev=1082319&view=rev
Log:
More tests for Voxel driver.
Added:
incubator/libcloud/trunk/test/compute/fixtures/voxel/create_node.xml
incubator/libcloud/trunk/test/compute/fixtures/voxel/failure.xml
incubator/libcloud/trunk/test/compute/fixtures/voxel/success.xml
Modified:
incubator/libcloud/trunk/test/compute/test_voxel.py
Added: incubator/libcloud/trunk/test/compute/fixtures/voxel/create_node.xml
URL: http://svn.apache.org/viewvc/incubator/libcloud/trunk/test/compute/fixtures/voxel/create_node.xml?rev=1082319&view=auto
==============================================================================
--- incubator/libcloud/trunk/test/compute/fixtures/voxel/create_node.xml (added)
+++ incubator/libcloud/trunk/test/compute/fixtures/voxel/create_node.xml Wed Mar 16 22:13:13 2011
@@ -0,0 +1,7 @@
+<rsp stat="ok">
+ <device>
+ <id>1234</id>
+ <last_update>1235386846</last_update>
+ <status>QUEUED</status>
+ </device>
+</rsp>
Added: incubator/libcloud/trunk/test/compute/fixtures/voxel/failure.xml
URL: http://svn.apache.org/viewvc/incubator/libcloud/trunk/test/compute/fixtures/voxel/failure.xml?rev=1082319&view=auto
==============================================================================
--- incubator/libcloud/trunk/test/compute/fixtures/voxel/failure.xml (added)
+++ incubator/libcloud/trunk/test/compute/fixtures/voxel/failure.xml Wed Mar 16 22:13:13 2011
@@ -0,0 +1 @@
+<rsp stat="fail"/>
Added: incubator/libcloud/trunk/test/compute/fixtures/voxel/success.xml
URL: http://svn.apache.org/viewvc/incubator/libcloud/trunk/test/compute/fixtures/voxel/success.xml?rev=1082319&view=auto
==============================================================================
--- incubator/libcloud/trunk/test/compute/fixtures/voxel/success.xml (added)
+++ incubator/libcloud/trunk/test/compute/fixtures/voxel/success.xml Wed Mar 16 22:13:13 2011
@@ -0,0 +1 @@
+<rsp stat="ok"/>
Modified: incubator/libcloud/trunk/test/compute/test_voxel.py
URL: http://svn.apache.org/viewvc/incubator/libcloud/trunk/test/compute/test_voxel.py?rev=1082319&r1=1082318&r2=1082319&view=diff
==============================================================================
--- incubator/libcloud/trunk/test/compute/test_voxel.py (original)
+++ incubator/libcloud/trunk/test/compute/test_voxel.py Wed Mar 16 22:13:13 2011
@@ -16,6 +16,7 @@ import sys
import unittest
import httplib
+from libcloud.compute.base import Node, NodeSize, NodeImage, NodeLocation
from libcloud.compute.drivers.voxel import VoxelNodeDriver as Voxel
from libcloud.compute.types import InvalidCredsError
@@ -41,6 +42,16 @@ class VoxelTest(unittest.TestCase):
else:
self.fail('test should have thrown')
+ def test_response_failure(self):
+ VoxelMockHttp.type = 'FAILURE'
+
+ try:
+ self.driver.list_nodes()
+ except Exception:
+ pass
+ else:
+ self.fail('Invalid response, but exception was not thrown')
+
def test_list_nodes(self):
VoxelMockHttp.type = 'LIST_NODES'
nodes = self.driver.list_nodes()
@@ -66,14 +77,49 @@ class VoxelTest(unittest.TestCase):
self.assertEqual(len(locations), 2)
self.assertEqual(locations[0].name, 'Amsterdam')
+ def test_create_node_invalid_disk_size(self):
+ image = NodeImage(id=1, name='Ubuntu 8.10 (intrepid)', driver=self.driver)
+ size = NodeSize(1, '256 slice', None, None, None, None, driver=self.driver)
+ location = NodeLocation(id=1, name='Europe', country='England',
+ driver=self.driver)
+
+ try:
+ self.driver.create_node(name='foo', image=image, size=size,
+ location=location)
+ except ValueError:
+ pass
+ else:
+ self.fail('Invalid disk size provided but an exception was not'
+ ' thrown')
+
def test_create_node(self):
- pass
+ VoxelMockHttp.type = 'CREATE_NODE'
+ image = NodeImage(id=1, name='Ubuntu 8.10 (intrepid)', driver=self.driver)
+ size = NodeSize(1, '256 slice', 1024, 500, None, None, driver=self.driver)
+ location = NodeLocation(id=1, name='Europe', country='England',
+ driver=self.driver)
+
+ node = self.driver.create_node(name='foo', image=image, size=size,
+ location=location)
+ self.assertEqual(node.id, '1234')
+
+ node = self.driver.create_node(name='foo', image=image, size=size,
+ location=location, voxel_access=True)
+ self.assertEqual(node.id, '1234')
def test_reboot_node(self):
- pass
+ VoxelMockHttp.type = 'REBOOT_NODE'
+ node = Node(id=72258, name=None, state=None, public_ip=None, private_ip=None,
+ driver=self.driver)
+
+ self.assertTrue(node.reboot())
def test_destroy_node(self):
- pass
+ VoxelMockHttp.type = 'DESTROY_NODE'
+ node = Node(id=72258, name=None, state=None, public_ip=None, private_ip=None,
+ driver=self.driver)
+
+ self.assertTrue(node.destroy())
class VoxelMockHttp(MockHttp):
@@ -83,6 +129,10 @@ class VoxelMockHttp(MockHttp):
body = self.fixtures.load('unauthorized.xml')
return (httplib.OK, body, {}, httplib.responses[httplib.OK])
+ def _FAILURE(self, method, url, body, headers):
+ body = self.fixtures.load('failure.xml')
+ return (httplib.OK, body, {}, httplib.responses[httplib.OK])
+
def _LIST_NODES(self, method, url, body, headers):
body = self.fixtures.load('nodes.xml')
return (httplib.OK, body, {}, httplib.responses[httplib.OK])
@@ -95,5 +145,17 @@ class VoxelMockHttp(MockHttp):
body = self.fixtures.load('locations.xml')
return (httplib.OK, body, {}, httplib.responses[httplib.OK])
+ def _CREATE_NODE(self, method, url, body, headers):
+ body = self.fixtures.load('create_node.xml')
+ return (httplib.OK, body, {}, httplib.responses[httplib.OK])
+
+ def _REBOOT_NODE(self, method, url, body, headers):
+ body = self.fixtures.load('success.xml')
+ return (httplib.OK, body, {}, httplib.responses[httplib.OK])
+
+ def _DESTROY_NODE(self, method, url, body, headers):
+ body = self.fixtures.load('success.xml')
+ return (httplib.OK, body, {}, httplib.responses[httplib.OK])
+
if __name__ == '__main__':
sys.exit(unittest.main())