From ce8c371aa7b961e9c257e324df36fa4010b89d9e Mon Sep 17 00:00:00 2001 From: Aymeric Barantal Date: Wed, 21 Sep 2011 12:58:25 +0200 Subject: [PATCH 5/7] simple test for ex_* methods --- test/compute/fixtures/gandi/disk_attach.xml | 53 +++++++ test/compute/fixtures/gandi/disk_detach.xml | 53 +++++++ test/compute/fixtures/gandi/disk_list.xml | 200 ++++++++++++++++++++++++++ test/compute/fixtures/gandi/iface_attach.xml | 53 +++++++ test/compute/fixtures/gandi/iface_detach.xml | 53 +++++++ test/compute/fixtures/gandi/iface_list.xml | 99 +++++++++++++ test/compute/test_gandi.py | 56 +++++++ 7 files changed, 567 insertions(+), 0 deletions(-) create mode 100644 test/compute/fixtures/gandi/disk_attach.xml create mode 100644 test/compute/fixtures/gandi/disk_detach.xml create mode 100644 test/compute/fixtures/gandi/disk_list.xml create mode 100644 test/compute/fixtures/gandi/iface_attach.xml create mode 100644 test/compute/fixtures/gandi/iface_detach.xml create mode 100644 test/compute/fixtures/gandi/iface_list.xml diff --git a/test/compute/fixtures/gandi/disk_attach.xml b/test/compute/fixtures/gandi/disk_attach.xml new file mode 100644 index 0000000..88e1c2a --- /dev/null +++ b/test/compute/fixtures/gandi/disk_attach.xml @@ -0,0 +1,53 @@ + + + + + + +iface_id + + + +date_updated +20110921T12:57:05 + + +vm_id +250133 + + +date_start + + + +disk_id +34918 + + +source +AB3917-GANDI + + +step +WAIT + + +ip_id + + + +date_created +20110921T12:57:05 + + +type +disk_attach + + +id +657982 + + + + + \ No newline at end of file diff --git a/test/compute/fixtures/gandi/disk_detach.xml b/test/compute/fixtures/gandi/disk_detach.xml new file mode 100644 index 0000000..388ad6d --- /dev/null +++ b/test/compute/fixtures/gandi/disk_detach.xml @@ -0,0 +1,53 @@ + + + + + + +iface_id + + + +date_updated +20110921T12:57:35 + + +vm_id +250133 + + +date_start + + + +disk_id +34918 + + +source +AB3917-GANDI + + +step +WAIT + + +ip_id + + + +date_created +20110921T12:57:35 + + +type +disk_detach + + +id +657983 + + + + + \ No newline at end of file diff --git a/test/compute/fixtures/gandi/disk_list.xml b/test/compute/fixtures/gandi/disk_list.xml new file mode 100644 index 0000000..5af7613 --- /dev/null +++ b/test/compute/fixtures/gandi/disk_list.xml @@ -0,0 +1,200 @@ + + + + + + + +datacenter_id +1 + + +name +disk_libcloud2 + + +kernel_version +2.6.32 + + +can_snapshot +0 + + +visibility +private + + +label +Debian 5 + + +vms_id + + + + +source +23351 + + +state +created + + +is_boot_disk +0 + + +date_updated +20101116T10:51:59 + + +date_created +20101028T13:52:38 + + +type +data + + +id +34918 + + +size +3072 + + + + +datacenter_id +1 + + +name +test1 + + +kernel_version +2.6.32 + + +can_snapshot + + + +visibility +private + + +label +Debian 5 + + +vms_id + +250133 + + + +source +23351 + + +state +created + + +is_boot_disk +1 + + +date_updated +20110120T15:02:01 + + +date_created +20110120T14:57:55 + + +type +data + + +id +34951 + + +size +3072 + + + + +datacenter_id +1 + + +name +test_disk + + +kernel_version +2.6.32 + + +can_snapshot +1 + + +visibility +private + + +label +Debian 5 + + +vms_id + +250288 + + + +source +23351 + + +state +created + + +is_boot_disk +1 + + +date_updated +20110325T16:31:11 + + +date_created +20110324T17:14:06 + + +type +data + + +id +35170 + + +size +3072 + + + + + + \ No newline at end of file diff --git a/test/compute/fixtures/gandi/iface_attach.xml b/test/compute/fixtures/gandi/iface_attach.xml new file mode 100644 index 0000000..33856c1 --- /dev/null +++ b/test/compute/fixtures/gandi/iface_attach.xml @@ -0,0 +1,53 @@ + + + + + + +iface_id +7857 + + +date_updated +20110921T12:49:35 + + +vm_id +250133 + + +date_start + + + +disk_id + + + +source +AB3917-GANDI + + +step +WAIT + + +ip_id + + + +date_created +20110921T12:49:35 + + +type +iface_attach + + +id +657980 + + + + + \ No newline at end of file diff --git a/test/compute/fixtures/gandi/iface_detach.xml b/test/compute/fixtures/gandi/iface_detach.xml new file mode 100644 index 0000000..f5080d9 --- /dev/null +++ b/test/compute/fixtures/gandi/iface_detach.xml @@ -0,0 +1,53 @@ + + + + + + +iface_id +7857 + + +date_updated +20110921T12:53:29 + + +vm_id +250133 + + +date_start + + + +disk_id + + + +source +AB3917-GANDI + + +step +WAIT + + +ip_id + + + +date_created +20110921T12:53:29 + + +type +iface_detach + + +id +657981 + + + + + \ No newline at end of file diff --git a/test/compute/fixtures/gandi/iface_list.xml b/test/compute/fixtures/gandi/iface_list.xml new file mode 100644 index 0000000..ba530a6 --- /dev/null +++ b/test/compute/fixtures/gandi/iface_list.xml @@ -0,0 +1,99 @@ + + + + + + + +date_updated +20110120T14:58:44 + + +vm_id +250133 + + +bandwidth +5120.0 + + +datacenter_id +1 + + +state +used + + +num +0 + + +ips_id + +9256 +9294 + + + +date_created +20110120T14:57:55 + + +type +public + + +id +7857 + + + + +date_updated +20110324T17:14:16 + + +vm_id +250288 + + +bandwidth +5192.0 + + +datacenter_id +1 + + +state +used + + +num +0 + + +ips_id + +9298 +9508 + + + +date_created +20110324T17:14:06 + + +type +public + + +id +8019 + + + + + + \ No newline at end of file diff --git a/test/compute/test_gandi.py b/test/compute/test_gandi.py index 2dd83bc..6c53d65 100644 --- a/test/compute/test_gandi.py +++ b/test/compute/test_gandi.py @@ -105,6 +105,38 @@ class GandiTests(unittest.TestCase): password=passwd, image=img, location=loc, size=size) self.assertEqual(node.name, self.node_name) + def test_ex_list_disks(self): + disks = self.driver.ex_list_disks() + self.assertTrue(len(disks) > 0) + + def test_ex_list_interfaces(self): + ifaces = self.driver.ex_list_interfaces() + self.assertTrue(len(ifaces) > 0) + + def test_ex_attach_interface(self): + ifaces = self.driver.ex_list_interfaces() + nodes = self.driver.list_nodes() + res = self.driver.ex_attach_interface(ifaces[0], nodes[0]) + self.assertTrue(res) + + def test_ex_detach_interface(self): + ifaces = self.driver.ex_list_interfaces() + nodes = self.driver.list_nodes() + res = self.driver.ex_detach_interface(ifaces[0], nodes[0]) + self.assertTrue(res) + + def test_ex_attach_disk(self): + disks = self.driver.ex_list_disks() + nodes = self.driver.list_nodes() + res = self.driver.ex_attach_disk(disks[0], nodes[0]) + self.assertTrue(res) + + def test_ex_detach_disk(self): + disks = self.driver.ex_list_disks() + nodes = self.driver.list_nodes() + res = self.driver.ex_detach_disk(disks[0], nodes[0]) + self.assertTrue(res) + class GandiMockHttp(MockHttp): @@ -154,5 +186,29 @@ class GandiMockHttp(MockHttp): body = self.fixtures.load('vm_stop.xml') return (httplib.OK, body, {}, httplib.responses[httplib.OK]) + def _xmlrpc_2_0__iface_list(self, method, url, body, headers): + body = self.fixtures.load('iface_list.xml') + return (httplib.OK, body, {}, httplib.responses[httplib.OK]) + + def _xmlrpc_2_0__disk_list(self, method, url, body, headers): + body = self.fixtures.load('disk_list.xml') + return (httplib.OK, body, {}, httplib.responses[httplib.OK]) + + def _xmlrpc_2_0__vm_iface_attach(self, method, url, body, headers): + body = self.fixtures.load('iface_attach.xml') + return (httplib.OK, body, {}, httplib.responses[httplib.OK]) + + def _xmlrpc_2_0__vm_iface_detach(self, method, url, body, headers): + body = self.fixtures.load('iface_detach.xml') + return (httplib.OK, body, {}, httplib.responses[httplib.OK]) + + def _xmlrpc_2_0__vm_disk_attach(self, method, url, body, headers): + body = self.fixtures.load('disk_attach.xml') + return (httplib.OK, body, {}, httplib.responses[httplib.OK]) + + def _xmlrpc_2_0__vm_disk_detach(self, method, url, body, headers): + body = self.fixtures.load('disk_detach.xml') + return (httplib.OK, body, {}, httplib.responses[httplib.OK]) + if __name__ == '__main__': sys.exit(unittest.main()) -- 1.7.6.1