460 Commits

Author SHA1 Message Date
Jenkins
52b849217f Merge "Add tests for uploads deleting DLO segments" 2015-05-21 00:47:28 +00:00
Jenkins
53432b5739 Merge "Add test for timeout being passed to keystone client" 2015-05-21 00:44:51 +00:00
Jenkins
1aebb7ccc5 Merge "Use a socket timeout in get_auth" 2015-05-04 19:28:15 +00:00
Jenkins
766cf73247 Merge "Compare each chunk of large objects when uploading" 2015-04-30 18:48:59 +00:00
Alistair Coles
a39e18ff5a Add test for timeout being passed to keystone client
Extends existing unit test for timeout being passed to get_auth
to cover v2.0 auth when keystone client should get the timeout
kwarg.

Related-Bug: 1447847
Change-Id: Ie9cfc86fa2156b94b45d290ac12e3f71b20d6c4f
2015-04-28 16:58:23 +01:00
Pete Zaitcev
e2f41a6635 Use a socket timeout in get_auth
A previous change added socket timeouts, but they weren't plumbed
through to the get_auth code path. Make sure we're passing them along
everywhere.

Original-Author: Monty Taylor <mordred@inaugust.com>
Change-Id: I398241898248e66d1f8c436c8ed2ec7a0e9387f6
Closes-bug: 1447847
2015-04-26 01:37:15 -06:00
Jenkins
ea6d2bf74d Merge "Add socket-level read timeout parameter" 2015-04-24 01:18:49 +00:00
Jenkins
3105cdc4f8 Merge "Include unsupported url scheme with ClientException" 2015-03-31 22:18:44 +00:00
Monty Taylor
f5a473edfc Add socket-level read timeout parameter
The underlying requests library supports a timeout input parameter. The
other python-*client libraries support passing it in, so while working
on shade, it seemed like a great idea to be able to pass in timeout to
swiftclient too. For reference, there's a change in shade:
I095c1240693abf024bda2315dd77f4400b24a45b that shows interaction with
the other libs, and a tentative patch that would consume this one.

Change-Id: I699ebb1e092aa010af678de7ba15712da6ed5315
2015-03-30 17:01:02 -04:00
Tim Burke
a4fb70ece1 Compare each chunk of large objects when uploading
Previously, we compared the ETag from Swift against the MD5 of the
entire large object. However, the ETag for large objects is generally
the MD5 of the concatenation of the ETags for each segment, unless the
object is a DLO whose segments span more than one page of a container
listing. Rather than worry about ETags, just compare each chunk of the
segmented file. This allows the use of --skip-identical when uploading
SLOs and DLOs.

Additionally, there are several test-related improvements:
 * The default arguments for OutputManager are now evaluated on
   construction, rather than on definition, so that
   TestOutputManager.test_instantiation will succeed when using nosetest
   as a test runner. (See also: bug 1251507)
 * An account_username option is now available in the functional tests
   config file for auth systems that do not follow the account:username
   format.
 * CaptureOutput no longer writes to the captured stream, and
   MockHttpTest now captures output. These were polluting test output
   unnecessarily. (See also: bug 1201376)

Change-Id: Ic484e9a0c186c9283c4012c6a2fa77b96b8edf8a
Closes-Bug: #1201376
Closes-Bug: #1379252
Related-Bug: #1251507
2015-03-23 18:35:45 -07:00
Tim Burke
c9f79e641c Mention --segment-size option after 413 response
Previously, it would only output something like

  ClientException: Object PUT failed <url> 413 Request Entity Too Large
  Your request is too large.

... which is misleading as it implies that Swift simply can't handle
large objects.

Change-Id: Icec9e76b2671490c3a2249ec08992950107c6828
2.4.0
2015-03-05 15:37:18 -08:00
Jenkins
8e94ca6394 Merge "Unindent a chunk of st_list" 2015-03-05 21:19:06 +00:00
Daniel Wakefield
13780f37c3 Add improvements to MD5 validation.
With MD5Sum checking being added, a concern was brought up that It was
a change with no possibility of reverting to the old behaviour.
This change adds the flag '--ignore-checksum' to the upload subcommand
allowing the checks to be turned off.

Changed occurrences of the magic string for a null md5 to use a descriptive
constant instead.

Updated Error messages generated when validation fails. They should now be more descriptive
and not output a literal newline sequence.

Change-Id: Id1756cbb6700bb7e38f0ee0e75bc535e37f777ed
2015-03-04 14:01:55 +00:00
Pete Zaitcev
35bcad638c Unindent a chunk of st_list
The chunk looks like nicely containable, but it pushes against the
right edge of the screen annoyingly. This patch _only_ prettifies,
without any observable changes.

Change-Id: I96fcb5848e3e5e0e8a8ebbe398b1d4a0bea5fa24
2015-02-26 15:46:13 -07:00
Alistair Coles
dcf2124d41 Add tests for uploads deleting DLO segments
This patch adds unit tests to verify that
uploads overwriting an existing DLO manifest
will delete any segments pointed to by the
manifest, unless --leave-segments is specified.

Also test the --leave-segments option with an
existing SLO manifest.

Related-Bug: 1418007

Change-Id: I54e8eb138976269bb36392a811089c33c1ace4d3
2015-02-25 16:52:23 +00:00
Jenkins
925c01ebfb Merge "Release connection after consuming the content" 2015-02-25 13:54:14 +00:00
Jenkins
771383145b Merge "Fix crash when stat'ing objects with non-ascii names" 2015-02-25 13:10:56 +00:00
Ian Cordasco
8756591b0a Release connection after consuming the content
When using stream=True, we need to make sure we release a connection
back to the connection pool to avoid warnings clogging up the logs. We
can do this by releasing the connection once we've read all the content
from the response. In situations where stream=False, requests already
does this for us.

Related-bug: 1424732
Closes-bug: 1341777
Change-Id: Id1c72ad86135a49d4b985992d788736b65f7dbda
2015-02-25 11:00:56 +00:00
Jenkins
731707f06d Merge "Fix crash with -l, -d /, and pseudo folders" 2015-02-25 05:39:23 +00:00
Jenkins
19a298bdaa Merge "Verify MD5 of uploaded objects." 2015-02-24 08:22:18 +00:00
Alistair Coles
47f089fbca Include unsupported url scheme with ClientException
This was an attempt to reveal some more info about failing
jenkins jobs such as here [1] where glance_store is
receiving a swiftclient exception because of 'unsupported
scheme in url'. It seems worth merging the more helpful
exception message.

[1] http://logs.openstack.org/91/155291/7/check/gate-tempest-dsvm-neutron-src-python-swiftclient/4adac1e/

Change-Id: I0f3411efd42d045b07d6d1000f59a06865d8034b
2015-02-23 19:10:32 +00:00
Daniel Wakefield
f0300e3714 Verify MD5 of uploaded objects.
Changed existing code to calculate the MD5 of the object
during the upload stream. Checks this MD5 against the etag
returned in the response.
An exception is raised if they do not match.

Closes-Bug: 1379263

Change-Id: I6c8bc1366dfb591a26d934a30cd21c9e6b9a04ce
2015-02-19 11:21:32 +00:00
Pete Zaitcev
fec5d068a0 Fix crash with -l, -d /, and pseudo folders
Using -l, -d /, or a pseduo folder by itself works fine, but if you
combine all of them, this happens:

[zaitcev@guren s]$ swift list -d / testcont
amazon_lili.jpg
pseudodir/
rin_shibuya_pixiv.jpg
swift-c134855-5a.diff
[zaitcev@guren s]$ swift list -d / -l testcont
      151954 2014-06-20 17:13:52 amazon_lili.jpg
Traceback (most recent call last):
  File "/q/zaitcev/hail/python-swiftclient-tip/bin/swift", line 24, in <module>
    sys.exit(main())
  File "/q/zaitcev/hail/python-swiftclient-tip/swiftclient/shell.py", line 1301, in main
    globals()['st_%s' % args[0]](parser, argv[1:], output)
  File "/q/zaitcev/hail/python-swiftclient-tip/swiftclient/shell.py", line 414, in st_list
    total_bytes += item_bytes
TypeError: unsupported operand type(s) for +=: 'int' and 'NoneType'

The patch is a straightforward fix that assigns expected variables.

Change-Id: If24dcc2491e8b8982455107d2aca30c0491a398a
Closes-Bug: 1399678
2015-02-18 19:46:41 -07:00
Sean Dague
8aff0bda9c add functional tox target
move the contents of the functional test hook into tox for
consistency.

Change-Id: I730f1bb530215ba7c30bf32a1c3bbc16edd5c217
Required-By: https://review.openstack.org/#/c/156676
2015-02-17 15:00:00 -08:00
Joel Wright
cac21e3cff Fix crash when stat'ing objects with non-ascii names
This patch fixes a crash and stack trace in stat when an object
name contains non-ascii characters.

Change-Id: Ib6dc686771e593243de56cafc100b17e51d9d9d5
Closes-Bug: 1411665
2015-02-17 14:52:35 +00:00
Jenkins
45cce75e50 Merge "Add help message for "<subcommand> --help"" 2015-02-10 23:51:28 +00:00
Hirokazu Sakata
eb85f8c1a4 Add help message for "<subcommand> --help"
This patch fixed help message for "<subcommand> --help" in
general help message. Previous help message was only
"this help message". It has not described for subcommand.

Change-Id: I2fe6413baf98ba3881425ee6bed29c618e29fff8
Closes-Bug: 1420253
2015-02-10 20:52:17 +09:00
Charles Hsu
df2442166c Fix missing ca-certificate parameter to get_auth.
Missing cacert parameter in get_auth_1_0() and it makes requests_args['verify']
is True in default(likes "swift --os-cacert ssl.crti list").
The requests_args['verify'] should be a ca-certificate file name("ssl.crt").

Change-Id: Id3110f3818f55922ad19eeb1ead80fface824009
Closes-Bug: 1418473
2015-02-07 11:42:49 +08:00
Joel Wright
06c73c6020 Fix deleting SLO segments on overwrite
This patch fixes a bug that results in SLO segments being left
behind regardless of the setting of --leave-segments.

Change-Id: I2b3c8ab4817df6facb4b5961dbe570645441a552
Closes-Bug: 1418007
2015-02-04 14:17:54 +00:00
Jenkins
eb28d8aff6 Merge "This patch fixes downloading files to stdout." 2015-02-03 18:55:47 +00:00
Jenkins
21473f1bc4 Merge "Fix cross account upload using --os-storage-url" 2015-02-02 08:30:40 +00:00
Joel Wright
bd42c2b00d This patch fixes downloading files to stdout.
This patch fixes downloading files to stdout and modifies
_SwiftReader to operate as an iterator that performs file
checks at the end of iteration as well as a context manager.
File verification checks have been removed from __exit__
and added to __iter__.

Change-Id: I3250bdeeef8484a9122c4b5b854756a7c8f8731e
Closes-Bug: 1395922
Closes-Bug: 1387376
2015-01-23 11:46:13 +00:00
Clay Gerrard
eef91b3513 Fix environment sanitization for TestServiceUtils
I'm not sure how test_process_options_defaults ever passed for anyone that had
all the ST_(AUTH|USER|KEY) set in their environment when they ran it.  Despite
our efforts to patch os.environ swiftclient.servce was acctually importing
environ from os and then sticking the results into some global state.  The
tests seemed to work fine on infra, but for me locally until I `unset ST_AUTH`
the test would always fail.  Seems to work now and looks fairly reasonable on
the surface.

Change-Id: Id68590d6af16040a2877e719bc38d1e126603e42
2015-01-21 17:20:53 -08:00
Jenkins
7709fea51e Merge "Check that content_type header exists before using" 2015-01-10 03:42:45 +00:00
Alistair Coles
9593d4b58a Fix cross account upload using --os-storage-url
Removes an account stat from the object upload path.
This stat fails when user is not account admin even
though the user may have container ACL permission to
write objects.

Reduces the severity of the CLI output message when
upload fails to create the given container (this is
not an error since the container may exist - the user
just does not have permission to PUT or POST the
container).

Changes the 'swift upload' exit return code from 1 to
0 if container PUT fails but object PUT succeeds.

For segment uploads, makes the attempt to create the
segment container conditional on it not being the same
as the manifest container. This avoids an unnecessary
container PUT.

Fixes another bug that became apparent: with segmented
upload a container HEAD may be attempted to determine
the policy to be used for the segment container. When
this failed the result dict has headers=None which was
causing an exception in the shell result handler.

Add unit tests for object upload/download and container
list with --os-storage-url option.

Closes-Bug: #1371650
Change-Id: If1f8a02ee7459ea2158ffa6e958f67d299ec529e
2015-01-06 16:13:39 +00:00
Alistair Coles
488272ee59 Change tests to use CaptureOutput class
Modify two tests to use the CaptureOutput class. These
tests were added after the comprehensive transition to using
CaptureOutput made in change [1], so this is just bringing
them in line with that test pattern.

Also deletes an unused mock.

[1] change id Ib59bbbe88256f215eed0a8ebc8282e02181d4377

Change-Id: Ic524311ffb3b0d6566addec0676633ddb8075e25
2015-01-05 11:23:56 +00:00
Jiří Suchomel
5d57018707 Print info message about incorrect --totals usage
when neither -l nor --lh is provided.
Added test coverage for --totals.

Change-Id: I3245e715c26ec28457a21dec07311a58c475c066
Closes-Bug: 1258392
2015-01-05 11:02:00 +00:00
Jenkins
2dde767e93 Merge "Fix misplaced check for None in SwiftUploadObject." 2015-01-04 22:23:58 +00:00
Jenkins
9aeb2cfaf4 Merge "Suppress 'No handlers...' message from keystoneclient logger" 2015-01-02 19:07:11 +00:00
Jenkins
eace20c14a Merge "Make preauth params work" 2014-12-31 00:06:12 +00:00
Jenkins
dfbb1807fb Merge "Change tests to use new CaptureOutput class." 2014-12-30 21:28:43 +00:00
Clay Gerrard
fbe558885f Make preauth params work
If you specify a token and storage url when creating a Connection,
regardless of the auth api version the first request will be made
directly to swift.  You can either provide a preauthurl and preauthtoken
or fall back to os_options' object_storage_url and auth_token keys
(exposed as --os-storage-url and --os-auth-token on the command line or
OS_STORAGE_URL and OS_AUTH_TOKEN in the environment).

If a _retry wrapped request on a Connection fails because of invalid
authentication (401) the Connection's cached token and url will be
invalidated.  If the Connection's retries attribute is > 0 the
subsequent attempt will call get_auth to refresh the token, but the
pre-configured storage_url will always be re-used.  This is consistent
with current auth v2 behavior and less surprising for auth v1.

The pre-existing, but previously undocumented behavior/interface of
get_auth would override the storage_url returned by the auth service if
the 'os_storage_url' option was provided in the os_options dict.  To
ensure that this behavior is consistent across auth v1 and v2 from the
command line and when using the Connection class as a library - the
preauthurl is stashed in the os_options dict when provided.

Improved Connection.get_capabilities storage_url handling to better
support the consistent behavior of a preauthurl/object_storage_url on
the connection regardless of auth version.

Fixed up some test infrastructure to enable setting up and testing
multiple requests/responses.

Change-Id: I6950fb73f3e28fdddb62760cae9320e2f4336776
2014-12-17 05:53:56 -07:00
Daniel Wakefield
8fa6cc9b1b Fix misplaced check for None in SwiftUploadObject.
Check for None was being done after a method call which
caused an attribute error if the value was None.
The Method call was also a mistake and has been corrected to the
hasattr function like intended.

Added Tests.

Closes-Bug: 1392651
Change-Id: Ifb1c84e26533bccbaddcce5738f434f36feca74e
2014-12-16 14:16:34 +00:00
Jenkins
d59af8cc8b Merge "Show warning when auth_version >= 2 and keystoneclient is missing" 2014-12-15 19:07:23 +00:00
Jenkins
7980704c33 Merge "Fix misnamed dictionary key." 2014-12-15 19:02:23 +00:00
Daniel Wakefield
5756fcc4f2 Fix misnamed dictionary key.
The response dictionary in _delete_segment attach's any error
it encounters to the dict key 'exception', all other response
dict's use 'error' to store the exception.

Changed to make it consistent and added tests

Also added a third branch in st_delete as messages
created in _delete_container where being silently dropped.

Change-Id: Ifbc3b1fae78910fbc6acf4a86cfb0f60bb1aa336
2014-12-08 15:45:40 +00:00
Daniel Wakefield
49a80f734c Change tests to use new CaptureOutput class.
Added the ability to clear the buffers in the
CaptureOutput class so it can be easily used multiple
times in the same context manager.
Also added a option to suppress the SystemExit
associated with printing an error.

Change-Id: Ib59bbbe88256f215eed0a8ebc8282e02181d4377
2014-12-05 10:57:09 +00:00
Jeremy Stanley
79fb53190e Workflow documentation is now in infra-manual
Replace URLs for workflow documentation to appropriate parts of the
OpenStack Project Infrastructure Manual.

Change-Id: I7513a141c95f3126ad348ed679b2baa335bdf45f
2014-12-05 15:32:57 +11:00
Christian Schwede
47546eb145 Show warning when auth_version >= 2 and keystoneclient is missing
Swiftclient hangs forever without any reasonable hint if someone
uses a recent version of swiftclient together with auth version
2 or later. The reason for this is the sys.exit() call in a thread
- the main thread never exists, and swift just waits forever.

Raising a ClientException instead of calling sys.exit() fixes this
and returns the desired information back to the user.

Change-Id: I1fdff85da2dd4b883d337d6098b1695e448d6f2b
2014-11-25 13:15:08 +01:00
Clay Gerrard
d89e08f722 Capture test output better
This change adds some new classes to test.unit.utils which wrap up the
collection and mocking of the std err and std out.  This will make the
testing code easier to write and maintain.

Change-Id: I50ad2a736b2bb550ab83f6a43fb5a0fb5393573e
2014-11-20 14:42:55 +00:00