root / snf-tools / synnefo_tools / burnin / pithos_tests.py @ 49517b8a
History | View | Annotate | Download (11.7 kB)
1 | 79a5c431 | Ilias Tsitsimpis | # Copyright 2013 GRNET S.A. All rights reserved.
|
---|---|---|---|
2 | 79a5c431 | Ilias Tsitsimpis | #
|
3 | 79a5c431 | Ilias Tsitsimpis | # Redistribution and use in source and binary forms, with or
|
4 | 79a5c431 | Ilias Tsitsimpis | # without modification, are permitted provided that the following
|
5 | 79a5c431 | Ilias Tsitsimpis | # conditions are met:
|
6 | 79a5c431 | Ilias Tsitsimpis | #
|
7 | 79a5c431 | Ilias Tsitsimpis | # 1. Redistributions of source code must retain the above
|
8 | 79a5c431 | Ilias Tsitsimpis | # copyright notice, this list of conditions and the following
|
9 | 79a5c431 | Ilias Tsitsimpis | # disclaimer.
|
10 | 79a5c431 | Ilias Tsitsimpis | #
|
11 | 79a5c431 | Ilias Tsitsimpis | # 2. Redistributions in binary form must reproduce the above
|
12 | 79a5c431 | Ilias Tsitsimpis | # copyright notice, this list of conditions and the following
|
13 | 79a5c431 | Ilias Tsitsimpis | # disclaimer in the documentation and/or other materials
|
14 | 79a5c431 | Ilias Tsitsimpis | # provided with the distribution.
|
15 | 79a5c431 | Ilias Tsitsimpis | #
|
16 | 79a5c431 | Ilias Tsitsimpis | # THIS SOFTWARE IS PROVIDED BY GRNET S.A. ``AS IS'' AND ANY EXPRESS
|
17 | 79a5c431 | Ilias Tsitsimpis | # OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
18 | 79a5c431 | Ilias Tsitsimpis | # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
19 | 79a5c431 | Ilias Tsitsimpis | # PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GRNET S.A OR
|
20 | 79a5c431 | Ilias Tsitsimpis | # CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
21 | 79a5c431 | Ilias Tsitsimpis | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
22 | 79a5c431 | Ilias Tsitsimpis | # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
|
23 | 79a5c431 | Ilias Tsitsimpis | # USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
24 | 79a5c431 | Ilias Tsitsimpis | # AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
25 | 79a5c431 | Ilias Tsitsimpis | # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
26 | 79a5c431 | Ilias Tsitsimpis | # ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
27 | 79a5c431 | Ilias Tsitsimpis | # POSSIBILITY OF SUCH DAMAGE.
|
28 | 79a5c431 | Ilias Tsitsimpis | #
|
29 | 79a5c431 | Ilias Tsitsimpis | # The views and conclusions contained in the software and
|
30 | 79a5c431 | Ilias Tsitsimpis | # documentation are those of the authors and should not be
|
31 | 79a5c431 | Ilias Tsitsimpis | # interpreted as representing official policies, either expressed
|
32 | 79a5c431 | Ilias Tsitsimpis | # or implied, of GRNET S.A.
|
33 | 79a5c431 | Ilias Tsitsimpis | |
34 | 79a5c431 | Ilias Tsitsimpis | """
|
35 | 79a5c431 | Ilias Tsitsimpis | This is the burnin class that tests the Pithos functionality
|
36 | 79a5c431 | Ilias Tsitsimpis |
|
37 | 79a5c431 | Ilias Tsitsimpis | """
|
38 | 79a5c431 | Ilias Tsitsimpis | |
39 | 3e5bbd85 | Ilias Tsitsimpis | import os |
40 | 79a5c431 | Ilias Tsitsimpis | import random |
41 | 79a5c431 | Ilias Tsitsimpis | import tempfile |
42 | 5d9987a5 | Stavros Sachtouris | from datetime import datetime |
43 | 79a5c431 | Ilias Tsitsimpis | |
44 | d11c80c0 | Ilias Tsitsimpis | from synnefo_tools.burnin.common import BurninTests, Proper |
45 | 6a6aba0b | Stavros Sachtouris | from kamaki.clients import ClientError |
46 | 79a5c431 | Ilias Tsitsimpis | |
47 | 79a5c431 | Ilias Tsitsimpis | |
48 | 79a5c431 | Ilias Tsitsimpis | # Too many public methods. pylint: disable-msg=R0904
|
49 | d11c80c0 | Ilias Tsitsimpis | class PithosTestSuite(BurninTests): |
50 | 79a5c431 | Ilias Tsitsimpis | """Test Pithos functionality"""
|
51 | d11c80c0 | Ilias Tsitsimpis | containers = Proper(value=None)
|
52 | d11c80c0 | Ilias Tsitsimpis | created_container = Proper(value=None)
|
53 | 5d9987a5 | Stavros Sachtouris | now_unformated = Proper(value=datetime.utcnow()) |
54 | 79a5c431 | Ilias Tsitsimpis | |
55 | 5d9987a5 | Stavros Sachtouris | def test_005_account_head(self): |
56 | 5d9987a5 | Stavros Sachtouris | """HEAD on pithos account"""
|
57 | 79a5c431 | Ilias Tsitsimpis | self._set_pithos_account(self._get_uuid()) |
58 | 5d9987a5 | Stavros Sachtouris | pithos = self.clients.pithos
|
59 | 5d9987a5 | Stavros Sachtouris | r = pithos.account_head() |
60 | 5d9987a5 | Stavros Sachtouris | self.assertEqual(r.status_code, 204) |
61 | 5d9987a5 | Stavros Sachtouris | self.info('Returns 204') |
62 | 5d9987a5 | Stavros Sachtouris | |
63 | 5d9987a5 | Stavros Sachtouris | r = pithos.account_head(until='1000000000')
|
64 | 5d9987a5 | Stavros Sachtouris | self.assertEqual(r.status_code, 204) |
65 | 5d9987a5 | Stavros Sachtouris | datestring = unicode(r.headers['x-account-until-timestamp']) |
66 | 5d9987a5 | Stavros Sachtouris | self.assertEqual(u'Sun, 09 Sep 2001 01:46:40 GMT', datestring) |
67 | 5d9987a5 | Stavros Sachtouris | self.assertTrue('x-account-policy-quota' in r.headers) |
68 | 5d9987a5 | Stavros Sachtouris | self.info('Until and policy quota exist') |
69 | 5d9987a5 | Stavros Sachtouris | |
70 | 5d9987a5 | Stavros Sachtouris | for format in pithos.DATE_FORMATS: |
71 | 5d9987a5 | Stavros Sachtouris | now_formated = self.now_unformated.strftime(format)
|
72 | 5d9987a5 | Stavros Sachtouris | r1 = pithos.account_head( |
73 | 5d9987a5 | Stavros Sachtouris | if_modified_since=now_formated, success=(204, 304, 412)) |
74 | 5d9987a5 | Stavros Sachtouris | r2 = pithos.account_head( |
75 | 5d9987a5 | Stavros Sachtouris | if_unmodified_since=now_formated, success=(204, 304, 412)) |
76 | 5d9987a5 | Stavros Sachtouris | self.assertNotEqual(r1.status_code, r2.status_code)
|
77 | 5d9987a5 | Stavros Sachtouris | self.info('If_(un)modified_since is OK') |
78 | 5d9987a5 | Stavros Sachtouris | |
79 | 5d9987a5 | Stavros Sachtouris | def test_010_account_get(self): |
80 | 5d9987a5 | Stavros Sachtouris | """Test account_get"""
|
81 | 5d9987a5 | Stavros Sachtouris | self.info('Preparation') |
82 | 5d9987a5 | Stavros Sachtouris | pithos = self.clients.pithos
|
83 | 5d9987a5 | Stavros Sachtouris | for i in range(1, 3): |
84 | 5d9987a5 | Stavros Sachtouris | cont_name = "cont%s_%s%s" % (
|
85 | 1ff50540 | Stavros Sachtouris | i, self.run_id or 0, random.randint(1000, 9999)) |
86 | 5d9987a5 | Stavros Sachtouris | self._create_pithos_container(cont_name)
|
87 | 5d9987a5 | Stavros Sachtouris | pithos.container, obj = cont_name, 'shared_file'
|
88 | 5d9987a5 | Stavros Sachtouris | pithos.create_object(obj) |
89 | 5d9987a5 | Stavros Sachtouris | pithos.set_object_sharing(obj, read_permission='*')
|
90 | 5d9987a5 | Stavros Sachtouris | self.info('Created object /%s/%s' % (cont_name, obj)) |
91 | 5d9987a5 | Stavros Sachtouris | |
92 | 5d9987a5 | Stavros Sachtouris | r = pithos.list_containers() |
93 | 5d9987a5 | Stavros Sachtouris | fullLen = len(r)
|
94 | 5d9987a5 | Stavros Sachtouris | self.assertTrue(fullLen > 2) |
95 | 5d9987a5 | Stavros Sachtouris | self.info('Normal use is OK') |
96 | 5d9987a5 | Stavros Sachtouris | |
97 | 5d9987a5 | Stavros Sachtouris | r = pithos.account_get(limit=1)
|
98 | 5d9987a5 | Stavros Sachtouris | self.assertEqual(len(r.json), 1) |
99 | 5d9987a5 | Stavros Sachtouris | self.info('Limit works') |
100 | 5d9987a5 | Stavros Sachtouris | |
101 | 5d9987a5 | Stavros Sachtouris | r = pithos.account_get(marker='cont')
|
102 | 5d9987a5 | Stavros Sachtouris | cont1, cont3 = r.json[0], r.json[2] |
103 | 5d9987a5 | Stavros Sachtouris | self.info('Marker works') |
104 | 5d9987a5 | Stavros Sachtouris | |
105 | 5d9987a5 | Stavros Sachtouris | r = pithos.account_get(limit=2, marker='cont') |
106 | 5d9987a5 | Stavros Sachtouris | conames = [container['name'] for container in r.json if ( |
107 | 5d9987a5 | Stavros Sachtouris | container['name'].lower().startswith('cont'))] |
108 | 5d9987a5 | Stavros Sachtouris | self.assertTrue(cont1['name'] in conames) |
109 | 5d9987a5 | Stavros Sachtouris | self.assertFalse(cont3['name'] in conames) |
110 | 5d9987a5 | Stavros Sachtouris | self.info('Marker-limit combination works') |
111 | 5d9987a5 | Stavros Sachtouris | |
112 | 5d9987a5 | Stavros Sachtouris | r = pithos.account_get(show_only_shared=True)
|
113 | 5d9987a5 | Stavros Sachtouris | self.assertTrue(cont_name in [c['name'] for c in r.json]) |
114 | 5d9987a5 | Stavros Sachtouris | self.info('Show-only-shared works') |
115 | 5d9987a5 | Stavros Sachtouris | |
116 | 5d9987a5 | Stavros Sachtouris | r = pithos.account_get(until=1342609206.0)
|
117 | 5d9987a5 | Stavros Sachtouris | self.assertTrue(len(r.json) <= fullLen) |
118 | 5d9987a5 | Stavros Sachtouris | self.info('Until works') |
119 | 5d9987a5 | Stavros Sachtouris | |
120 | 5d9987a5 | Stavros Sachtouris | for format in pithos.DATE_FORMATS: |
121 | 5d9987a5 | Stavros Sachtouris | now_formated = self.now_unformated.strftime(format)
|
122 | 5d9987a5 | Stavros Sachtouris | r1 = pithos.account_get( |
123 | 5d9987a5 | Stavros Sachtouris | if_modified_since=now_formated, success=(200, 304, 412)) |
124 | 5d9987a5 | Stavros Sachtouris | r2 = pithos.account_get( |
125 | 5d9987a5 | Stavros Sachtouris | if_unmodified_since=now_formated, success=(200, 304, 412)) |
126 | 5d9987a5 | Stavros Sachtouris | self.assertNotEqual(r1.status_code, r2.status_code)
|
127 | 5d9987a5 | Stavros Sachtouris | self.info('If_(un)modified_since is OK') |
128 | 5d9987a5 | Stavros Sachtouris | |
129 | 6a6aba0b | Stavros Sachtouris | def test_015_account_post(self): |
130 | 6a6aba0b | Stavros Sachtouris | """Test account_post"""
|
131 | 6a6aba0b | Stavros Sachtouris | pithos = self.clients.pithos
|
132 | 6a6aba0b | Stavros Sachtouris | r = pithos.account_post() |
133 | 6a6aba0b | Stavros Sachtouris | self.assertEqual(r.status_code, 202) |
134 | 6a6aba0b | Stavros Sachtouris | self.info('Status code is OK') |
135 | 6a6aba0b | Stavros Sachtouris | |
136 | 6a6aba0b | Stavros Sachtouris | rand_num = '%s%s' % (self.run_id or 0, random.randint(1000, 9999)) |
137 | 6a6aba0b | Stavros Sachtouris | grpName = 'grp%s' % rand_num
|
138 | 6a6aba0b | Stavros Sachtouris | |
139 | 6a6aba0b | Stavros Sachtouris | u1, u2 = pithos.account, 'invalid-user-uuid-%s' % rand_num
|
140 | 6a6aba0b | Stavros Sachtouris | self.assertRaises(
|
141 | 6a6aba0b | Stavros Sachtouris | ClientError, pithos.set_account_group, grpName, [u1, u2]) |
142 | 6a6aba0b | Stavros Sachtouris | self.info('Invalid uuid is handled correctly') |
143 | 6a6aba0b | Stavros Sachtouris | |
144 | 6a6aba0b | Stavros Sachtouris | pithos.set_account_group(grpName, [u1]) |
145 | 6a6aba0b | Stavros Sachtouris | r = pithos.get_account_group() |
146 | 6a6aba0b | Stavros Sachtouris | self.assertEqual(r['x-account-group-' + grpName], '%s' % u1) |
147 | 6a6aba0b | Stavros Sachtouris | self.info('Account group is OK') |
148 | 6a6aba0b | Stavros Sachtouris | pithos.del_account_group(grpName) |
149 | 6a6aba0b | Stavros Sachtouris | r = pithos.get_account_group() |
150 | 6a6aba0b | Stavros Sachtouris | self.assertTrue('x-account-group-' + grpName not in r) |
151 | 6a6aba0b | Stavros Sachtouris | self.info('Removed account group') |
152 | 6a6aba0b | Stavros Sachtouris | |
153 | 6a6aba0b | Stavros Sachtouris | mprefix = 'meta%s' % rand_num
|
154 | 6a6aba0b | Stavros Sachtouris | pithos.set_account_meta({ |
155 | 6a6aba0b | Stavros Sachtouris | mprefix + '1': 'v1', mprefix + '2': 'v2'}) |
156 | 6a6aba0b | Stavros Sachtouris | r = pithos.get_account_meta() |
157 | 6a6aba0b | Stavros Sachtouris | self.assertEqual(r['x-account-meta-' + mprefix + '1'], 'v1') |
158 | 6a6aba0b | Stavros Sachtouris | self.assertEqual(r['x-account-meta-' + mprefix + '2'], 'v2') |
159 | 6a6aba0b | Stavros Sachtouris | self.info('Account meta is OK') |
160 | 6a6aba0b | Stavros Sachtouris | |
161 | 6a6aba0b | Stavros Sachtouris | pithos.del_account_meta(mprefix + '1')
|
162 | 6a6aba0b | Stavros Sachtouris | r = pithos.get_account_meta() |
163 | 6a6aba0b | Stavros Sachtouris | self.assertTrue('x-account-meta-' + mprefix + '1' not in r) |
164 | 6a6aba0b | Stavros Sachtouris | self.assertTrue('x-account-meta-' + mprefix + '2' in r) |
165 | 6a6aba0b | Stavros Sachtouris | self.info('Selective removal of account meta is OK') |
166 | 6a6aba0b | Stavros Sachtouris | |
167 | 6a6aba0b | Stavros Sachtouris | pithos.del_account_meta(mprefix + '2')
|
168 | 6a6aba0b | Stavros Sachtouris | r = pithos.get_account_meta() |
169 | 6a6aba0b | Stavros Sachtouris | self.assertTrue('x-account-meta-' + mprefix + '2' not in r) |
170 | 6a6aba0b | Stavros Sachtouris | self.info('Temporary account meta are removed') |
171 | 6a6aba0b | Stavros Sachtouris | |
172 | 1ff50540 | Stavros Sachtouris | def test_020_container_head(self): |
173 | 1ff50540 | Stavros Sachtouris | """Test container HEAD"""
|
174 | 1ff50540 | Stavros Sachtouris | pithos = self.clients.pithos
|
175 | 1ff50540 | Stavros Sachtouris | r = pithos.container_head() |
176 | 1ff50540 | Stavros Sachtouris | self.assertEqual(r.status_code, 204) |
177 | 1ff50540 | Stavros Sachtouris | self.info('Status code is OK') |
178 | 1ff50540 | Stavros Sachtouris | |
179 | 1ff50540 | Stavros Sachtouris | r = pithos.container_head(until=1000000, success=(204, 404)) |
180 | 1ff50540 | Stavros Sachtouris | self.assertEqual(r.status_code, 404) |
181 | 1ff50540 | Stavros Sachtouris | self.info('Until works') |
182 | 1ff50540 | Stavros Sachtouris | |
183 | 1ff50540 | Stavros Sachtouris | for format in pithos.DATE_FORMATS: |
184 | 1ff50540 | Stavros Sachtouris | now_formated = self.now_unformated.strftime(format)
|
185 | 1ff50540 | Stavros Sachtouris | r1 = pithos.container_head( |
186 | 1ff50540 | Stavros Sachtouris | if_modified_since=now_formated, success=(204, 304, 412)) |
187 | 1ff50540 | Stavros Sachtouris | r2 = pithos.container_head( |
188 | 1ff50540 | Stavros Sachtouris | if_unmodified_since=now_formated, success=(204, 304, 412)) |
189 | 1ff50540 | Stavros Sachtouris | self.assertNotEqual(r1.status_code, r2.status_code)
|
190 | 1ff50540 | Stavros Sachtouris | |
191 | 1ff50540 | Stavros Sachtouris | k = 'metakey%s' % random.randint(1000, 9999) |
192 | 1ff50540 | Stavros Sachtouris | pithos.set_container_meta({k: 'our value'})
|
193 | 1ff50540 | Stavros Sachtouris | r = pithos.get_container_meta() |
194 | 1ff50540 | Stavros Sachtouris | k = 'x-container-meta-%s' % k
|
195 | 1ff50540 | Stavros Sachtouris | self.assertIn(k, r)
|
196 | 1ff50540 | Stavros Sachtouris | self.assertEqual('our value', r[k]) |
197 | 1ff50540 | Stavros Sachtouris | self.info('Container meta exists') |
198 | 1ff50540 | Stavros Sachtouris | |
199 | 6a6aba0b | Stavros Sachtouris | # def test_050_stop_test(self):
|
200 | 6a6aba0b | Stavros Sachtouris | # """STOP TESTING ALREADY"""
|
201 | 6a6aba0b | Stavros Sachtouris | # self.assertTrue(False)
|
202 | 6a6aba0b | Stavros Sachtouris | |
203 | 5d9987a5 | Stavros Sachtouris | def test_051_list_containers(self): |
204 | 5d9987a5 | Stavros Sachtouris | """Test container list actually returns containers"""
|
205 | d11c80c0 | Ilias Tsitsimpis | self.containers = self._get_list_of_containers() |
206 | 79a5c431 | Ilias Tsitsimpis | self.assertGreater(len(self.containers), 0) |
207 | 5d9987a5 | Stavros Sachtouris | self.lala = 1 |
208 | 79a5c431 | Ilias Tsitsimpis | |
209 | 5d9987a5 | Stavros Sachtouris | def test_052_unique_containers(self): |
210 | 79a5c431 | Ilias Tsitsimpis | """Test if containers have unique names"""
|
211 | 79a5c431 | Ilias Tsitsimpis | names = [n['name'] for n in self.containers] |
212 | 79a5c431 | Ilias Tsitsimpis | names = sorted(names)
|
213 | 79a5c431 | Ilias Tsitsimpis | self.assertEqual(sorted(list(set(names))), names) |
214 | 79a5c431 | Ilias Tsitsimpis | |
215 | 5d9987a5 | Stavros Sachtouris | def test_053_create_container(self): |
216 | 79a5c431 | Ilias Tsitsimpis | """Test creating a new container"""
|
217 | 79a5c431 | Ilias Tsitsimpis | names = [n['name'] for n in self.containers] |
218 | 79a5c431 | Ilias Tsitsimpis | while True: |
219 | 79a5c431 | Ilias Tsitsimpis | rand_num = random.randint(1000, 9999) |
220 | 1ff50540 | Stavros Sachtouris | rand_name = "%s%s" % (self.run_id or 0, rand_num) |
221 | 79a5c431 | Ilias Tsitsimpis | self.info("Trying container name %s", rand_name) |
222 | 79a5c431 | Ilias Tsitsimpis | if rand_name not in names: |
223 | 79a5c431 | Ilias Tsitsimpis | break
|
224 | 79a5c431 | Ilias Tsitsimpis | self.info("Container name %s already exists", rand_name) |
225 | 79a5c431 | Ilias Tsitsimpis | # Create container
|
226 | 79a5c431 | Ilias Tsitsimpis | self._create_pithos_container(rand_name)
|
227 | 79a5c431 | Ilias Tsitsimpis | # Verify that container is created
|
228 | 79a5c431 | Ilias Tsitsimpis | containers = self._get_list_of_containers()
|
229 | 79a5c431 | Ilias Tsitsimpis | self.info("Verify that container %s is created", rand_name) |
230 | 79a5c431 | Ilias Tsitsimpis | names = [n['name'] for n in containers] |
231 | 79a5c431 | Ilias Tsitsimpis | self.assertIn(rand_name, names)
|
232 | 79a5c431 | Ilias Tsitsimpis | # Keep the name of the container so we can remove it
|
233 | 79a5c431 | Ilias Tsitsimpis | # at cleanup phase, if something goes wrong.
|
234 | d11c80c0 | Ilias Tsitsimpis | self.created_container = rand_name
|
235 | 79a5c431 | Ilias Tsitsimpis | |
236 | 5d9987a5 | Stavros Sachtouris | def test_054_upload_file(self): |
237 | 79a5c431 | Ilias Tsitsimpis | """Test uploading a txt file to Pithos"""
|
238 | 79a5c431 | Ilias Tsitsimpis | # Create a tmp file
|
239 | 24d1788b | Ilias Tsitsimpis | with tempfile.TemporaryFile(dir=self.temp_directory) as fout: |
240 | 79a5c431 | Ilias Tsitsimpis | fout.write("This is a temp file")
|
241 | 79a5c431 | Ilias Tsitsimpis | fout.seek(0, 0) |
242 | 79a5c431 | Ilias Tsitsimpis | # Upload the file,
|
243 | 79a5c431 | Ilias Tsitsimpis | # The container is the one choosen during the `create_container'
|
244 | 79a5c431 | Ilias Tsitsimpis | self.clients.pithos.upload_object("test.txt", fout) |
245 | 3e5bbd85 | Ilias Tsitsimpis | # Verify quotas
|
246 | 3e5bbd85 | Ilias Tsitsimpis | self._check_quotas(diskspace=+os.fstat(fout.fileno()).st_size)
|
247 | 79a5c431 | Ilias Tsitsimpis | |
248 | 5d9987a5 | Stavros Sachtouris | def test_055_download_file(self): |
249 | 79a5c431 | Ilias Tsitsimpis | """Test downloading the file from Pithos"""
|
250 | 79a5c431 | Ilias Tsitsimpis | # Create a tmp directory to save the file
|
251 | 24d1788b | Ilias Tsitsimpis | with tempfile.TemporaryFile(dir=self.temp_directory) as fout: |
252 | 79a5c431 | Ilias Tsitsimpis | self.clients.pithos.download_object("test.txt", fout) |
253 | 79a5c431 | Ilias Tsitsimpis | # Now read the file
|
254 | 79a5c431 | Ilias Tsitsimpis | fout.seek(0, 0) |
255 | 79a5c431 | Ilias Tsitsimpis | contents = fout.read() |
256 | 79a5c431 | Ilias Tsitsimpis | # Compare results
|
257 | 79a5c431 | Ilias Tsitsimpis | self.info("Comparing contents with the uploaded file") |
258 | 79a5c431 | Ilias Tsitsimpis | self.assertEqual(contents, "This is a temp file") |
259 | 79a5c431 | Ilias Tsitsimpis | |
260 | 5d9987a5 | Stavros Sachtouris | def test_056_remove(self): |
261 | 79a5c431 | Ilias Tsitsimpis | """Test removing files and containers from Pithos"""
|
262 | 79a5c431 | Ilias Tsitsimpis | self.info("Removing the file %s from container %s", |
263 | 79a5c431 | Ilias Tsitsimpis | "test.txt", self.created_container) |
264 | 79a5c431 | Ilias Tsitsimpis | # The container is the one choosen during the `create_container'
|
265 | 3e5bbd85 | Ilias Tsitsimpis | content_length = \ |
266 | 3e5bbd85 | Ilias Tsitsimpis | self.clients.pithos.get_object_info("test.txt")['content-length'] |
267 | 79a5c431 | Ilias Tsitsimpis | self.clients.pithos.del_object("test.txt") |
268 | 79a5c431 | Ilias Tsitsimpis | |
269 | 3e5bbd85 | Ilias Tsitsimpis | # Verify quotas
|
270 | 3e5bbd85 | Ilias Tsitsimpis | self._check_quotas(diskspace=-int(content_length)) |
271 | 3e5bbd85 | Ilias Tsitsimpis | |
272 | 79a5c431 | Ilias Tsitsimpis | self.info("Removing the container %s", self.created_container) |
273 | 79a5c431 | Ilias Tsitsimpis | self.clients.pithos.purge_container()
|
274 | 79a5c431 | Ilias Tsitsimpis | |
275 | 79a5c431 | Ilias Tsitsimpis | # List containers
|
276 | 79a5c431 | Ilias Tsitsimpis | containers = self._get_list_of_containers()
|
277 | 79a5c431 | Ilias Tsitsimpis | self.info("Check that the container %s has been deleted", |
278 | 79a5c431 | Ilias Tsitsimpis | self.created_container)
|
279 | 79a5c431 | Ilias Tsitsimpis | names = [n['name'] for n in containers] |
280 | 79a5c431 | Ilias Tsitsimpis | self.assertNotIn(self.created_container, names) |
281 | 79a5c431 | Ilias Tsitsimpis | # We successfully deleted our container, no need to do it
|
282 | 79a5c431 | Ilias Tsitsimpis | # in our clean up phase
|
283 | d11c80c0 | Ilias Tsitsimpis | self.created_container = None |
284 | 79a5c431 | Ilias Tsitsimpis | |
285 | 79a5c431 | Ilias Tsitsimpis | @classmethod
|
286 | 79a5c431 | Ilias Tsitsimpis | def tearDownClass(cls): # noqa |
287 | 79a5c431 | Ilias Tsitsimpis | """Clean up"""
|
288 | 49517b8a | Stavros Sachtouris | pithos = cls.clients.pithos |
289 | 49517b8a | Stavros Sachtouris | for c in getattr(cls, 'temp_containers', []): |
290 | 49517b8a | Stavros Sachtouris | pithos.container = c |
291 | 49517b8a | Stavros Sachtouris | try:
|
292 | 49517b8a | Stavros Sachtouris | pithos.del_container(delimiter='/')
|
293 | 49517b8a | Stavros Sachtouris | pithos.purge_container(c) |
294 | 49517b8a | Stavros Sachtouris | except ClientError as ce: |
295 | 49517b8a | Stavros Sachtouris | print ('Failed to destroy container (%s)' % ce) |