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 | |
| 20 | import json |
| 21 | import os |
| 22 | import tempfile |
| 23 | import unittest |
| 24 | import httplib2 |
| 25 | import urllib |
| 26 | import hashlib |
| 27 | |
| 28 | from pprint import pprint |
| 29 | |
| 30 | import tests |
| 31 | |
| 32 | |
| 33 | class TestCleanUp(tests.FunctionalTest): |
| 34 | def test_995_delete_server(self): |
| 35 | path = "http://%s:%s/%s/servers/%s" % (self.nova['host'], |
| 36 | self.nova['port'], |
| 37 | self.nova['ver'], |
| 38 | self.nova['single_server_id']) |
| 39 | http = httplib2.Http() |
| 40 | headers = {'X-Auth-User': '%s' % (self.nova['user']), |
| 41 | 'X-Auth-Token': '%s' % (self.nova['X-Auth-Token'])} |
| 42 | response, content = http.request(path, 'DELETE', headers=headers) |
Justin Shepherd | b5ac32f | 2011-08-17 10:57:14 -0500 | [diff] [blame] | 43 | self.assertEqual(response.status, 202) |
Justin Shepherd | 0d9bbd1 | 2011-08-11 12:57:44 -0500 | [diff] [blame] | 44 | test_995_delete_server.tags = ['nova'] |
| 45 | |
| 46 | def test_996_delete_multi_server(self): |
| 47 | print "Deleting %s instances." % (len(self.nova['multi_server'])) |
| 48 | for k, v in self.nova['multi_server'].iteritems(): |
| 49 | path = "http://%s:%s/%s/servers/%s" % (self.nova['host'], |
| 50 | self.nova['port'], |
| 51 | self.nova['ver'], |
| 52 | v) |
| 53 | http = httplib2.Http() |
| 54 | headers = {'X-Auth-User': '%s' % (self.nova['user']), |
| 55 | 'X-Auth-Token': '%s' % (self.nova['X-Auth-Token'])} |
| 56 | response, content = http.request(path, 'DELETE', headers=headers) |
| 57 | self.assertEqual(204, response.status) |
| 58 | test_996_delete_multi_server.tags = ['nova'] |
| 59 | |
| 60 | def test_997_delete_kernel_from_glance(self): |
| 61 | if 'apiver' in self.glance: |
| 62 | path = "http://%s:%s/%s/images/%s" % (self.glance['host'], |
| 63 | self.glance['port'], self.glance['apiver'], |
| 64 | self.glance['kernel_id']) |
| 65 | else: |
| 66 | path = "http://%s:%s/images/%s" % (self.glance['host'], |
| 67 | self.glance['port'], self.glance['kernel_id']) |
| 68 | http = httplib2.Http() |
| 69 | response, content = http.request(path, 'DELETE') |
| 70 | self.assertEqual(200, response.status) |
| 71 | test_997_delete_kernel_from_glance.tags = ['glance', 'nova'] |
| 72 | |
| 73 | def test_998_delete_initrd_from_glance(self): |
| 74 | if 'apiver' in self.glance: |
| 75 | path = "http://%s:%s/%s/images/%s" % (self.glance['host'], |
| 76 | self.glance['port'], self.glance['apiver'], |
| 77 | self.glance['ramdisk_id']) |
| 78 | else: |
| 79 | path = "http://%s:%s/images/%s" % (self.glance['host'], |
| 80 | self.glance['port'], self.glance['ramdisk_id']) |
| 81 | http = httplib2.Http() |
| 82 | response, content = http.request(path, 'DELETE') |
| 83 | self.assertEqual(200, response.status) |
| 84 | test_998_delete_initrd_from_glance.tags = ['glance', 'nova'] |
| 85 | |
| 86 | def test_999_delete_image_from_glance(self): |
| 87 | if 'apiver' in self.glance: |
| 88 | path = "http://%s:%s/%s/images/%s" % (self.glance['host'], |
| 89 | self.glance['port'], self.glance['apiver'], |
| 90 | self.glance['image_id']) |
| 91 | else: |
| 92 | path = "http://%s:%s/images/%s" % (self.glance['host'], |
| 93 | self.glance['port'], self.glance['image_id']) |
| 94 | http = httplib2.Http() |
| 95 | response, content = http.request(path, 'DELETE') |
| 96 | self.assertEqual(200, response.status) |
| 97 | test_999_delete_image_from_glance.tags = ['glance', 'nova'] |