Justin Shepherd | 0d9bbd1 | 2011-08-11 12:57:44 -0500 | [diff] [blame] | 1 | # vim: tabstop=4 shiftwidth=4 softtabstop=4 |
| 2 | |
| 3 | # Copyright 2011 OpenStack, LLC |
| 4 | # All Rights Reserved. |
| 5 | # |
| 6 | # Licensed under the Apache License, Version 2.0 (the "License"); you may |
| 7 | # not use this file except in compliance with the License. You may obtain |
| 8 | # a copy of the License at |
| 9 | # |
| 10 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 11 | # |
| 12 | # Unless required by applicable law or agreed to in writing, software |
| 13 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
| 14 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the |
| 15 | # License for the specific language governing permissions and limitations |
| 16 | # under the License. |
| 17 | |
| 18 | """Functional test case that utilizes cURL against the API server""" |
| 19 | |
Justin Shepherd | 0d9bbd1 | 2011-08-11 12:57:44 -0500 | [diff] [blame] | 20 | import httplib2 |
Justin Shepherd | 0d9bbd1 | 2011-08-11 12:57:44 -0500 | [diff] [blame] | 21 | |
| 22 | from pprint import pprint |
| 23 | |
Soren Hansen | ec3f709 | 2011-09-08 13:03:42 +0200 | [diff] [blame] | 24 | from kong import tests |
Justin Shepherd | 0d9bbd1 | 2011-08-11 12:57:44 -0500 | [diff] [blame] | 25 | |
| 26 | |
| 27 | class TestCleanUp(tests.FunctionalTest): |
| 28 | def test_995_delete_server(self): |
| 29 | path = "http://%s:%s/%s/servers/%s" % (self.nova['host'], |
| 30 | self.nova['port'], |
| 31 | self.nova['ver'], |
| 32 | self.nova['single_server_id']) |
| 33 | http = httplib2.Http() |
| 34 | headers = {'X-Auth-User': '%s' % (self.nova['user']), |
| 35 | 'X-Auth-Token': '%s' % (self.nova['X-Auth-Token'])} |
| 36 | response, content = http.request(path, 'DELETE', headers=headers) |
Justin Shepherd | b5ac32f | 2011-08-17 10:57:14 -0500 | [diff] [blame] | 37 | self.assertEqual(response.status, 202) |
Justin Shepherd | 0d9bbd1 | 2011-08-11 12:57:44 -0500 | [diff] [blame] | 38 | test_995_delete_server.tags = ['nova'] |
| 39 | |
| 40 | def test_996_delete_multi_server(self): |
| 41 | print "Deleting %s instances." % (len(self.nova['multi_server'])) |
| 42 | for k, v in self.nova['multi_server'].iteritems(): |
| 43 | path = "http://%s:%s/%s/servers/%s" % (self.nova['host'], |
| 44 | self.nova['port'], |
| 45 | self.nova['ver'], |
| 46 | v) |
| 47 | http = httplib2.Http() |
| 48 | headers = {'X-Auth-User': '%s' % (self.nova['user']), |
| 49 | 'X-Auth-Token': '%s' % (self.nova['X-Auth-Token'])} |
| 50 | response, content = http.request(path, 'DELETE', headers=headers) |
| 51 | self.assertEqual(204, response.status) |
| 52 | test_996_delete_multi_server.tags = ['nova'] |
| 53 | |
| 54 | def test_997_delete_kernel_from_glance(self): |
| 55 | if 'apiver' in self.glance: |
| 56 | path = "http://%s:%s/%s/images/%s" % (self.glance['host'], |
| 57 | self.glance['port'], self.glance['apiver'], |
| 58 | self.glance['kernel_id']) |
| 59 | else: |
| 60 | path = "http://%s:%s/images/%s" % (self.glance['host'], |
| 61 | self.glance['port'], self.glance['kernel_id']) |
| 62 | http = httplib2.Http() |
| 63 | response, content = http.request(path, 'DELETE') |
| 64 | self.assertEqual(200, response.status) |
| 65 | test_997_delete_kernel_from_glance.tags = ['glance', 'nova'] |
| 66 | |
| 67 | def test_998_delete_initrd_from_glance(self): |
| 68 | if 'apiver' in self.glance: |
| 69 | path = "http://%s:%s/%s/images/%s" % (self.glance['host'], |
| 70 | self.glance['port'], self.glance['apiver'], |
| 71 | self.glance['ramdisk_id']) |
| 72 | else: |
| 73 | path = "http://%s:%s/images/%s" % (self.glance['host'], |
| 74 | self.glance['port'], self.glance['ramdisk_id']) |
| 75 | http = httplib2.Http() |
| 76 | response, content = http.request(path, 'DELETE') |
| 77 | self.assertEqual(200, response.status) |
| 78 | test_998_delete_initrd_from_glance.tags = ['glance', 'nova'] |
| 79 | |
| 80 | def test_999_delete_image_from_glance(self): |
| 81 | if 'apiver' in self.glance: |
| 82 | path = "http://%s:%s/%s/images/%s" % (self.glance['host'], |
| 83 | self.glance['port'], self.glance['apiver'], |
| 84 | self.glance['image_id']) |
| 85 | else: |
| 86 | path = "http://%s:%s/images/%s" % (self.glance['host'], |
| 87 | self.glance['port'], self.glance['image_id']) |
| 88 | http = httplib2.Http() |
| 89 | response, content = http.request(path, 'DELETE') |
| 90 | self.assertEqual(200, response.status) |
| 91 | test_999_delete_image_from_glance.tags = ['glance', 'nova'] |