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 | 224 | marker = '' | 224 | marker = '' |
6 | 225 | while True: | 225 | while True: |
7 | 226 | containers = \ | 226 | containers = \ |
9 | 227 | list(broker.list_containers_iter(1000, marker, None, None)) | 227 | list(broker.list_containers_iter(1000, marker, None, None, |
10 | 228 | None)) | ||
11 | 228 | if not containers: | 229 | if not containers: |
12 | 229 | break | 230 | break |
13 | 230 | try: | 231 | try: |
14 | 231 | 232 | ||
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 | 200 | return HTTPPreconditionFailed(request=req, | 200 | return HTTPPreconditionFailed(request=req, |
20 | 201 | body='Maximum limit is %d' % ACCOUNT_LISTING_LIMIT) | 201 | body='Maximum limit is %d' % ACCOUNT_LISTING_LIMIT) |
21 | 202 | marker = get_param(req, 'marker', '') | 202 | marker = get_param(req, 'marker', '') |
22 | 203 | end_marker = get_param(req, 'end_marker') | ||
23 | 203 | query_format = get_param(req, 'format') | 204 | query_format = get_param(req, 'format') |
24 | 204 | except UnicodeDecodeError, err: | 205 | except UnicodeDecodeError, err: |
25 | 205 | return HTTPBadRequest(body='parameters not utf8', | 206 | return HTTPBadRequest(body='parameters not utf8', |
26 | @@ -210,8 +211,8 @@ | |||
27 | 210 | ['text/plain', 'application/json', | 211 | ['text/plain', 'application/json', |
28 | 211 | 'application/xml', 'text/xml'], | 212 | 'application/xml', 'text/xml'], |
29 | 212 | default_match='text/plain') | 213 | default_match='text/plain') |
32 | 213 | account_list = broker.list_containers_iter(limit, marker, prefix, | 214 | account_list = broker.list_containers_iter(limit, marker, end_marker, |
33 | 214 | delimiter) | 215 | prefix, delimiter) |
34 | 215 | if out_content_type == 'application/json': | 216 | if out_content_type == 'application/json': |
35 | 216 | json_pattern = ['"name":%s', '"count":%s', '"bytes":%s'] | 217 | json_pattern = ['"name":%s', '"count":%s', '"bytes":%s'] |
36 | 217 | json_pattern = '{' + ','.join(json_pattern) + '}' | 218 | json_pattern = '{' + ','.join(json_pattern) + '}' |
37 | 218 | 219 | ||
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 | 940 | rv.append(row['name']) | 940 | rv.append(row['name']) |
43 | 941 | return list(set(rv)) | 941 | return list(set(rv)) |
44 | 942 | 942 | ||
47 | 943 | def list_objects_iter(self, limit, marker, prefix, delimiter, path=None, | 943 | def list_objects_iter(self, limit, marker, end_marker, prefix, delimiter, |
48 | 944 | format=None): | 944 | path=None, format=None): |
49 | 945 | """ | 945 | """ |
50 | 946 | Get a list of objects sorted by name starting at marker onward, up | 946 | Get a list of objects sorted by name starting at marker onward, up |
51 | 947 | to limit entries. Entries will begin with the prefix and will not | 947 | to limit entries. Entries will begin with the prefix and will not |
52 | @@ -949,6 +949,7 @@ | |||
53 | 949 | 949 | ||
54 | 950 | :param limit: maximum number of entries to get | 950 | :param limit: maximum number of entries to get |
55 | 951 | :param marker: marker query | 951 | :param marker: marker query |
56 | 952 | :param end_marker: end marker query | ||
57 | 952 | :param prefix: prefix query | 953 | :param prefix: prefix query |
58 | 953 | :param delimeter: delimeter for query | 954 | :param delimeter: delimeter for query |
59 | 954 | :param path: if defined, will set the prefix and delimter based on | 955 | :param path: if defined, will set the prefix and delimter based on |
60 | @@ -977,6 +978,9 @@ | |||
61 | 977 | query = '''SELECT name, created_at, size, content_type, etag | 978 | query = '''SELECT name, created_at, size, content_type, etag |
62 | 978 | FROM object WHERE''' | 979 | FROM object WHERE''' |
63 | 979 | query_args = [] | 980 | query_args = [] |
64 | 981 | if end_marker: | ||
65 | 982 | query += ' name <= ? AND' | ||
66 | 983 | query_args.append(end_marker) | ||
67 | 980 | if marker and marker >= prefix: | 984 | if marker and marker >= prefix: |
68 | 981 | query += ' name > ? AND' | 985 | query += ' name > ? AND' |
69 | 982 | query_args.append(marker) | 986 | query_args.append(marker) |
70 | @@ -1440,7 +1444,8 @@ | |||
71 | 1440 | rv.append(row['name']) | 1444 | rv.append(row['name']) |
72 | 1441 | return list(set(rv)) | 1445 | return list(set(rv)) |
73 | 1442 | 1446 | ||
75 | 1443 | def list_containers_iter(self, limit, marker, prefix, delimiter): | 1447 | def list_containers_iter(self, limit, marker, end_marker, prefix, |
76 | 1448 | delimiter): | ||
77 | 1444 | """ | 1449 | """ |
78 | 1445 | Get a list of containerss sorted by name starting at marker onward, up | 1450 | Get a list of containerss sorted by name starting at marker onward, up |
79 | 1446 | to limit entries. Entries will begin with the prefix and will not | 1451 | to limit entries. Entries will begin with the prefix and will not |
80 | @@ -1448,6 +1453,7 @@ | |||
81 | 1448 | 1453 | ||
82 | 1449 | :param limit: maximum number of entries to get | 1454 | :param limit: maximum number of entries to get |
83 | 1450 | :param marker: marker query | 1455 | :param marker: marker query |
84 | 1456 | :param end_marker: end marker query | ||
85 | 1451 | :param prefix: prefix query | 1457 | :param prefix: prefix query |
86 | 1452 | :param delimeter: delimeter for query | 1458 | :param delimeter: delimeter for query |
87 | 1453 | 1459 | ||
88 | @@ -1469,6 +1475,9 @@ | |||
89 | 1469 | FROM container | 1475 | FROM container |
90 | 1470 | WHERE deleted = 0 AND """ | 1476 | WHERE deleted = 0 AND """ |
91 | 1471 | query_args = [] | 1477 | query_args = [] |
92 | 1478 | if end_marker: | ||
93 | 1479 | query += ' name <= ? AND' | ||
94 | 1480 | query_args.append(end_marker) | ||
95 | 1472 | if marker and marker >= prefix: | 1481 | if marker and marker >= prefix: |
96 | 1473 | query += ' name > ? AND' | 1482 | query += ' name > ? AND' |
97 | 1474 | query_args.append(marker) | 1483 | query_args.append(marker) |
98 | 1475 | 1484 | ||
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 | 156 | tries += 1 | 156 | tries += 1 |
104 | 157 | return 200 <= resp.status_int < 300 | 157 | return 200 <= resp.status_int < 300 |
105 | 158 | 158 | ||
108 | 159 | def get_container_list(self, account, container, marker=None, limit=None, | 159 | def get_container_list(self, account, container, marker=None, |
109 | 160 | prefix=None, delimiter=None, full_listing=True): | 160 | end_marker=None, limit=None, prefix=None, |
110 | 161 | delimiter=None, full_listing=True): | ||
111 | 161 | """ | 162 | """ |
112 | 162 | Get container listing. | 163 | Get container listing. |
113 | 163 | 164 | ||
114 | 164 | :param account: account name for the container | 165 | :param account: account name for the container |
115 | 165 | :param container: container name to get the listing of | 166 | :param container: container name to get the listing of |
116 | 166 | :param marker: marker query | 167 | :param marker: marker query |
117 | 168 | :param end_marker: end marker query | ||
118 | 167 | :param limit: limit to query | 169 | :param limit: limit to query |
119 | 168 | :param prefix: prefix query | 170 | :param prefix: prefix query |
120 | 169 | :param delimeter: delimeter for query | 171 | :param delimeter: delimeter for query |
121 | @@ -173,7 +175,7 @@ | |||
122 | 173 | if full_listing: | 175 | if full_listing: |
123 | 174 | rv = [] | 176 | rv = [] |
124 | 175 | listing = self.get_container_list(account, container, marker, | 177 | listing = self.get_container_list(account, container, marker, |
126 | 176 | limit, prefix, delimiter, full_listing=False) | 178 | end_marker, limit, prefix, delimiter, full_listing=False) |
127 | 177 | while listing: | 179 | while listing: |
128 | 178 | rv.extend(listing) | 180 | rv.extend(listing) |
129 | 179 | if not delimiter: | 181 | if not delimiter: |
130 | @@ -181,12 +183,14 @@ | |||
131 | 181 | else: | 183 | else: |
132 | 182 | marker = listing[-1].get('name', listing[-1].get('subdir')) | 184 | marker = listing[-1].get('name', listing[-1].get('subdir')) |
133 | 183 | listing = self.get_container_list(account, container, marker, | 185 | listing = self.get_container_list(account, container, marker, |
135 | 184 | limit, prefix, delimiter, full_listing=False) | 186 | end_marker, limit, prefix, delimiter, full_listing=False) |
136 | 185 | return rv | 187 | return rv |
137 | 186 | path = '/v1/%s/%s' % (account, container) | 188 | path = '/v1/%s/%s' % (account, container) |
138 | 187 | qs = 'format=json' | 189 | qs = 'format=json' |
139 | 188 | if marker: | 190 | if marker: |
140 | 189 | qs += '&marker=%s' % quote(marker) | 191 | qs += '&marker=%s' % quote(marker) |
141 | 192 | if end_marker: | ||
142 | 193 | qs += '&end_marker=%s' % quote(end_marker) | ||
143 | 190 | if limit: | 194 | if limit: |
144 | 191 | qs += '&limit=%d' % limit | 195 | qs += '&limit=%d' % limit |
145 | 192 | if prefix: | 196 | if prefix: |
146 | 193 | 197 | ||
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 | 267 | # delimiters can be made more flexible later | 267 | # delimiters can be made more flexible later |
152 | 268 | return HTTPPreconditionFailed(body='Bad delimiter') | 268 | return HTTPPreconditionFailed(body='Bad delimiter') |
153 | 269 | marker = get_param(req, 'marker', '') | 269 | marker = get_param(req, 'marker', '') |
154 | 270 | end_marker = get_param(req, 'end_marker') | ||
155 | 270 | limit = CONTAINER_LISTING_LIMIT | 271 | limit = CONTAINER_LISTING_LIMIT |
156 | 271 | given_limit = get_param(req, 'limit') | 272 | given_limit = get_param(req, 'limit') |
157 | 272 | if given_limit and given_limit.isdigit(): | 273 | if given_limit and given_limit.isdigit(): |
158 | @@ -284,8 +285,8 @@ | |||
159 | 284 | ['text/plain', 'application/json', | 285 | ['text/plain', 'application/json', |
160 | 285 | 'application/xml', 'text/xml'], | 286 | 'application/xml', 'text/xml'], |
161 | 286 | default_match='text/plain') | 287 | default_match='text/plain') |
164 | 287 | container_list = broker.list_objects_iter(limit, marker, prefix, | 288 | container_list = broker.list_objects_iter(limit, marker, end_marker, |
165 | 288 | delimiter, path) | 289 | prefix, delimiter, path) |
166 | 289 | if out_content_type == 'application/json': | 290 | if out_content_type == 'application/json': |
167 | 290 | json_pattern = ['"name":%s', '"hash":"%s"', '"bytes":%s', | 291 | json_pattern = ['"name":%s', '"hash":"%s"', '"bytes":%s', |
168 | 291 | '"content_type":%s, "last_modified":"%s"'] | 292 | '"content_type":%s, "last_modified":"%s"'] |
169 | 292 | 293 | ||
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 | 158 | container_listing = self.internal_proxy.get_container_list( | 158 | container_listing = self.internal_proxy.get_container_list( |
175 | 159 | swift_account, | 159 | swift_account, |
176 | 160 | container_name, | 160 | container_name, |
178 | 161 | marker=search_key) | 161 | marker=search_key, |
179 | 162 | end_marker=end_key) | ||
180 | 162 | results = [] | 163 | results = [] |
181 | 163 | if container_listing is not None: | 164 | if container_listing is not None: |
182 | 164 | if listing_filter is None: | 165 | if listing_filter is None: |
183 | 165 | listing_filter = set() | 166 | listing_filter = set() |
184 | 166 | for item in container_listing: | 167 | for item in container_listing: |
185 | 167 | name = item['name'] | 168 | name = item['name'] |
186 | 168 | if end_key and name > end_key: | ||
187 | 169 | break | ||
188 | 170 | if name not in listing_filter: | 169 | if name not in listing_filter: |
189 | 171 | results.append(name) | 170 | results.append(name) |
190 | 172 | return results | 171 | return results |
191 | 173 | 172 | ||
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 | 978 | normalize_timestamp(time()), 0, 'text/plain', | 978 | normalize_timestamp(time()), 0, 'text/plain', |
197 | 979 | 'd41d8cd98f00b204e9800998ecf8427e') | 979 | 'd41d8cd98f00b204e9800998ecf8427e') |
198 | 980 | 980 | ||
200 | 981 | listing = broker.list_objects_iter(100, '', None, '') | 981 | listing = broker.list_objects_iter(100, '', None, None, '') |
201 | 982 | self.assertEquals(len(listing), 100) | 982 | self.assertEquals(len(listing), 100) |
202 | 983 | self.assertEquals(listing[0][0], '0/0000') | 983 | self.assertEquals(listing[0][0], '0/0000') |
203 | 984 | self.assertEquals(listing[-1][0], '0/0099') | 984 | self.assertEquals(listing[-1][0], '0/0099') |
204 | 985 | 985 | ||
206 | 986 | listing = broker.list_objects_iter(100, '0/0099', None, '') | 986 | listing = broker.list_objects_iter(100, '', '0/0050', None, '') |
207 | 987 | self.assertEquals(len(listing), 51) | ||
208 | 988 | self.assertEquals(listing[0][0], '0/0000') | ||
209 | 989 | self.assertEquals(listing[-1][0], '0/0050') | ||
210 | 990 | |||
211 | 991 | listing = broker.list_objects_iter(100, '0/0099', None, None, '') | ||
212 | 987 | self.assertEquals(len(listing), 100) | 992 | self.assertEquals(len(listing), 100) |
213 | 988 | self.assertEquals(listing[0][0], '0/0100') | 993 | self.assertEquals(listing[0][0], '0/0100') |
214 | 989 | self.assertEquals(listing[-1][0], '1/0074') | 994 | self.assertEquals(listing[-1][0], '1/0074') |
215 | 990 | 995 | ||
217 | 991 | listing = broker.list_objects_iter(55, '1/0074', None, '') | 996 | listing = broker.list_objects_iter(55, '1/0074', None, None, '') |
218 | 992 | self.assertEquals(len(listing), 55) | 997 | self.assertEquals(len(listing), 55) |
219 | 993 | self.assertEquals(listing[0][0], '1/0075') | 998 | self.assertEquals(listing[0][0], '1/0075') |
220 | 994 | self.assertEquals(listing[-1][0], '2/0004') | 999 | self.assertEquals(listing[-1][0], '2/0004') |
221 | 995 | 1000 | ||
223 | 996 | listing = broker.list_objects_iter(10, '', '0/01', '') | 1001 | listing = broker.list_objects_iter(10, '', None, '0/01', '') |
224 | 997 | self.assertEquals(len(listing), 10) | 1002 | self.assertEquals(len(listing), 10) |
225 | 998 | self.assertEquals(listing[0][0], '0/0100') | 1003 | self.assertEquals(listing[0][0], '0/0100') |
226 | 999 | self.assertEquals(listing[-1][0], '0/0109') | 1004 | self.assertEquals(listing[-1][0], '0/0109') |
227 | 1000 | 1005 | ||
229 | 1001 | listing = broker.list_objects_iter(10, '', '0/', '/') | 1006 | listing = broker.list_objects_iter(10, '', None, '0/', '/') |
230 | 1002 | self.assertEquals(len(listing), 10) | 1007 | self.assertEquals(len(listing), 10) |
231 | 1003 | self.assertEquals(listing[0][0], '0/0000') | 1008 | self.assertEquals(listing[0][0], '0/0000') |
232 | 1004 | self.assertEquals(listing[-1][0], '0/0009') | 1009 | self.assertEquals(listing[-1][0], '0/0009') |
233 | 1005 | 1010 | ||
235 | 1006 | listing = broker.list_objects_iter(10, '', '', '/') | 1011 | listing = broker.list_objects_iter(10, '', None, '', '/') |
236 | 1007 | self.assertEquals(len(listing), 4) | 1012 | self.assertEquals(len(listing), 4) |
237 | 1008 | self.assertEquals([row[0] for row in listing], | 1013 | self.assertEquals([row[0] for row in listing], |
238 | 1009 | ['0/', '1/', '2/', '3/']) | 1014 | ['0/', '1/', '2/', '3/']) |
239 | 1010 | 1015 | ||
241 | 1011 | listing = broker.list_objects_iter(10, '2', None, '/') | 1016 | listing = broker.list_objects_iter(10, '2', None, None, '/') |
242 | 1012 | self.assertEquals(len(listing), 2) | 1017 | self.assertEquals(len(listing), 2) |
243 | 1013 | self.assertEquals([row[0] for row in listing], ['2/', '3/']) | 1018 | self.assertEquals([row[0] for row in listing], ['2/', '3/']) |
244 | 1014 | 1019 | ||
246 | 1015 | listing = broker.list_objects_iter(10, '2/', None, '/') | 1020 | listing = broker.list_objects_iter(10, '2/',None, None, '/') |
247 | 1016 | self.assertEquals(len(listing), 1) | 1021 | self.assertEquals(len(listing), 1) |
248 | 1017 | self.assertEquals([row[0] for row in listing], ['3/']) | 1022 | self.assertEquals([row[0] for row in listing], ['3/']) |
249 | 1018 | 1023 | ||
251 | 1019 | listing = broker.list_objects_iter(10, '2/0050', '2/', '/') | 1024 | listing = broker.list_objects_iter(10, '2/0050', None, '2/', '/') |
252 | 1020 | self.assertEquals(len(listing), 10) | 1025 | self.assertEquals(len(listing), 10) |
253 | 1021 | self.assertEquals(listing[0][0], '2/0051') | 1026 | self.assertEquals(listing[0][0], '2/0051') |
254 | 1022 | self.assertEquals(listing[1][0], '2/0051/') | 1027 | self.assertEquals(listing[1][0], '2/0051/') |
255 | 1023 | self.assertEquals(listing[2][0], '2/0052') | 1028 | self.assertEquals(listing[2][0], '2/0052') |
256 | 1024 | self.assertEquals(listing[-1][0], '2/0059') | 1029 | self.assertEquals(listing[-1][0], '2/0059') |
257 | 1025 | 1030 | ||
259 | 1026 | listing = broker.list_objects_iter(10, '3/0045', '3/', '/') | 1031 | listing = broker.list_objects_iter(10, '3/0045', None, '3/', '/') |
260 | 1027 | self.assertEquals(len(listing), 10) | 1032 | self.assertEquals(len(listing), 10) |
261 | 1028 | self.assertEquals([row[0] for row in listing], | 1033 | self.assertEquals([row[0] for row in listing], |
262 | 1029 | ['3/0045/', '3/0046', '3/0046/', '3/0047', | 1034 | ['3/0045/', '3/0046', '3/0046/', '3/0047', |
263 | @@ -1032,33 +1037,34 @@ | |||
264 | 1032 | 1037 | ||
265 | 1033 | broker.put_object('3/0049/', normalize_timestamp(time()), 0, | 1038 | broker.put_object('3/0049/', normalize_timestamp(time()), 0, |
266 | 1034 | 'text/plain', 'd41d8cd98f00b204e9800998ecf8427e') | 1039 | 'text/plain', 'd41d8cd98f00b204e9800998ecf8427e') |
268 | 1035 | listing = broker.list_objects_iter(10, '3/0048', None, None) | 1040 | listing = broker.list_objects_iter(10, '3/0048', None, None, None) |
269 | 1036 | self.assertEquals(len(listing), 10) | 1041 | self.assertEquals(len(listing), 10) |
270 | 1037 | self.assertEquals([row[0] for row in listing], | 1042 | self.assertEquals([row[0] for row in listing], |
271 | 1038 | ['3/0048/0049', '3/0049', '3/0049/', | 1043 | ['3/0048/0049', '3/0049', '3/0049/', |
272 | 1039 | '3/0049/0049', '3/0050', '3/0050/0049', '3/0051', '3/0051/0049', | 1044 | '3/0049/0049', '3/0050', '3/0050/0049', '3/0051', '3/0051/0049', |
273 | 1040 | '3/0052', '3/0052/0049']) | 1045 | '3/0052', '3/0052/0049']) |
274 | 1041 | 1046 | ||
276 | 1042 | listing = broker.list_objects_iter(10, '3/0048', '3/', '/') | 1047 | listing = broker.list_objects_iter(10, '3/0048', None, '3/', '/') |
277 | 1043 | self.assertEquals(len(listing), 10) | 1048 | self.assertEquals(len(listing), 10) |
278 | 1044 | self.assertEquals([row[0] for row in listing], | 1049 | self.assertEquals([row[0] for row in listing], |
279 | 1045 | ['3/0048/', '3/0049', '3/0049/', '3/0050', | 1050 | ['3/0048/', '3/0049', '3/0049/', '3/0050', |
280 | 1046 | '3/0050/', '3/0051', '3/0051/', '3/0052', '3/0052/', '3/0053']) | 1051 | '3/0050/', '3/0051', '3/0051/', '3/0052', '3/0052/', '3/0053']) |
281 | 1047 | 1052 | ||
283 | 1048 | listing = broker.list_objects_iter(10, None, '3/0049/', '/') | 1053 | listing = broker.list_objects_iter(10, None, None, '3/0049/', '/') |
284 | 1049 | self.assertEquals(len(listing), 2) | 1054 | self.assertEquals(len(listing), 2) |
285 | 1050 | self.assertEquals([row[0] for row in listing], | 1055 | self.assertEquals([row[0] for row in listing], |
286 | 1051 | ['3/0049/', '3/0049/0049']) | 1056 | ['3/0049/', '3/0049/0049']) |
287 | 1052 | 1057 | ||
289 | 1053 | listing = broker.list_objects_iter(10, None, None, None, '3/0049') | 1058 | listing = broker.list_objects_iter(10, None, None, None, None, |
290 | 1059 | '3/0049') | ||
291 | 1054 | self.assertEquals(len(listing), 1) | 1060 | self.assertEquals(len(listing), 1) |
292 | 1055 | self.assertEquals([row[0] for row in listing], ['3/0049/0049']) | 1061 | self.assertEquals([row[0] for row in listing], ['3/0049/0049']) |
293 | 1056 | 1062 | ||
295 | 1057 | listing = broker.list_objects_iter(2, None, '3/', '/') | 1063 | listing = broker.list_objects_iter(2, None, None, '3/', '/') |
296 | 1058 | self.assertEquals(len(listing), 2) | 1064 | self.assertEquals(len(listing), 2) |
297 | 1059 | self.assertEquals([row[0] for row in listing], ['3/0000', '3/0000/']) | 1065 | self.assertEquals([row[0] for row in listing], ['3/0000', '3/0000/']) |
298 | 1060 | 1066 | ||
300 | 1061 | listing = broker.list_objects_iter(2, None, None, None, '3') | 1067 | listing = broker.list_objects_iter(2, None, None, None, None, '3') |
301 | 1062 | self.assertEquals(len(listing), 2) | 1068 | self.assertEquals(len(listing), 2) |
302 | 1063 | self.assertEquals([row[0] for row in listing], ['3/0000', '3/0001']) | 1069 | self.assertEquals([row[0] for row in listing], ['3/0000', '3/0001']) |
303 | 1064 | 1070 | ||
304 | @@ -1082,11 +1088,11 @@ | |||
305 | 1082 | 1088 | ||
306 | 1083 | #def list_objects_iter(self, limit, marker, prefix, delimiter, path=None, | 1089 | #def list_objects_iter(self, limit, marker, prefix, delimiter, path=None, |
307 | 1084 | # format=None): | 1090 | # format=None): |
313 | 1085 | listing = broker.list_objects_iter(100, None, '/pets/f', '/') | 1091 | listing = broker.list_objects_iter(100, None, None, '/pets/f', '/') |
314 | 1086 | self.assertEquals([row[0] for row in listing], ['/pets/fish/', '/pets/fish_info.txt']) | 1092 | self.assertEquals([row[0] for row in listing], ['/pets/fish/', '/pets/fish_info.txt']) |
315 | 1087 | listing = broker.list_objects_iter(100, None, '/pets/fish', '/') | 1093 | listing = broker.list_objects_iter(100, None, None, '/pets/fish', '/') |
316 | 1088 | self.assertEquals([row[0] for row in listing], ['/pets/fish/', '/pets/fish_info.txt']) | 1094 | self.assertEquals([row[0] for row in listing], ['/pets/fish/', '/pets/fish_info.txt']) |
317 | 1089 | listing = broker.list_objects_iter(100, None, '/pets/fish/', '/') | 1095 | listing = broker.list_objects_iter(100, None, None, '/pets/fish/', '/') |
318 | 1090 | self.assertEquals([row[0] for row in listing], ['/pets/fish/a', '/pets/fish/b']) | 1096 | self.assertEquals([row[0] for row in listing], ['/pets/fish/a', '/pets/fish/b']) |
319 | 1091 | 1097 | ||
320 | 1092 | def test_double_check_trailing_delimiter(self): | 1098 | def test_double_check_trailing_delimiter(self): |
321 | @@ -1114,19 +1120,19 @@ | |||
322 | 1114 | 'text/plain', 'd41d8cd98f00b204e9800998ecf8427e') | 1120 | 'text/plain', 'd41d8cd98f00b204e9800998ecf8427e') |
323 | 1115 | broker.put_object('c', normalize_timestamp(time()), 0, | 1121 | broker.put_object('c', normalize_timestamp(time()), 0, |
324 | 1116 | 'text/plain', 'd41d8cd98f00b204e9800998ecf8427e') | 1122 | 'text/plain', 'd41d8cd98f00b204e9800998ecf8427e') |
326 | 1117 | listing = broker.list_objects_iter(15, None, None, None) | 1123 | listing = broker.list_objects_iter(15, None, None, None, None) |
327 | 1118 | self.assertEquals(len(listing), 10) | 1124 | self.assertEquals(len(listing), 10) |
328 | 1119 | self.assertEquals([row[0] for row in listing], | 1125 | self.assertEquals([row[0] for row in listing], |
329 | 1120 | ['a', 'a/', 'a/a', 'a/a/a', 'a/a/b', 'a/b', 'b', 'b/a', 'b/b', 'c']) | 1126 | ['a', 'a/', 'a/a', 'a/a/a', 'a/a/b', 'a/b', 'b', 'b/a', 'b/b', 'c']) |
331 | 1121 | listing = broker.list_objects_iter(15, None, '', '/') | 1127 | listing = broker.list_objects_iter(15, None, None, '', '/') |
332 | 1122 | self.assertEquals(len(listing), 5) | 1128 | self.assertEquals(len(listing), 5) |
333 | 1123 | self.assertEquals([row[0] for row in listing], | 1129 | self.assertEquals([row[0] for row in listing], |
334 | 1124 | ['a', 'a/', 'b', 'b/', 'c']) | 1130 | ['a', 'a/', 'b', 'b/', 'c']) |
336 | 1125 | listing = broker.list_objects_iter(15, None, 'a/', '/') | 1131 | listing = broker.list_objects_iter(15, None, None, 'a/', '/') |
337 | 1126 | self.assertEquals(len(listing), 4) | 1132 | self.assertEquals(len(listing), 4) |
338 | 1127 | self.assertEquals([row[0] for row in listing], | 1133 | self.assertEquals([row[0] for row in listing], |
339 | 1128 | ['a/', 'a/a', 'a/a/', 'a/b']) | 1134 | ['a/', 'a/a', 'a/a/', 'a/b']) |
341 | 1129 | listing = broker.list_objects_iter(15, None, 'b/', '/') | 1135 | listing = broker.list_objects_iter(15, None, None, 'b/', '/') |
342 | 1130 | self.assertEquals(len(listing), 2) | 1136 | self.assertEquals(len(listing), 2) |
343 | 1131 | self.assertEquals([row[0] for row in listing], ['b/a', 'b/b']) | 1137 | self.assertEquals([row[0] for row in listing], ['b/a', 'b/b']) |
344 | 1132 | 1138 | ||
345 | @@ -1646,57 +1652,62 @@ | |||
346 | 1646 | broker.put_container('3/%04d/0049' % cont, | 1652 | broker.put_container('3/%04d/0049' % cont, |
347 | 1647 | normalize_timestamp(time()), 0, 0, 0) | 1653 | normalize_timestamp(time()), 0, 0, 0) |
348 | 1648 | 1654 | ||
350 | 1649 | listing = broker.list_containers_iter(100, '', None, '') | 1655 | listing = broker.list_containers_iter(100, '', None, None, '') |
351 | 1650 | self.assertEquals(len(listing), 100) | 1656 | self.assertEquals(len(listing), 100) |
352 | 1651 | self.assertEquals(listing[0][0], '0/0000') | 1657 | self.assertEquals(listing[0][0], '0/0000') |
353 | 1652 | self.assertEquals(listing[-1][0], '0/0099') | 1658 | self.assertEquals(listing[-1][0], '0/0099') |
354 | 1653 | 1659 | ||
356 | 1654 | listing = broker.list_containers_iter(100, '0/0099', None, '') | 1660 | listing = broker.list_containers_iter(100, '', '0/0050', None, '') |
357 | 1661 | self.assertEquals(len(listing), 51) | ||
358 | 1662 | self.assertEquals(listing[0][0], '0/0000') | ||
359 | 1663 | self.assertEquals(listing[-1][0], '0/0050') | ||
360 | 1664 | |||
361 | 1665 | listing = broker.list_containers_iter(100, '0/0099', None, None, '') | ||
362 | 1655 | self.assertEquals(len(listing), 100) | 1666 | self.assertEquals(len(listing), 100) |
363 | 1656 | self.assertEquals(listing[0][0], '0/0100') | 1667 | self.assertEquals(listing[0][0], '0/0100') |
364 | 1657 | self.assertEquals(listing[-1][0], '1/0074') | 1668 | self.assertEquals(listing[-1][0], '1/0074') |
365 | 1658 | 1669 | ||
367 | 1659 | listing = broker.list_containers_iter(55, '1/0074', None, '') | 1670 | listing = broker.list_containers_iter(55, '1/0074', None, None, '') |
368 | 1660 | self.assertEquals(len(listing), 55) | 1671 | self.assertEquals(len(listing), 55) |
369 | 1661 | self.assertEquals(listing[0][0], '1/0075') | 1672 | self.assertEquals(listing[0][0], '1/0075') |
370 | 1662 | self.assertEquals(listing[-1][0], '2/0004') | 1673 | self.assertEquals(listing[-1][0], '2/0004') |
371 | 1663 | 1674 | ||
383 | 1664 | listing = broker.list_containers_iter(10, '', '0/01', '') | 1675 | listing = broker.list_containers_iter(10, '', None, '0/01', '') |
384 | 1665 | self.assertEquals(len(listing), 10) | 1676 | self.assertEquals(len(listing), 10) |
385 | 1666 | self.assertEquals(listing[0][0], '0/0100') | 1677 | self.assertEquals(listing[0][0], '0/0100') |
386 | 1667 | self.assertEquals(listing[-1][0], '0/0109') | 1678 | self.assertEquals(listing[-1][0], '0/0109') |
387 | 1668 | 1679 | ||
388 | 1669 | listing = broker.list_containers_iter(10, '', '0/01', '/') | 1680 | listing = broker.list_containers_iter(10, '', None, '0/01', '/') |
389 | 1670 | self.assertEquals(len(listing), 10) | 1681 | self.assertEquals(len(listing), 10) |
390 | 1671 | self.assertEquals(listing[0][0], '0/0100') | 1682 | self.assertEquals(listing[0][0], '0/0100') |
391 | 1672 | self.assertEquals(listing[-1][0], '0/0109') | 1683 | self.assertEquals(listing[-1][0], '0/0109') |
392 | 1673 | 1684 | ||
393 | 1674 | listing = broker.list_containers_iter(10, '', '0/', '/') | 1685 | listing = broker.list_containers_iter(10, '', None, '0/', '/') |
394 | 1675 | self.assertEquals(len(listing), 10) | 1686 | self.assertEquals(len(listing), 10) |
395 | 1676 | self.assertEquals(listing[0][0], '0/0000') | 1687 | self.assertEquals(listing[0][0], '0/0000') |
396 | 1677 | self.assertEquals(listing[-1][0], '0/0009') | 1688 | self.assertEquals(listing[-1][0], '0/0009') |
397 | 1678 | 1689 | ||
399 | 1679 | listing = broker.list_containers_iter(10, '', '', '/') | 1690 | listing = broker.list_containers_iter(10, '', None, '', '/') |
400 | 1680 | self.assertEquals(len(listing), 4) | 1691 | self.assertEquals(len(listing), 4) |
401 | 1681 | self.assertEquals([row[0] for row in listing], | 1692 | self.assertEquals([row[0] for row in listing], |
402 | 1682 | ['0/', '1/', '2/', '3/']) | 1693 | ['0/', '1/', '2/', '3/']) |
403 | 1683 | 1694 | ||
405 | 1684 | listing = broker.list_containers_iter(10, '2/', None, '/') | 1695 | listing = broker.list_containers_iter(10, '2/', None, None, '/') |
406 | 1685 | self.assertEquals(len(listing), 1) | 1696 | self.assertEquals(len(listing), 1) |
407 | 1686 | self.assertEquals([row[0] for row in listing], ['3/']) | 1697 | self.assertEquals([row[0] for row in listing], ['3/']) |
408 | 1687 | 1698 | ||
410 | 1688 | listing = broker.list_containers_iter(10, '', '2', '/') | 1699 | listing = broker.list_containers_iter(10, '', None, '2', '/') |
411 | 1689 | self.assertEquals(len(listing), 1) | 1700 | self.assertEquals(len(listing), 1) |
412 | 1690 | self.assertEquals([row[0] for row in listing], ['2/']) | 1701 | self.assertEquals([row[0] for row in listing], ['2/']) |
413 | 1691 | 1702 | ||
415 | 1692 | listing = broker.list_containers_iter(10, '2/0050', '2/', '/') | 1703 | listing = broker.list_containers_iter(10, '2/0050', None, '2/', '/') |
416 | 1693 | self.assertEquals(len(listing), 10) | 1704 | self.assertEquals(len(listing), 10) |
417 | 1694 | self.assertEquals(listing[0][0], '2/0051') | 1705 | self.assertEquals(listing[0][0], '2/0051') |
418 | 1695 | self.assertEquals(listing[1][0], '2/0051/') | 1706 | self.assertEquals(listing[1][0], '2/0051/') |
419 | 1696 | self.assertEquals(listing[2][0], '2/0052') | 1707 | self.assertEquals(listing[2][0], '2/0052') |
420 | 1697 | self.assertEquals(listing[-1][0], '2/0059') | 1708 | self.assertEquals(listing[-1][0], '2/0059') |
421 | 1698 | 1709 | ||
423 | 1699 | listing = broker.list_containers_iter(10, '3/0045', '3/', '/') | 1710 | listing = broker.list_containers_iter(10, '3/0045', None, '3/', '/') |
424 | 1700 | self.assertEquals(len(listing), 10) | 1711 | self.assertEquals(len(listing), 10) |
425 | 1701 | self.assertEquals([row[0] for row in listing], | 1712 | self.assertEquals([row[0] for row in listing], |
426 | 1702 | ['3/0045/', '3/0046', '3/0046/', '3/0047', | 1713 | ['3/0045/', '3/0046', '3/0046/', '3/0047', |
427 | @@ -1704,21 +1715,21 @@ | |||
428 | 1704 | '3/0049/', '3/0050']) | 1715 | '3/0049/', '3/0050']) |
429 | 1705 | 1716 | ||
430 | 1706 | broker.put_container('3/0049/', normalize_timestamp(time()), 0, 0, 0) | 1717 | broker.put_container('3/0049/', normalize_timestamp(time()), 0, 0, 0) |
432 | 1707 | listing = broker.list_containers_iter(10, '3/0048', None, None) | 1718 | listing = broker.list_containers_iter(10, '3/0048', None, None, None) |
433 | 1708 | self.assertEquals(len(listing), 10) | 1719 | self.assertEquals(len(listing), 10) |
434 | 1709 | self.assertEquals([row[0] for row in listing], | 1720 | self.assertEquals([row[0] for row in listing], |
435 | 1710 | ['3/0048/0049', '3/0049', '3/0049/', '3/0049/0049', | 1721 | ['3/0048/0049', '3/0049', '3/0049/', '3/0049/0049', |
436 | 1711 | '3/0050', '3/0050/0049', '3/0051', '3/0051/0049', | 1722 | '3/0050', '3/0050/0049', '3/0051', '3/0051/0049', |
437 | 1712 | '3/0052', '3/0052/0049']) | 1723 | '3/0052', '3/0052/0049']) |
438 | 1713 | 1724 | ||
440 | 1714 | listing = broker.list_containers_iter(10, '3/0048', '3/', '/') | 1725 | listing = broker.list_containers_iter(10, '3/0048', None, '3/', '/') |
441 | 1715 | self.assertEquals(len(listing), 10) | 1726 | self.assertEquals(len(listing), 10) |
442 | 1716 | self.assertEquals([row[0] for row in listing], | 1727 | self.assertEquals([row[0] for row in listing], |
443 | 1717 | ['3/0048/', '3/0049', '3/0049/', '3/0050', | 1728 | ['3/0048/', '3/0049', '3/0049/', '3/0050', |
444 | 1718 | '3/0050/', '3/0051', '3/0051/', '3/0052', | 1729 | '3/0050/', '3/0051', '3/0051/', '3/0052', |
445 | 1719 | '3/0052/', '3/0053']) | 1730 | '3/0052/', '3/0053']) |
446 | 1720 | 1731 | ||
448 | 1721 | listing = broker.list_containers_iter(10, None, '3/0049/', '/') | 1732 | listing = broker.list_containers_iter(10, None, None, '3/0049/', '/') |
449 | 1722 | self.assertEquals(len(listing), 2) | 1733 | self.assertEquals(len(listing), 2) |
450 | 1723 | self.assertEquals([row[0] for row in listing], | 1734 | self.assertEquals([row[0] for row in listing], |
451 | 1724 | ['3/0049/', '3/0049/0049']) | 1735 | ['3/0049/', '3/0049/0049']) |
452 | @@ -1738,20 +1749,20 @@ | |||
453 | 1738 | broker.put_container('b/a', normalize_timestamp(time()), 0, 0, 0) | 1749 | broker.put_container('b/a', normalize_timestamp(time()), 0, 0, 0) |
454 | 1739 | broker.put_container('b/b', normalize_timestamp(time()), 0, 0, 0) | 1750 | broker.put_container('b/b', normalize_timestamp(time()), 0, 0, 0) |
455 | 1740 | broker.put_container('c', normalize_timestamp(time()), 0, 0, 0) | 1751 | broker.put_container('c', normalize_timestamp(time()), 0, 0, 0) |
457 | 1741 | listing = broker.list_containers_iter(15, None, None, None) | 1752 | listing = broker.list_containers_iter(15, None, None, None, None) |
458 | 1742 | self.assertEquals(len(listing), 10) | 1753 | self.assertEquals(len(listing), 10) |
459 | 1743 | self.assertEquals([row[0] for row in listing], | 1754 | self.assertEquals([row[0] for row in listing], |
460 | 1744 | ['a', 'a/', 'a/a', 'a/a/a', 'a/a/b', 'a/b', 'b', | 1755 | ['a', 'a/', 'a/a', 'a/a/a', 'a/a/b', 'a/b', 'b', |
461 | 1745 | 'b/a', 'b/b', 'c']) | 1756 | 'b/a', 'b/b', 'c']) |
463 | 1746 | listing = broker.list_containers_iter(15, None, '', '/') | 1757 | listing = broker.list_containers_iter(15, None, None, '', '/') |
464 | 1747 | self.assertEquals(len(listing), 5) | 1758 | self.assertEquals(len(listing), 5) |
465 | 1748 | self.assertEquals([row[0] for row in listing], | 1759 | self.assertEquals([row[0] for row in listing], |
466 | 1749 | ['a', 'a/', 'b', 'b/', 'c']) | 1760 | ['a', 'a/', 'b', 'b/', 'c']) |
468 | 1750 | listing = broker.list_containers_iter(15, None, 'a/', '/') | 1761 | listing = broker.list_containers_iter(15, None, None, 'a/', '/') |
469 | 1751 | self.assertEquals(len(listing), 4) | 1762 | self.assertEquals(len(listing), 4) |
470 | 1752 | self.assertEquals([row[0] for row in listing], | 1763 | self.assertEquals([row[0] for row in listing], |
471 | 1753 | ['a/', 'a/a', 'a/a/', 'a/b']) | 1764 | ['a/', 'a/a', 'a/a/', 'a/b']) |
473 | 1754 | listing = broker.list_containers_iter(15, None, 'b/', '/') | 1765 | listing = broker.list_containers_iter(15, None, None, 'b/', '/') |
474 | 1755 | self.assertEquals(len(listing), 2) | 1766 | self.assertEquals(len(listing), 2) |
475 | 1756 | self.assertEquals([row[0] for row in listing], ['b/a', 'b/b']) | 1767 | self.assertEquals([row[0] for row in listing], ['b/a', 'b/b']) |
476 | 1757 | 1768 | ||
477 | 1758 | 1769 | ||
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 | 46 | pass | 46 | pass |
483 | 47 | 47 | ||
484 | 48 | class DumbInternalProxy(object): | 48 | class DumbInternalProxy(object): |
486 | 49 | def get_container_list(self, account, container, marker=None): | 49 | def get_container_list(self, account, container, marker=None, |
487 | 50 | end_marker=None): | ||
488 | 50 | n = '2010/03/14/13/obj1' | 51 | n = '2010/03/14/13/obj1' |
489 | 51 | if marker is None or n > marker: | 52 | if marker is None or n > marker: |
490 | 53 | if end_marker and n <= end_marker: | ||
491 | 54 | return [{'name': n}] | ||
492 | 55 | elif end_marker: | ||
493 | 56 | return [] | ||
494 | 52 | return [{'name': n}] | 57 | return [{'name': n}] |
497 | 53 | else: | 58 | return [] |
496 | 54 | return [] | ||
498 | 55 | 59 | ||
499 | 56 | def get_object(self, account, container, object_name): | 60 | def get_object(self, account, container, object_name): |
500 | 57 | code = 200 | 61 | 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.