Fix downloading from "marker" item
The documentation of "swift download" hints that "marker" option is supported, but in reality we forgot to patch it through, so all downloads were always done with the default, empty marker. Closes-Bug: #1565393 Change-Id: I38bd29d2baa9188b61397dec75ce1d864041653c
This commit is contained in:
parent
f86b2d8138
commit
909bdf8954
@ -883,7 +883,7 @@ class SwiftService(object):
|
||||
|
||||
@staticmethod
|
||||
def _list_container_job(conn, container, options, result_queue):
|
||||
marker = ''
|
||||
marker = options.get('marker', '')
|
||||
error = None
|
||||
try:
|
||||
while True:
|
||||
|
@ -203,7 +203,7 @@ def st_delete(parser, args, output_manager):
|
||||
output_manager.error(err.value)
|
||||
|
||||
|
||||
st_download_options = '''[--all] [--marker] [--prefix <prefix>]
|
||||
st_download_options = '''[--all] [--marker <marker>] [--prefix <prefix>]
|
||||
[--output <out_file>] [--output-dir <out_directory>]
|
||||
[--object-threads <threads>]
|
||||
[--container-threads <threads>] [--no-download]
|
||||
@ -225,7 +225,7 @@ Positional arguments:
|
||||
Optional arguments:
|
||||
-a, --all Indicates that you really want to download
|
||||
everything in the account.
|
||||
-m, --marker Marker to use when starting a container or account
|
||||
-m, --marker <marker> Marker to use when starting a container or account
|
||||
download.
|
||||
-p, --prefix <prefix> Only download items beginning with <prefix>
|
||||
-r, --remove-prefix An optional flag for --prefix <prefix>, use this
|
||||
|
@ -687,6 +687,41 @@ class TestServiceList(_TestServiceBase):
|
||||
self.assertEqual(expected_r_long, self._get_queue(mock_q))
|
||||
self.assertIsNone(self._get_queue(mock_q))
|
||||
|
||||
def test_list_container_marker(self):
|
||||
mock_q = Queue()
|
||||
mock_conn = self._get_mock_connection()
|
||||
|
||||
get_container_returns = [
|
||||
(None, [{'name': 'b'}, {'name': 'c'}]),
|
||||
(None, [])
|
||||
]
|
||||
mock_get_cont = Mock(side_effect=get_container_returns)
|
||||
mock_conn.get_container = mock_get_cont
|
||||
|
||||
expected_r = self._get_expected({
|
||||
'action': 'list_container_part',
|
||||
'container': 'test_c',
|
||||
'success': True,
|
||||
'listing': [{'name': 'b'}, {'name': 'c'}],
|
||||
'marker': 'b'
|
||||
})
|
||||
|
||||
_opts = self.opts.copy()
|
||||
_opts['marker'] = 'b'
|
||||
SwiftService._list_container_job(mock_conn, 'test_c', _opts, mock_q)
|
||||
|
||||
# This does not test if the marker is propagated, because we always
|
||||
# get the final call to the get_container with the final item 'c',
|
||||
# even if marker wasn't set. This test just makes sure the whole
|
||||
# stack works in a sane way.
|
||||
mock_kw = mock_get_cont.call_args[1]
|
||||
self.assertEqual(mock_kw['marker'], 'c')
|
||||
|
||||
# This tests that the lower levels get the marker delivered.
|
||||
self.assertEqual(expected_r, self._get_queue(mock_q))
|
||||
|
||||
self.assertIsNone(self._get_queue(mock_q))
|
||||
|
||||
def test_list_container_exception(self):
|
||||
mock_q = Queue()
|
||||
mock_conn = self._get_mock_connection()
|
||||
|
Loading…
x
Reference in New Issue
Block a user