Merge lp:~notmyname/swift/end_marker into lp:~hudson-openstack/swift/trunk
- end_marker
- Merge into trunk
Status: | Merged |
---|---|
Approved by: | Chuck Thier |
Approved revision: | 130 |
Merged at revision: | 130 |
Proposed branch: | lp:~notmyname/swift/end_marker |
Merge into: | lp:~hudson-openstack/swift/trunk |
Diff against target: |
500 lines (+99/-69) 8 files modified
swift/account/reaper.py (+2/-1) swift/account/server.py (+3/-2) swift/common/db.py (+12/-3) swift/common/internal_proxy.py (+8/-4) swift/container/server.py (+3/-2) swift/stats/log_processor.py (+2/-3) test/unit/common/test_db.py (+62/-51) test/unit/stats/test_log_processor.py (+7/-3) |
To merge this branch: | bzr merge lp:~notmyname/swift/end_marker |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Chuck Thier (community) | Approve | ||
John Dickinson | Needs Resubmitting | ||
Review via email: mp+40742@code.launchpad.net |
Commit message
added end_marker query parameter for container and object listings
Description of the change
Added end_marker query parameter for container and object listings. end_marker filters on the name <= end_marker
John Dickinson (notmyname) wrote : | # |
Chuck Thier (cthier) wrote : | # |
in swift/common/
John Dickinson (notmyname) wrote : | # |
fixed the erroneous marker to be end_marker
tests for internal_proxy would be very good, but they are not in the scope of this branch
Chuck Thier (cthier) wrote : | # |
I get the following error when I run the unit tests:
ERROR: test_get_
-------
Traceback (most recent call last):
File "/home/
result = p.get_container
File "/home/
end_
TypeError: get_container_
Chuck Thier (cthier) wrote : | # |
Looks good to me now. All unit and functional tests pass.
Preview Diff
1 | === modified file 'swift/account/reaper.py' |
2 | --- swift/account/reaper.py 2010-09-06 04:06:16 +0000 |
3 | +++ swift/account/reaper.py 2010-11-17 15:38:03 +0000 |
4 | @@ -224,7 +224,8 @@ |
5 | marker = '' |
6 | while True: |
7 | containers = \ |
8 | - list(broker.list_containers_iter(1000, marker, None, None)) |
9 | + list(broker.list_containers_iter(1000, marker, None, None, |
10 | + None)) |
11 | if not containers: |
12 | break |
13 | try: |
14 | |
15 | === modified file 'swift/account/server.py' |
16 | --- swift/account/server.py 2010-11-02 18:32:18 +0000 |
17 | +++ swift/account/server.py 2010-11-17 15:38:03 +0000 |
18 | @@ -200,6 +200,7 @@ |
19 | return HTTPPreconditionFailed(request=req, |
20 | body='Maximum limit is %d' % ACCOUNT_LISTING_LIMIT) |
21 | marker = get_param(req, 'marker', '') |
22 | + end_marker = get_param(req, 'end_marker') |
23 | query_format = get_param(req, 'format') |
24 | except UnicodeDecodeError, err: |
25 | return HTTPBadRequest(body='parameters not utf8', |
26 | @@ -210,8 +211,8 @@ |
27 | ['text/plain', 'application/json', |
28 | 'application/xml', 'text/xml'], |
29 | default_match='text/plain') |
30 | - account_list = broker.list_containers_iter(limit, marker, prefix, |
31 | - delimiter) |
32 | + account_list = broker.list_containers_iter(limit, marker, end_marker, |
33 | + prefix, delimiter) |
34 | if out_content_type == 'application/json': |
35 | json_pattern = ['"name":%s', '"count":%s', '"bytes":%s'] |
36 | json_pattern = '{' + ','.join(json_pattern) + '}' |
37 | |
38 | === modified file 'swift/common/db.py' |
39 | --- swift/common/db.py 2010-08-16 22:30:27 +0000 |
40 | +++ swift/common/db.py 2010-11-17 15:38:03 +0000 |
41 | @@ -940,8 +940,8 @@ |
42 | rv.append(row['name']) |
43 | return list(set(rv)) |
44 | |
45 | - def list_objects_iter(self, limit, marker, prefix, delimiter, path=None, |
46 | - format=None): |
47 | + def list_objects_iter(self, limit, marker, end_marker, prefix, delimiter, |
48 | + path=None, format=None): |
49 | """ |
50 | Get a list of objects sorted by name starting at marker onward, up |
51 | to limit entries. Entries will begin with the prefix and will not |
52 | @@ -949,6 +949,7 @@ |
53 | |
54 | :param limit: maximum number of entries to get |
55 | :param marker: marker query |
56 | + :param end_marker: end marker query |
57 | :param prefix: prefix query |
58 | :param delimeter: delimeter for query |
59 | :param path: if defined, will set the prefix and delimter based on |
60 | @@ -977,6 +978,9 @@ |
61 | query = '''SELECT name, created_at, size, content_type, etag |
62 | FROM object WHERE''' |
63 | query_args = [] |
64 | + if end_marker: |
65 | + query += ' name <= ? AND' |
66 | + query_args.append(end_marker) |
67 | if marker and marker >= prefix: |
68 | query += ' name > ? AND' |
69 | query_args.append(marker) |
70 | @@ -1440,7 +1444,8 @@ |
71 | rv.append(row['name']) |
72 | return list(set(rv)) |
73 | |
74 | - def list_containers_iter(self, limit, marker, prefix, delimiter): |
75 | + def list_containers_iter(self, limit, marker, end_marker, prefix, |
76 | + delimiter): |
77 | """ |
78 | Get a list of containerss sorted by name starting at marker onward, up |
79 | to limit entries. Entries will begin with the prefix and will not |
80 | @@ -1448,6 +1453,7 @@ |
81 | |
82 | :param limit: maximum number of entries to get |
83 | :param marker: marker query |
84 | + :param end_marker: end marker query |
85 | :param prefix: prefix query |
86 | :param delimeter: delimeter for query |
87 | |
88 | @@ -1469,6 +1475,9 @@ |
89 | FROM container |
90 | WHERE deleted = 0 AND """ |
91 | query_args = [] |
92 | + if end_marker: |
93 | + query += ' name <= ? AND' |
94 | + query_args.append(end_marker) |
95 | if marker and marker >= prefix: |
96 | query += ' name > ? AND' |
97 | query_args.append(marker) |
98 | |
99 | === modified file 'swift/common/internal_proxy.py' |
100 | --- swift/common/internal_proxy.py 2010-10-04 21:12:43 +0000 |
101 | +++ swift/common/internal_proxy.py 2010-11-17 15:38:03 +0000 |
102 | @@ -156,14 +156,16 @@ |
103 | tries += 1 |
104 | return 200 <= resp.status_int < 300 |
105 | |
106 | - def get_container_list(self, account, container, marker=None, limit=None, |
107 | - prefix=None, delimiter=None, full_listing=True): |
108 | + def get_container_list(self, account, container, marker=None, |
109 | + end_marker=None, limit=None, prefix=None, |
110 | + delimiter=None, full_listing=True): |
111 | """ |
112 | Get container listing. |
113 | |
114 | :param account: account name for the container |
115 | :param container: container name to get the listing of |
116 | :param marker: marker query |
117 | + :param end_marker: end marker query |
118 | :param limit: limit to query |
119 | :param prefix: prefix query |
120 | :param delimeter: delimeter for query |
121 | @@ -173,7 +175,7 @@ |
122 | if full_listing: |
123 | rv = [] |
124 | listing = self.get_container_list(account, container, marker, |
125 | - limit, prefix, delimiter, full_listing=False) |
126 | + end_marker, limit, prefix, delimiter, full_listing=False) |
127 | while listing: |
128 | rv.extend(listing) |
129 | if not delimiter: |
130 | @@ -181,12 +183,14 @@ |
131 | else: |
132 | marker = listing[-1].get('name', listing[-1].get('subdir')) |
133 | listing = self.get_container_list(account, container, marker, |
134 | - limit, prefix, delimiter, full_listing=False) |
135 | + end_marker, limit, prefix, delimiter, full_listing=False) |
136 | return rv |
137 | path = '/v1/%s/%s' % (account, container) |
138 | qs = 'format=json' |
139 | if marker: |
140 | qs += '&marker=%s' % quote(marker) |
141 | + if end_marker: |
142 | + qs += '&end_marker=%s' % quote(end_marker) |
143 | if limit: |
144 | qs += '&limit=%d' % limit |
145 | if prefix: |
146 | |
147 | === modified file 'swift/container/server.py' |
148 | --- swift/container/server.py 2010-11-02 18:32:18 +0000 |
149 | +++ swift/container/server.py 2010-11-17 15:38:03 +0000 |
150 | @@ -267,6 +267,7 @@ |
151 | # delimiters can be made more flexible later |
152 | return HTTPPreconditionFailed(body='Bad delimiter') |
153 | marker = get_param(req, 'marker', '') |
154 | + end_marker = get_param(req, 'end_marker') |
155 | limit = CONTAINER_LISTING_LIMIT |
156 | given_limit = get_param(req, 'limit') |
157 | if given_limit and given_limit.isdigit(): |
158 | @@ -284,8 +285,8 @@ |
159 | ['text/plain', 'application/json', |
160 | 'application/xml', 'text/xml'], |
161 | default_match='text/plain') |
162 | - container_list = broker.list_objects_iter(limit, marker, prefix, |
163 | - delimiter, path) |
164 | + container_list = broker.list_objects_iter(limit, marker, end_marker, |
165 | + prefix, delimiter, path) |
166 | if out_content_type == 'application/json': |
167 | json_pattern = ['"name":%s', '"hash":"%s"', '"bytes":%s', |
168 | '"content_type":%s, "last_modified":"%s"'] |
169 | |
170 | === modified file 'swift/stats/log_processor.py' |
171 | --- swift/stats/log_processor.py 2010-11-04 19:56:08 +0000 |
172 | +++ swift/stats/log_processor.py 2010-11-17 15:38:03 +0000 |
173 | @@ -158,15 +158,14 @@ |
174 | container_listing = self.internal_proxy.get_container_list( |
175 | swift_account, |
176 | container_name, |
177 | - marker=search_key) |
178 | + marker=search_key, |
179 | + end_marker=end_key) |
180 | results = [] |
181 | if container_listing is not None: |
182 | if listing_filter is None: |
183 | listing_filter = set() |
184 | for item in container_listing: |
185 | name = item['name'] |
186 | - if end_key and name > end_key: |
187 | - break |
188 | if name not in listing_filter: |
189 | results.append(name) |
190 | return results |
191 | |
192 | === modified file 'test/unit/common/test_db.py' |
193 | --- test/unit/common/test_db.py 2010-08-16 22:30:27 +0000 |
194 | +++ test/unit/common/test_db.py 2010-11-17 15:38:03 +0000 |
195 | @@ -978,52 +978,57 @@ |
196 | normalize_timestamp(time()), 0, 'text/plain', |
197 | 'd41d8cd98f00b204e9800998ecf8427e') |
198 | |
199 | - listing = broker.list_objects_iter(100, '', None, '') |
200 | + listing = broker.list_objects_iter(100, '', None, None, '') |
201 | self.assertEquals(len(listing), 100) |
202 | self.assertEquals(listing[0][0], '0/0000') |
203 | self.assertEquals(listing[-1][0], '0/0099') |
204 | |
205 | - listing = broker.list_objects_iter(100, '0/0099', None, '') |
206 | + listing = broker.list_objects_iter(100, '', '0/0050', None, '') |
207 | + self.assertEquals(len(listing), 51) |
208 | + self.assertEquals(listing[0][0], '0/0000') |
209 | + self.assertEquals(listing[-1][0], '0/0050') |
210 | + |
211 | + listing = broker.list_objects_iter(100, '0/0099', None, None, '') |
212 | self.assertEquals(len(listing), 100) |
213 | self.assertEquals(listing[0][0], '0/0100') |
214 | self.assertEquals(listing[-1][0], '1/0074') |
215 | |
216 | - listing = broker.list_objects_iter(55, '1/0074', None, '') |
217 | + listing = broker.list_objects_iter(55, '1/0074', None, None, '') |
218 | self.assertEquals(len(listing), 55) |
219 | self.assertEquals(listing[0][0], '1/0075') |
220 | self.assertEquals(listing[-1][0], '2/0004') |
221 | |
222 | - listing = broker.list_objects_iter(10, '', '0/01', '') |
223 | + listing = broker.list_objects_iter(10, '', None, '0/01', '') |
224 | self.assertEquals(len(listing), 10) |
225 | self.assertEquals(listing[0][0], '0/0100') |
226 | self.assertEquals(listing[-1][0], '0/0109') |
227 | |
228 | - listing = broker.list_objects_iter(10, '', '0/', '/') |
229 | + listing = broker.list_objects_iter(10, '', None, '0/', '/') |
230 | self.assertEquals(len(listing), 10) |
231 | self.assertEquals(listing[0][0], '0/0000') |
232 | self.assertEquals(listing[-1][0], '0/0009') |
233 | |
234 | - listing = broker.list_objects_iter(10, '', '', '/') |
235 | + listing = broker.list_objects_iter(10, '', None, '', '/') |
236 | self.assertEquals(len(listing), 4) |
237 | self.assertEquals([row[0] for row in listing], |
238 | ['0/', '1/', '2/', '3/']) |
239 | |
240 | - listing = broker.list_objects_iter(10, '2', None, '/') |
241 | + listing = broker.list_objects_iter(10, '2', None, None, '/') |
242 | self.assertEquals(len(listing), 2) |
243 | self.assertEquals([row[0] for row in listing], ['2/', '3/']) |
244 | |
245 | - listing = broker.list_objects_iter(10, '2/', None, '/') |
246 | + listing = broker.list_objects_iter(10, '2/',None, None, '/') |
247 | self.assertEquals(len(listing), 1) |
248 | self.assertEquals([row[0] for row in listing], ['3/']) |
249 | |
250 | - listing = broker.list_objects_iter(10, '2/0050', '2/', '/') |
251 | + listing = broker.list_objects_iter(10, '2/0050', None, '2/', '/') |
252 | self.assertEquals(len(listing), 10) |
253 | self.assertEquals(listing[0][0], '2/0051') |
254 | self.assertEquals(listing[1][0], '2/0051/') |
255 | self.assertEquals(listing[2][0], '2/0052') |
256 | self.assertEquals(listing[-1][0], '2/0059') |
257 | |
258 | - listing = broker.list_objects_iter(10, '3/0045', '3/', '/') |
259 | + listing = broker.list_objects_iter(10, '3/0045', None, '3/', '/') |
260 | self.assertEquals(len(listing), 10) |
261 | self.assertEquals([row[0] for row in listing], |
262 | ['3/0045/', '3/0046', '3/0046/', '3/0047', |
263 | @@ -1032,33 +1037,34 @@ |
264 | |
265 | broker.put_object('3/0049/', normalize_timestamp(time()), 0, |
266 | 'text/plain', 'd41d8cd98f00b204e9800998ecf8427e') |
267 | - listing = broker.list_objects_iter(10, '3/0048', None, None) |
268 | + listing = broker.list_objects_iter(10, '3/0048', None, None, None) |
269 | self.assertEquals(len(listing), 10) |
270 | self.assertEquals([row[0] for row in listing], |
271 | ['3/0048/0049', '3/0049', '3/0049/', |
272 | '3/0049/0049', '3/0050', '3/0050/0049', '3/0051', '3/0051/0049', |
273 | '3/0052', '3/0052/0049']) |
274 | |
275 | - listing = broker.list_objects_iter(10, '3/0048', '3/', '/') |
276 | + listing = broker.list_objects_iter(10, '3/0048', None, '3/', '/') |
277 | self.assertEquals(len(listing), 10) |
278 | self.assertEquals([row[0] for row in listing], |
279 | ['3/0048/', '3/0049', '3/0049/', '3/0050', |
280 | '3/0050/', '3/0051', '3/0051/', '3/0052', '3/0052/', '3/0053']) |
281 | |
282 | - listing = broker.list_objects_iter(10, None, '3/0049/', '/') |
283 | + listing = broker.list_objects_iter(10, None, None, '3/0049/', '/') |
284 | self.assertEquals(len(listing), 2) |
285 | self.assertEquals([row[0] for row in listing], |
286 | ['3/0049/', '3/0049/0049']) |
287 | |
288 | - listing = broker.list_objects_iter(10, None, None, None, '3/0049') |
289 | + listing = broker.list_objects_iter(10, None, None, None, None, |
290 | + '3/0049') |
291 | self.assertEquals(len(listing), 1) |
292 | self.assertEquals([row[0] for row in listing], ['3/0049/0049']) |
293 | |
294 | - listing = broker.list_objects_iter(2, None, '3/', '/') |
295 | + listing = broker.list_objects_iter(2, None, None, '3/', '/') |
296 | self.assertEquals(len(listing), 2) |
297 | self.assertEquals([row[0] for row in listing], ['3/0000', '3/0000/']) |
298 | |
299 | - listing = broker.list_objects_iter(2, None, None, None, '3') |
300 | + listing = broker.list_objects_iter(2, None, None, None, None, '3') |
301 | self.assertEquals(len(listing), 2) |
302 | self.assertEquals([row[0] for row in listing], ['3/0000', '3/0001']) |
303 | |
304 | @@ -1082,11 +1088,11 @@ |
305 | |
306 | #def list_objects_iter(self, limit, marker, prefix, delimiter, path=None, |
307 | # format=None): |
308 | - listing = broker.list_objects_iter(100, None, '/pets/f', '/') |
309 | - self.assertEquals([row[0] for row in listing], ['/pets/fish/', '/pets/fish_info.txt']) |
310 | - listing = broker.list_objects_iter(100, None, '/pets/fish', '/') |
311 | - self.assertEquals([row[0] for row in listing], ['/pets/fish/', '/pets/fish_info.txt']) |
312 | - listing = broker.list_objects_iter(100, None, '/pets/fish/', '/') |
313 | + listing = broker.list_objects_iter(100, None, None, '/pets/f', '/') |
314 | + self.assertEquals([row[0] for row in listing], ['/pets/fish/', '/pets/fish_info.txt']) |
315 | + listing = broker.list_objects_iter(100, None, None, '/pets/fish', '/') |
316 | + self.assertEquals([row[0] for row in listing], ['/pets/fish/', '/pets/fish_info.txt']) |
317 | + listing = broker.list_objects_iter(100, None, None, '/pets/fish/', '/') |
318 | self.assertEquals([row[0] for row in listing], ['/pets/fish/a', '/pets/fish/b']) |
319 | |
320 | def test_double_check_trailing_delimiter(self): |
321 | @@ -1114,19 +1120,19 @@ |
322 | 'text/plain', 'd41d8cd98f00b204e9800998ecf8427e') |
323 | broker.put_object('c', normalize_timestamp(time()), 0, |
324 | 'text/plain', 'd41d8cd98f00b204e9800998ecf8427e') |
325 | - listing = broker.list_objects_iter(15, None, None, None) |
326 | + listing = broker.list_objects_iter(15, None, None, None, None) |
327 | self.assertEquals(len(listing), 10) |
328 | self.assertEquals([row[0] for row in listing], |
329 | ['a', 'a/', 'a/a', 'a/a/a', 'a/a/b', 'a/b', 'b', 'b/a', 'b/b', 'c']) |
330 | - listing = broker.list_objects_iter(15, None, '', '/') |
331 | + listing = broker.list_objects_iter(15, None, None, '', '/') |
332 | self.assertEquals(len(listing), 5) |
333 | self.assertEquals([row[0] for row in listing], |
334 | ['a', 'a/', 'b', 'b/', 'c']) |
335 | - listing = broker.list_objects_iter(15, None, 'a/', '/') |
336 | + listing = broker.list_objects_iter(15, None, None, 'a/', '/') |
337 | self.assertEquals(len(listing), 4) |
338 | self.assertEquals([row[0] for row in listing], |
339 | ['a/', 'a/a', 'a/a/', 'a/b']) |
340 | - listing = broker.list_objects_iter(15, None, 'b/', '/') |
341 | + listing = broker.list_objects_iter(15, None, None, 'b/', '/') |
342 | self.assertEquals(len(listing), 2) |
343 | self.assertEquals([row[0] for row in listing], ['b/a', 'b/b']) |
344 | |
345 | @@ -1646,57 +1652,62 @@ |
346 | broker.put_container('3/%04d/0049' % cont, |
347 | normalize_timestamp(time()), 0, 0, 0) |
348 | |
349 | - listing = broker.list_containers_iter(100, '', None, '') |
350 | + listing = broker.list_containers_iter(100, '', None, None, '') |
351 | self.assertEquals(len(listing), 100) |
352 | self.assertEquals(listing[0][0], '0/0000') |
353 | self.assertEquals(listing[-1][0], '0/0099') |
354 | |
355 | - listing = broker.list_containers_iter(100, '0/0099', None, '') |
356 | + listing = broker.list_containers_iter(100, '', '0/0050', None, '') |
357 | + self.assertEquals(len(listing), 51) |
358 | + self.assertEquals(listing[0][0], '0/0000') |
359 | + self.assertEquals(listing[-1][0], '0/0050') |
360 | + |
361 | + listing = broker.list_containers_iter(100, '0/0099', None, None, '') |
362 | self.assertEquals(len(listing), 100) |
363 | self.assertEquals(listing[0][0], '0/0100') |
364 | self.assertEquals(listing[-1][0], '1/0074') |
365 | |
366 | - listing = broker.list_containers_iter(55, '1/0074', None, '') |
367 | + listing = broker.list_containers_iter(55, '1/0074', None, None, '') |
368 | self.assertEquals(len(listing), 55) |
369 | self.assertEquals(listing[0][0], '1/0075') |
370 | self.assertEquals(listing[-1][0], '2/0004') |
371 | |
372 | - listing = broker.list_containers_iter(10, '', '0/01', '') |
373 | - self.assertEquals(len(listing), 10) |
374 | - self.assertEquals(listing[0][0], '0/0100') |
375 | - self.assertEquals(listing[-1][0], '0/0109') |
376 | - |
377 | - listing = broker.list_containers_iter(10, '', '0/01', '/') |
378 | - self.assertEquals(len(listing), 10) |
379 | - self.assertEquals(listing[0][0], '0/0100') |
380 | - self.assertEquals(listing[-1][0], '0/0109') |
381 | - |
382 | - listing = broker.list_containers_iter(10, '', '0/', '/') |
383 | + listing = broker.list_containers_iter(10, '', None, '0/01', '') |
384 | + self.assertEquals(len(listing), 10) |
385 | + self.assertEquals(listing[0][0], '0/0100') |
386 | + self.assertEquals(listing[-1][0], '0/0109') |
387 | + |
388 | + listing = broker.list_containers_iter(10, '', None, '0/01', '/') |
389 | + self.assertEquals(len(listing), 10) |
390 | + self.assertEquals(listing[0][0], '0/0100') |
391 | + self.assertEquals(listing[-1][0], '0/0109') |
392 | + |
393 | + listing = broker.list_containers_iter(10, '', None, '0/', '/') |
394 | self.assertEquals(len(listing), 10) |
395 | self.assertEquals(listing[0][0], '0/0000') |
396 | self.assertEquals(listing[-1][0], '0/0009') |
397 | |
398 | - listing = broker.list_containers_iter(10, '', '', '/') |
399 | + listing = broker.list_containers_iter(10, '', None, '', '/') |
400 | self.assertEquals(len(listing), 4) |
401 | self.assertEquals([row[0] for row in listing], |
402 | ['0/', '1/', '2/', '3/']) |
403 | |
404 | - listing = broker.list_containers_iter(10, '2/', None, '/') |
405 | + listing = broker.list_containers_iter(10, '2/', None, None, '/') |
406 | self.assertEquals(len(listing), 1) |
407 | self.assertEquals([row[0] for row in listing], ['3/']) |
408 | |
409 | - listing = broker.list_containers_iter(10, '', '2', '/') |
410 | + listing = broker.list_containers_iter(10, '', None, '2', '/') |
411 | self.assertEquals(len(listing), 1) |
412 | self.assertEquals([row[0] for row in listing], ['2/']) |
413 | |
414 | - listing = broker.list_containers_iter(10, '2/0050', '2/', '/') |
415 | + listing = broker.list_containers_iter(10, '2/0050', None, '2/', '/') |
416 | self.assertEquals(len(listing), 10) |
417 | self.assertEquals(listing[0][0], '2/0051') |
418 | self.assertEquals(listing[1][0], '2/0051/') |
419 | self.assertEquals(listing[2][0], '2/0052') |
420 | self.assertEquals(listing[-1][0], '2/0059') |
421 | |
422 | - listing = broker.list_containers_iter(10, '3/0045', '3/', '/') |
423 | + listing = broker.list_containers_iter(10, '3/0045', None, '3/', '/') |
424 | self.assertEquals(len(listing), 10) |
425 | self.assertEquals([row[0] for row in listing], |
426 | ['3/0045/', '3/0046', '3/0046/', '3/0047', |
427 | @@ -1704,21 +1715,21 @@ |
428 | '3/0049/', '3/0050']) |
429 | |
430 | broker.put_container('3/0049/', normalize_timestamp(time()), 0, 0, 0) |
431 | - listing = broker.list_containers_iter(10, '3/0048', None, None) |
432 | + listing = broker.list_containers_iter(10, '3/0048', None, None, None) |
433 | self.assertEquals(len(listing), 10) |
434 | self.assertEquals([row[0] for row in listing], |
435 | ['3/0048/0049', '3/0049', '3/0049/', '3/0049/0049', |
436 | '3/0050', '3/0050/0049', '3/0051', '3/0051/0049', |
437 | '3/0052', '3/0052/0049']) |
438 | |
439 | - listing = broker.list_containers_iter(10, '3/0048', '3/', '/') |
440 | + listing = broker.list_containers_iter(10, '3/0048', None, '3/', '/') |
441 | self.assertEquals(len(listing), 10) |
442 | self.assertEquals([row[0] for row in listing], |
443 | ['3/0048/', '3/0049', '3/0049/', '3/0050', |
444 | '3/0050/', '3/0051', '3/0051/', '3/0052', |
445 | '3/0052/', '3/0053']) |
446 | |
447 | - listing = broker.list_containers_iter(10, None, '3/0049/', '/') |
448 | + listing = broker.list_containers_iter(10, None, None, '3/0049/', '/') |
449 | self.assertEquals(len(listing), 2) |
450 | self.assertEquals([row[0] for row in listing], |
451 | ['3/0049/', '3/0049/0049']) |
452 | @@ -1738,20 +1749,20 @@ |
453 | broker.put_container('b/a', normalize_timestamp(time()), 0, 0, 0) |
454 | broker.put_container('b/b', normalize_timestamp(time()), 0, 0, 0) |
455 | broker.put_container('c', normalize_timestamp(time()), 0, 0, 0) |
456 | - listing = broker.list_containers_iter(15, None, None, None) |
457 | + listing = broker.list_containers_iter(15, None, None, None, None) |
458 | self.assertEquals(len(listing), 10) |
459 | self.assertEquals([row[0] for row in listing], |
460 | ['a', 'a/', 'a/a', 'a/a/a', 'a/a/b', 'a/b', 'b', |
461 | 'b/a', 'b/b', 'c']) |
462 | - listing = broker.list_containers_iter(15, None, '', '/') |
463 | + listing = broker.list_containers_iter(15, None, None, '', '/') |
464 | self.assertEquals(len(listing), 5) |
465 | self.assertEquals([row[0] for row in listing], |
466 | ['a', 'a/', 'b', 'b/', 'c']) |
467 | - listing = broker.list_containers_iter(15, None, 'a/', '/') |
468 | + listing = broker.list_containers_iter(15, None, None, 'a/', '/') |
469 | self.assertEquals(len(listing), 4) |
470 | self.assertEquals([row[0] for row in listing], |
471 | ['a/', 'a/a', 'a/a/', 'a/b']) |
472 | - listing = broker.list_containers_iter(15, None, 'b/', '/') |
473 | + listing = broker.list_containers_iter(15, None, None, 'b/', '/') |
474 | self.assertEquals(len(listing), 2) |
475 | self.assertEquals([row[0] for row in listing], ['b/a', 'b/b']) |
476 | |
477 | |
478 | === modified file 'test/unit/stats/test_log_processor.py' |
479 | --- test/unit/stats/test_log_processor.py 2010-11-05 05:26:53 +0000 |
480 | +++ test/unit/stats/test_log_processor.py 2010-11-17 15:38:03 +0000 |
481 | @@ -46,12 +46,16 @@ |
482 | pass |
483 | |
484 | class DumbInternalProxy(object): |
485 | - def get_container_list(self, account, container, marker=None): |
486 | + def get_container_list(self, account, container, marker=None, |
487 | + end_marker=None): |
488 | n = '2010/03/14/13/obj1' |
489 | if marker is None or n > marker: |
490 | + if end_marker and n <= end_marker: |
491 | + return [{'name': n}] |
492 | + elif end_marker: |
493 | + return [] |
494 | return [{'name': n}] |
495 | - else: |
496 | - return [] |
497 | + return [] |
498 | |
499 | def get_object(self, account, container, object_name): |
500 | code = 200 |
I think "end_marker" is a good name, but better ones may be suggested. It's a lot easier to change it now.